Last active
September 15, 2017 23:36
-
-
Save PaulMaynard/5173c72c3d5431ac37acbafd494ab2db 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
root | |
= elements:(sexp+) {return {type: 'root', elements}} | |
sexp | |
= parenexp | |
/ delimited | |
/ id | |
parenexp | |
= type:$lparen elements:exp+ rparen {return {type, elements}} | |
/ type:$lbrace elements:exp+ rbrace {return {type, elements}} | |
/ type:$lbracket elements:exp+ rbracket {return {type, elements}} | |
/ type:$rangle elements:exp+ langle {return {type, elements}} | |
delimited | |
= type:$squote elements:(!squote e:exp {return e})+ squote {return {type, elements}} | |
/ type:$dquote elements:(!dquote e:exp {return e})+ dquote {return {type, elements}} | |
/ type:$bar elements:(!bar e:exp {return e})+ bar {return {type, elements}} | |
exp | |
= id | |
/ sexp | |
id | |
= c:(!reserved c:. {return c})+ _ {return c.join('')} | |
reserved = ws / lparen / rparen / lbrace / rbrace / lbracket / rbracket / rangle / langle / dquote / squote / bar | |
lparen = '(' _ | |
rparen = ')' _ | |
lbrace = '{' _ | |
rbrace = '}' _ | |
lbracket = '[' _ | |
rbracket = ']' _ | |
langle = '<' _ | |
rangle = '>' _ | |
dquote = '"' _ | |
squote = "'" _ | |
bar = '|' _ | |
_ = ws? | |
ws 'whitespace' = [\r\n\t ]+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment