1
1
mirror of https://github.com/github/semantic.git synced 2024-12-11 08:45:48 +03:00
semantic/docs/core-grammar.md

31 lines
608 B
Markdown
Raw Normal View History

2019-06-04 17:55:37 +03:00
# Semantic Core grammar
This is an EBNF grammar for the (experimental) core IR language.
```
expr ::= expr '.' expr
| expr ' '+ expr
| '{' expr (';' expr)* ';'? '}'
| 'if' expr 'then' expr 'else' expr
| ('lexical' | 'import' | 'load') expr
| lit
| 'let'? lvalue '=' expr
| '(' expr ')'
2019-06-04 17:55:37 +03:00
lvalue ::= ident
| parens expr
2019-06-04 17:55:37 +03:00
lit ::= '#true'
| '#false'
| 'unit'
| 'frame'
| lambda
| ident
2019-06-04 17:55:37 +03:00
lambda ::= ('λ' | '\') ident ('->' | '→') expr
2019-06-04 17:55:37 +03:00
ident ::= [A-z_] ([A-z0-9_])*
| '#{' [^{}]+ '}'
| '"' [^"]+ '"'
```