Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 132c30a

Browse files
author
Patrick Thomson
committed
Add EBNF grammar.
1 parent 2b446df commit 132c30a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

docs/core-grammar.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Semantic Core grammar
2+
3+
This is an EBNF grammar for the (experimental) core IR language.
4+
5+
```
6+
expr ::= expr '.' expr
7+
| expr ' '+ expr
8+
| '{' expr (';' expr)* ';'? '}'
9+
| 'if' expr 'then' expr 'else' expr
10+
| ('lexical' | 'import' | 'load') expr
11+
| lit
12+
| 'let'? lvalue '=' expr
13+
| '(' expr ')'
14+
15+
lvalue ::= ident
16+
| parens expr
17+
18+
lit ::= '#true'
19+
| '#false'
20+
| 'unit'
21+
| 'frame'
22+
| lambda
23+
| ident
24+
25+
lambda ::= ('λ' | '\') ident ('->' | '→') expr
26+
27+
ident ::= [A-z_] ([A-z0-9_])*
28+
| '#{' [^{}]+ '}'
29+
| '"' [^"]+ '"'
30+
```

0 commit comments

Comments
 (0)