Tidy up expr groups

db4
Chris Double 2008-03-20 17:19:41 +13:00
parent 8ade4f9b5b
commit dbd0583044
1 changed files with 6 additions and 6 deletions

View File

@ -10,13 +10,13 @@ IN: peg.expr
swap [ first2 swap call ] reduce ;
EBNF: expr
times = ("*") [[ drop [ * ] ]]
divide = ("/") [[ drop [ / ] ]]
add = ("+") [[ drop [ + ] ]]
subtract = ("-") [[ drop [ - ] ]]
times = "*" [[ drop [ * ] ]]
divide = "/" [[ drop [ / ] ]]
add = "+" [[ drop [ + ] ]]
subtract = "-" [[ drop [ - ] ]]
digit = ([0-9]) [[ digit> ]]
number = ((digit)+) [[ unclip [ swap 10 * + ] reduce ]]
digit = [0-9] [[ digit> ]]
number = (digit)+ [[ unclip [ swap 10 * + ] reduce ]]
value = number | ("(" expr ")") [[ second ]]
product = (value ((times | divide) value)*) [[ first2 operator-fold ]]