Try this here: http://pegjs.org/online
Last active
November 17, 2021 11:25
-
-
Save wreulicke/7712af630d74b713c55a73898980b64e to your computer and use it in GitHub Desktop.
PEG.jsによる逆ポ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Statement | |
= a:Expression _ b:Statement _ operator:Operator {return operator(a,b)} | |
/ Expression | |
Expression | |
= a:Number _ b:Number _ operator:Operator {return operator(a,b)} | |
/ Number | |
Operator "operator" | |
= "*" {return function(a,b){return a*b}} | |
/ "+" {return function(a,b){return a+b}} | |
/ "-" {return function(a,b){return a-b}} | |
/ "/" {return function(a,b){return a/b}} | |
Number | |
= Double | |
/Integer | |
Double | |
= a:Integer "." b:Integer {return Number(text())}; | |
Integer | |
= [0-9]+ { return Number(text()); } | |
_ "whitespace" | |
= [ \t\n\r]* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment