Last active
June 11, 2016 22:38
-
-
Save ebb/4d723b3c5dfddb0854ab018260382553 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Terminals: | |
natural_number (regex: 0|[1-9][0-9]*) | |
character (examples: 'a', '\'', '"', '\n') | |
string (examples: "", "hello", "\treturn \"\";\n") | |
ident (regex: [a-z][a-z0-9_']*|[A-Z][A-Z0-9_']*) | |
Where, Let, Define, ... (a fixed finite subset of regex: [A-Z][a-z]+) | |
Nonterminals: | |
Note: Each source file matches the "package" nonterminal. | |
package = expr { Where { binder } } . | |
binder = Let ( ident | tuple_pattern | function_pattern ) body | |
| Define function_pattern body | |
| Do body . | |
tuple_pattern = '{' { '_' | ident | tuple_pattern } '}' . | |
function_pattern = '[' ident param_pattern { param_pattern } ']' . | |
param_pattern = '_' | ident | tuple_pattern . | |
variant_pattern = '`' ident [ '.' ( '_' | ident | tuple_pattern ) ] . | |
body = { { binder } In } expr . | |
expr = natural_number | character | string | | |
ident { '.' ( natural_number | ident ) } | | |
'`' ident [ '.' expr ] | | |
True | | |
False | | |
Prim ident | | |
Package string | | |
Func param_pattern { param_pattern } '.' body | | |
For expr binder | | |
Block body | | |
unary_op expr | | |
'(' expr { binary_op expr } ')' | | |
'{' ( List { expr } | Record { ident [ ':' expr ] } | { expr } ) '}' | | |
'[' expr expr { expr } ']' | | |
If expr expr expr | | |
And expr expr | | |
Or expr expr | | |
Cond { '|' expr body } ';' | | |
Switch expr { '|' ( '_' | ident | [ '-' ] ( natural_number | character ) ) body } ';' | | |
Match expr { '|' variant_pattern body } ';' | | |
Continue '[' ident expr { expr } ']' | | |
When expr { expr } End | | |
Begin { expr } End expr . | |
unary_op = '-' | '!' . | |
binary_op = '+' | '-' | '*' | '=' | '<' [ '=' ] | '>' [ '=' ] | '!' '=' | ':' ':' . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment