Initial ANTLR grammar
This commit is contained in:
commit
cfce3e4dbb
7 changed files with 171 additions and 0 deletions
23
parser/src/main/antlr4/nu/zoom/dsl/parser/Endpoints.g4
Normal file
23
parser/src/main/antlr4/nu/zoom/dsl/parser/Endpoints.g4
Normal file
|
@ -0,0 +1,23 @@
|
|||
grammar Endpoints;
|
||||
|
||||
generatorconfig : '{' (configitem)? (',' configitem)* '}';
|
||||
configitem : configkey ':' configvalue ;
|
||||
configkey : IDENTIFIER ;
|
||||
configvalue : (IDENTIFIER|VALUE) ;
|
||||
fieldName : IDENTIFIER ;
|
||||
fieldType : IDENTIFIER ;
|
||||
compoundTypeName : IDENTIFIER ;
|
||||
compoundField : fieldName ':' fieldType ;
|
||||
compoundFields : '(' compoundField (',' compoundField)* ')' ;
|
||||
compoundType : compoundTypeName compoundFields ;
|
||||
pathSegment : '/' (IDENTIFIER|VALUE) ;
|
||||
path : (pathSegment)+ ;
|
||||
endpoint : path '<' (compoundFields | IDENTIFIER) ;
|
||||
|
||||
|
||||
fragment DIGIT : [0-9] ;
|
||||
fragment LOWERCASE : [a-z] ;
|
||||
fragment UPPERCASE : [A-Z] ;
|
||||
WS : [ \t\n\r]+ -> skip;
|
||||
IDENTIFIER : (LOWERCASE | UPPERCASE) (LOWERCASE | UPPERCASE | DIGIT)* ;
|
||||
VALUE : ~[ ,{}:()\n\t\r/<>"']+ ;
|
7
parser/src/main/java/nu/zoom/dsl/Main.java
Normal file
7
parser/src/main/java/nu/zoom/dsl/Main.java
Normal file
|
@ -0,0 +1,7 @@
|
|||
package nu.zoom.dsl;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello, World!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package nu.zoom.dsl.parser;
|
||||
|
||||
public class ParserFactory {
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue