Skip to content

Instantly share code, notes, and snippets.

@PollRobots
Last active December 12, 2015 01:18
Show Gist options
  • Select an option

  • Save PollRobots/4689701 to your computer and use it in GitHub Desktop.

Select an option

Save PollRobots/4689701 to your computer and use it in GitHub Desktop.
hexDigit <- [0123456789abcdefABCDEF]
escapedCharacter <- '\\' ([abfnrtv0\\"'[\]] / ('u' hexDigit hexDigit hexDigit hexDigit))
safeCharacter <- escapedCharacter / (!["\\\n] <anychar>)
oneofCharacter <- escapedCharacter / (![\\\]] <anychar>)
terminalUnicode <- '{' ( "Lu" / "Ll" / "Lt" / "Lm" / "Lo" / "Mn" / "Mc" / "Me" / "Nd" / "Nl" / "No" / "Pc" / "Pd" /
"Ps" / "Pe" / "Pi" / "Pf" / "Po" / "Sm" / "Sc" / "Sk" / "So" / "Zs" / "Zl" / "Zp" / "Cc" /
"Cf" / "Cs" / "Co" / "Cn" ) '}'
terminalOneOf <- '[' oneofCharacter+ ']'
terminalCharacter <- '\'' safeCharacter '\''
terminalWord <- '\"' safeCharacter+ '\"'
terminal <- terminalWord / terminalCharacter / terminalOneOf / terminalUnicode / "<anychar>" / "<epsilon>"
space <- [ \t\r\n]+
name <- ({Lu} / {Ll} / '-') ({Lu} / {Ll} / {Nd} / [_-])*
nonterminal <- name
atom <- terminal / nonterminal / ('(' space? expr space? ')')
unary <- ([!&] unary) / (atom [*+?])?
sequence <- unary (space unary)*
choice <- sequence (space? '/' space? sequence)*
expr <- choice
codechar <- (![{}\] <anychar>) / ('\\' [{}\\]) / ('{' codechar* '}')
codeblock <- '{' codechar* '}'
rule <- name space? "<-" space? expr space? codeblock? space? <epsilon>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment