Initial ANTLR grammar

This commit is contained in:
Johan Maasing 2025-03-24 21:44:21 +01:00
commit cfce3e4dbb
Signed by: johan
GPG key ID: FFD31BABEE2DEED2
7 changed files with 171 additions and 0 deletions

View 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/<>"']+ ;

View file

@ -0,0 +1,7 @@
package nu.zoom.dsl;
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

View file

@ -0,0 +1,4 @@
package nu.zoom.dsl.parser;
public class ParserFactory {
}