LiteRT-LM / runtime /components /tool_use /antlr /AntlrPythonParser.g4
SeaWolf-AI's picture
Upload full LiteRT-LM codebase
5f923cd verified
parser grammar AntlrPythonParser;
options {
tokenVocab = AntlrPythonLexer;
}
main: expr EOF;
expr: functionCall+ | functionCallList;
key: STRING;
value: INT | FLOAT | BOOL | STRING | NONE | list | dict | object;
list: LIST_OPEN (value (SEP value)* SEP?)? LIST_CLOSE;
dict
: OPEN_BRACE (key COLON value (SEP key COLON value)* SEP?)? CLOSE_BRACE
;
argVal: NAME EQ value;
argValExpr: argVal (SEP argVal)* SEP?;
object
: NAME OPEN_PAR CLOSE_PAR
| NAME OPEN_PAR argValExpr CLOSE_PAR
;
emptyFunctionCall: NAME OPEN_PAR CLOSE_PAR;
fullFunctionCall: NAME OPEN_PAR argValExpr CLOSE_PAR;
functionCall
: fullFunctionCall
| emptyFunctionCall
;
functionCallList
: LIST_OPEN functionCall (SEP functionCall)* SEP? LIST_CLOSE
| LIST_OPEN LIST_CLOSE;