diff --git a/CodeGen/BMapBindings/ExpFctsLexer.g4 b/CodeGen/BMapBindings/ExpFctsLexer.g4 new file mode 100644 index 0000000..a705b40 --- /dev/null +++ b/CodeGen/BMapBindings/ExpFctsLexer.g4 @@ -0,0 +1,23 @@ +lexer grammar ExpFctsLexer; + +// keywords +EXPFCTS_EXPORT: 'LIBCMO_EXPORT' ; +EXPFCTS_FILE_DECL: 'BMPARAM_FILE_DECL' ; +EXPFCTS_MESHTRANS_DECL: 'BMPARAM_MESHTRANS_DECL' ; +EXPFCTS_OBJECT_DECL: 'BMPARAM_OBJECT_DECL' ; +EXPFCTS_PARAM_IN: 'BMPARAM_IN' ; +EXPFCTS_PARAM_OUT: 'BMPARAM_OUT' ; + +// symbols +EXPFCTS_LPARENTHESES: '(' ; +EXPFCTS_RPARENTHESES: ')' ; +EXPFCTS_COMMA: ',' ; +EXPFCTS_SEMICOLON: ';' ; +EXPFCTS_STAR: '*' ; +EXPFCTS_DOUBLE_COLON: '::' ; + +// identifider +EXPFCTS_IDENTIFIER: [_a-zA-Z][_a-zA-Z0-9]* ; + +// remove whitespace and line break +EXPFCTS_WS: [ \t\n\r\f]+ -> skip ; diff --git a/CodeGen/BMapBindings/ExpFctsParser.g4 b/CodeGen/BMapBindings/ExpFctsParser.g4 new file mode 100644 index 0000000..9bbae20 --- /dev/null +++ b/CodeGen/BMapBindings/ExpFctsParser.g4 @@ -0,0 +1,21 @@ +parser grammar ExpFctsParser; +options { tokenVocab = ExpFctsLexer; } + +program: fctDecl* ; + +fctDecl + : EXPFCTS_EXPORT varType EXPFCTS_IDENTIFIER '(' (fctArg (',' fctArg)*)? ')' ';' + ; + +fctArg + : EXPFCTS_FILE_DECL '(' EXPFCTS_IDENTIFIER ')' # fctArgFileDecl + | EXPFCTS_MESHTRANS_DECL '(' EXPFCTS_IDENTIFIER ')' #fctArgMeshTransDecl + | EXPFCTS_OBJECT_DECL '(' EXPFCTS_IDENTIFIER ',' EXPFCTS_IDENTIFIER ')' # fctArgObjDecl + | EXPFCTS_PARAM_IN '(' varType ',' EXPFCTS_IDENTIFIER ')' # fctArgParamIn + | EXPFCTS_PARAM_OUT '(' varType ',' EXPFCTS_IDENTIFIER ')' # fctArgParamOut + ; + +varType + : EXPFCTS_IDENTIFIER ('::' EXPFCTS_IDENTIFIER)* '*'? + ; +