Created
August 30, 2012 18:29
-
-
Save SineSwiper/3536754 to your computer and use it in GitHub Desktop.
Weird comment bugs
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
# "Atoms" | |
E_CODE : /( | |
<C_LCURLY> | |
(: | |
[^ <C_LCURLY><C_RCURLY> ]+ | # Most stuff | |
(?1) # Nesting braces | |
)* | |
<C_RCURLY> | |
)/ | |
E_PERCODE : / <PERCENT><E_CODE> ~ / # bit of a hack, as it swallows the % from %}\n | |
E_BEGINCODE: / <PERCENT> begin ~ <E_CODE> ~ / | |
E_IDENT : / (: <ALPHA> | <UNDER> ) <WORD>* ~ / | |
E_LABEL : / <COLON> <WORD>+ ~ / | |
E_LITERAL : / <SINGLE> [^ <SINGLE> ]+ <SINGLE> ~ / | |
E_NAME : / <PERCENT> name ~ / | |
E_nameident: / ( <E_NAME> ~ (<E_IDENT>) ~ )? / | |
E_OPTION : / <E_nameident> <QMARK> ~ / | |
E_PLUS : / <E_nameident> <PLUS> ~ / | |
E_PREC : / <PERCENT> prec ~ / | |
E_PLUS : / <E_nameident> <STAR> ~ / | |
# Main rule | |
eyapp: head body tail | |
# Common rules: | |
symbol: E_LITERAL | ident | |
ident: E_IDENT | |
# Head section: | |
head: decl* / ~ <PERCENT><PERCENT> ~ / | |
decl: / [ ^<DOS> ]* <EOL> / | E_PERCODE ~ | |
# Rule section | |
body: rules* / ~ <PERCENT><PERCENT> ~ / | |
rules: / (<E_IDENT>) ~ <COLON> ~ / rhss ~ <SEMI> ~ | |
rhss: ( <rule>2+ % / ~ <PIPE> ~ / ) | rule | |
rule: optname? rhselt* ( prec code? )? | |
rhselt: | |
symbol | |
| code | |
| E_PREC ident | |
| <LPAREN> optname? rhseltwithid* <RPAREN> | |
# (not used in Pg.eyp) | |
| rhselt ( | |
E_STAR | |
| E_OPTION | |
| E_PLUS | |
| <LANGLE> ( E_STAR | E_PLUS ) symbol <LANGLE> | |
) | |
; | |
optname: E_NAME ( E_IDENT E_LABEL? | E_LABEL ) # (not used in Pg.eyp) | |
prec: E_PREC ~ symbol | |
code: E_CODE | E_BEGINCODE | |
# Tail section: | |
tail: / ( <ALL>+ ) / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment