Skip to content

Commit

Permalink
Create calc.pegjs
Browse files Browse the repository at this point in the history
  • Loading branch information
luisespino committed May 14, 2024
1 parent 60ea473 commit e8f6c8e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions peggy/02_calc/calc.pegjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
s = e

e = left:t "+" right:e { return left + right; }
/ t

t = left:f "*" right:t { return left * right; }
/ f

f = _ num:[0-9]+ _ { return parseInt(num.join(""), 10); }

_ = [ \t\n\r]*

0 comments on commit e8f6c8e

Please sign in to comment.