Skip to content

Instantly share code, notes, and snippets.

@westphallm1
Created May 17, 2019 00:19
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 westphallm1/1ab52b963f34ef6a62438c3bc74e597a to your computer and use it in GitHub Desktop.
Save westphallm1/1ab52b963f34ef6a62438c3bc74e597a to your computer and use it in GitHub Desktop.
Pest grammar for process calculus
var = {('a'..'z') ~ ('a'..'z'|'A' .. 'Z'| '0' .. '9')*}
num = {"-"? ~ ('0'..'9')+}
opr = {"+"|"*"|"-"|"/"}
chan = {('A'..'Z') ~ ('a'..'z'|'A' .. 'Z'| '0' .. '9')*}
expr = {term ~ opr ~ expr | term}
term = {var | num | "("~ expr ~")"}
bexpr = {"true" | "false" | expr ~ "<" ~ expr}
def_list = { def ~ "\n" ~ def_list | def }
def = { chan ~ "=" ~ proc_list | proc_list}
proc_list = {procs ~ "|" ~proc_list | procs}
procs = {proc_ ~ ";" ~ procs | proc_ ~";"?}
proc_ = {"done" | var ~ "<-" ~ chan | expr ~ "->" ~ chan | "[" ~ bexpr ~ "]" |
chan}
WHITESPACE = _{" "}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment