Skip to content

Instantly share code, notes, and snippets.

@ssube
Created August 22, 2017 15:48
Show Gist options
  • Save ssube/8edcfcc359d00532f4196f6bbc5317e2 to your computer and use it in GitHub Desktop.
Save ssube/8edcfcc359d00532f4196f6bbc5317e2 to your computer and use it in GitHub Desktop.
bot grammar example
Request
= body:(next:Command WS ';' WS { return next; })* tail:Command { return body.concat(tail); }
Command
= verb:Verb WS noun:Noun WS params:Parameters { return {verb, noun, params}; }
Verb = $Word
Noun = $Word
Parameters
= '(' WS body:(next:$Word WS ',' WS { return next; })* tail:$Word WS ')' { return body.concat([tail]); }
Word
= [a-z]+
Integer "integer"
= [0-9]+ { return parseInt(text(), 10); }
WS "whitespace"
= [ \t\n\r]*
do some (foo, bar); do other (bis, nis)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment