Skip to content

Instantly share code, notes, and snippets.

@chunibyo-wly
Last active May 28, 2022 12:44
Show Gist options
  • Save chunibyo-wly/06e0f109b93da7457c8a69478d81c472 to your computer and use it in GitHub Desktop.
Save chunibyo-wly/06e0f109b93da7457c8a69478d81c472 to your computer and use it in GitHub Desktop.
peggy
start
= operation
operation
= WSS a:entity WSS b:operator WSS c:operation WSS { return `${a} ${b} ${c}`; }
/ WSS a:entity WSS b:operator2 WSS c:operation WSS { return `${a}${b}${c}`; }
/ WSS a:entity WSS c:operation WSS { return `${a}${c}`; }
/ WSS a:entity WSS { return a; }
entity "entity"
= e:ident_part+ { return e.join(''); }
/ "{" WSS e:operation WSS "}" { return `{${e}}`; }
/ "(" WSS e:operation WSS ")" { return `(${e})`; }
/ b:built_in_operator e:ident_part+ { return `\\${e.join('')}`; }
built_in_operator "built_in_operator"
= "\\"
ident_part
= [A-Za-z0-9]
operator "operator"
= [\+\-\*\/=]
operator2 "operator2"
= [_^]
WSS "whitespaces"
= [ \t\r\n]*
@chunibyo-wly
Copy link
Author

chunibyo-wly commented May 28, 2022

1+ \Omega_1^2      
 + a_a_1  + \frac{1+1}{i-1} /

             (a    +1      /3       )
/(4+5)*
9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment