2021-06-09 06:33:53 +00:00
|
|
|
program: decl*
|
2021-06-09 00:56:30 +00:00
|
|
|
|
2021-06-09 06:33:53 +00:00
|
|
|
?decl: iface
|
2021-06-09 00:56:30 +00:00
|
|
|
| node
|
2021-06-09 07:44:52 +00:00
|
|
|
| func
|
2021-06-09 00:56:30 +00:00
|
|
|
|
2021-06-09 06:33:53 +00:00
|
|
|
sep_trail{item, punc}: item (punc item)? punc?
|
2021-06-09 00:56:30 +00:00
|
|
|
|
2021-06-09 07:44:52 +00:00
|
|
|
func: "fn" ident "(" ")" ("->" ty) "{" "}"
|
|
|
|
|
2021-06-09 06:33:53 +00:00
|
|
|
iface: "iface" ident "{" sep_trail{iface_field, ","} "}"
|
|
|
|
iface_field: ident ":" ident
|
|
|
|
|
2021-06-09 07:44:52 +00:00
|
|
|
iface_ref: ident
|
|
|
|
iface_refs: iface_ref*
|
|
|
|
node: "node" ident ":" iface_refs "{" variants "}"
|
|
|
|
variants: variant*
|
|
|
|
variant: prod "=>" "{" equations "}"
|
2021-06-09 00:56:30 +00:00
|
|
|
prod: sym*
|
2021-06-09 05:10:45 +00:00
|
|
|
sym: sym_rename
|
2021-06-09 00:56:30 +00:00
|
|
|
| STRING
|
2021-06-09 06:33:53 +00:00
|
|
|
sym_rename: "<" ident ":" node_ref ">"
|
|
|
|
node_ref: node_ref_name
|
2021-06-09 00:56:30 +00:00
|
|
|
| STRING
|
2021-06-09 06:33:53 +00:00
|
|
|
node_ref_name: ident
|
2021-06-09 07:44:52 +00:00
|
|
|
equations: equation_*
|
2021-06-09 06:48:34 +00:00
|
|
|
equation_: equation ";"
|
2021-06-09 07:44:52 +00:00
|
|
|
// TODO: the left side should really be a separate type
|
|
|
|
// called lvalue, and should NOT include literals
|
2021-06-09 06:48:34 +00:00
|
|
|
equation: expr "=" expr
|
2021-06-09 00:56:30 +00:00
|
|
|
|
2021-06-09 05:10:45 +00:00
|
|
|
expr: expr_dot
|
|
|
|
| expr_add
|
|
|
|
| expr_mul
|
|
|
|
| expr_call
|
2021-06-09 06:33:53 +00:00
|
|
|
| expr_name
|
2021-06-09 06:48:34 +00:00
|
|
|
expr_dot: expr "." expr
|
|
|
|
expr_add: expr "+" expr
|
|
|
|
expr_mul: expr "*" expr
|
|
|
|
expr_call: expr "(" args ")"
|
2021-06-09 06:33:53 +00:00
|
|
|
expr_name: ident
|
2021-06-09 06:48:34 +00:00
|
|
|
args: sep_trail{expr, ","}
|
2021-06-09 00:56:30 +00:00
|
|
|
|
2021-06-09 07:44:52 +00:00
|
|
|
ty: ident
|
|
|
|
|
2021-06-09 06:33:53 +00:00
|
|
|
ident: IDENT
|
2021-06-09 07:44:52 +00:00
|
|
|
COMMENT: /\/\/[^\n]*/
|
2021-06-09 00:56:30 +00:00
|
|
|
IDENT: /([a-zA-Z][a-zA-Z0-9_]*)|(_[a-zA-Z0-9_]+)/
|
|
|
|
|
|
|
|
%import python.STRING
|
|
|
|
%import common.WS
|
2021-06-09 07:44:52 +00:00
|
|
|
%ignore WS
|
|
|
|
%ignore COMMENT
|