Switched to ANTLR parser branch
This commit is contained in:
parent
a8dae95e49
commit
c4f2b9ae65
28
pom.xml
28
pom.xml
|
|
@ -68,6 +68,20 @@
|
||||||
<excludePackageNames>example;*.impl</excludePackageNames>
|
<excludePackageNames>example;*.impl</excludePackageNames>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.antlr</groupId>
|
||||||
|
<artifactId>antlr4-maven-plugin</artifactId>
|
||||||
|
<version>4.2.2</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>antlr4</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<properties>
|
<properties>
|
||||||
|
|
@ -81,6 +95,20 @@
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.antlr</groupId>
|
||||||
|
<artifactId>antlr4-runtime</artifactId>
|
||||||
|
<version>4.2.1</version>
|
||||||
|
<classifier>complete</classifier>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.antlr</groupId>
|
||||||
|
<artifactId>antlr4</artifactId>
|
||||||
|
<version>4.2.1</version>
|
||||||
|
<classifier>complete</classifier>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
/** A Mikrotik API Command grammar */
|
||||||
|
|
||||||
|
grammar Command;
|
||||||
|
line: command param* where? retrn? ;
|
||||||
|
command: CMD ;
|
||||||
|
param: NAME ('=' text )? ;
|
||||||
|
text: NO_SPACE | QUOTED ;
|
||||||
|
where: 'where' expr ;
|
||||||
|
expr: ( eqExpr | hasExpr | moreExpr | lessExpr ) binExpr? ;
|
||||||
|
binExpr: andExpr | orExpr ;
|
||||||
|
eqExpr: NAME '=' text ;
|
||||||
|
hasExpr: NAME ;
|
||||||
|
moreExpr: NAME '>' text;
|
||||||
|
lessExpr: NAME '<' text;
|
||||||
|
andExpr: expr 'and' expr ;
|
||||||
|
orExpr: expr 'or' expr ;
|
||||||
|
retrn: 'returns' NAME (',' NAME )* ;
|
||||||
|
|
||||||
|
NAME : ('a'..'z'|'A'..'Z'|'-')+ ;
|
||||||
|
CMD_PART : ('/' NAME)+ ;
|
||||||
|
CMD : CMD_PART+ ;
|
||||||
|
NO_SPACE : [\\S]+ ;
|
||||||
|
QUOTED : ('"' [.]* '"') ;
|
||||||
Loading…
Reference in New Issue