Skip to content

Instantly share code, notes, and snippets.

@yhirose
Created May 8, 2022 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yhirose/0dab18e9a863cc5a16758913cb134439 to your computer and use it in GitHub Desktop.
Save yhirose/0dab18e9a863cc5a16758913cb134439 to your computer and use it in GitHub Desktop.
Learn LLVM 12 - Chapter 03 - calc PEG grammar
calc <- decl expr
decl <- ('with' ident (',' ident)* ':')?
expr <- term (term_op term)*
term <- factor (factor_op factor)*
factor <- ident / number / '(' expr ')'
term_op <- < [+-] >
factor_op <- < [*/] >
ident <- < [a-zA-Z]+ >
number <- < [0-9]+ >
%whitespace <- [ \t\n]*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment