-
-
Save brendanberg/870fa50bc860951bf2b5 to your computer and use it in GitHub Desktop.
L Syntax
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
# For now we're doing simple ASCII identifiers, but we'll add unicode support in the parser later. | |
identifier ::= letter subsequent* | '_' subsequent+ | |
subsequent ::= letter | digit | '_' | |
letter ::= 'a'...'z' | 'A'...'Z' | |
integer ::= decimalinteger | hexinteger | bininteger | |
decimalinteger ::= nonzerodigit digit* | '0' | |
hexinteger ::= '0' ('x' | 'X') hexdigit+ | |
bininteger ::= '0' ('b' | 'B') bindigit+ | |
nonzerodigit ::= '1'...'9' | |
digit ::= '0'...'9' | |
bindigit ::= '0' | '1' | |
hexdigit ::= digit | 'a'...'f' | 'A'...'F' | |
float ::= decimalinteger (mantissa | mantissa exponent) | |
mantissa ::= '.' digit* | |
exponent ::= ('e' | 'E') ['+' | '-'] digit+ | |
imaginary ::= (integer | float) ('j' | 'J') | |
sequence ::= '[' (commalist | range) ']' | |
range ::= (['-'] decimalinteger ':' [['-'] decimalinteger]) [stride] | |
| (':' ['-'] decimalinteger) [stride] | |
stride ::= '\' ['-'] decimalinteger | |
commalist ::= expression | expression ',' commalist | |
mapping ::= '{' maplist '}' | |
maplist ::= map | map ',' maplist | |
map ::= expression ':' expression | |
function ::= identifier '->' (expression | block) | |
block ::= indent blocklist outdent | |
blocklist ::= expression | expression br blocklist | |
# expression ::= ['='] expr | |
# expr ::= atom | '(' atom ')' | |
# molecule ::= atom | atom molecule+ | |
# atom ::= identifier | literal | |
# literal ::= integer | float | imaginary | sequence | mapping | string | function | bottom | |
bottom ::= '_' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment