agtest/grammar.lark
2021-06-08 19:56:30 -05:00

44 lines
No EOL
722 B
Text

start: decl*
decl: iface
| node
iface: IFACE IDENT "{" iface_field (COMMA iface_field)? COMMA? "}"
iface_field: IDENT COLON IDENT
node: NODE IDENT COLON IDENT "{" node_prod* "}"
node_prod: prod THICCARROW "{" (equation SEMI)* "}"
prod: sym*
sym: IDENT
| LANG IDENT COLON node_ref RANG
| STRING
node_ref: IDENT
| STRING
equation: expr EQ expr
expr: expr DOT expr
| expr ADD expr
| expr MUL expr
| expr LPAR args RPAR
| IDENT
args: expr (COMMA expr)? COMMA?
IDENT: /([a-zA-Z][a-zA-Z0-9_]*)|(_[a-zA-Z0-9_]+)/
IFACE: "iface"
NODE: "node"
LANG: "<"
RANG: ">"
ADD: "+"
MUL: "*"
COMMA: ","
COLON: ":"
LPAR: "("
RPAR: ")"
EQ: "="
DOT: "."
SEMI: ";"
THICCARROW: "=>"
%import python.STRING
%import common.WS
%ignore WS