--- a/PPArithmeticParser.st Tue Mar 04 15:33:36 2014 +0100
+++ b/PPArithmeticParser.st Tue Mar 04 15:33:59 2014 +0100
@@ -18,8 +18,8 @@
!PPArithmeticParser methodsFor:'grammar'!
addition
- ^ (factors separatedBy: ($+ asParser / $- asParser) token trim)
- foldLeft: [ :a :op :b | a perform: op value asSymbol with: b ]
+ ^ (factors separatedBy: ($+ asParser / $- asParser) trim)
+ foldLeft: [ :a :op :b | a perform: op asSymbol with: b ]
!
factors
@@ -27,20 +27,23 @@
!
multiplication
- ^ (power separatedBy: ($* asParser / $/ asParser) token trim)
- foldLeft: [ :a :op :b | a perform: op value asSymbol with: b ]
+ ^ (power separatedBy: ($* asParser / $/ asParser) trim)
+ foldLeft: [ :a :op :b | a perform: op asSymbol with: b ]
!
number
- ^ ($- asParser optional , #digit asParser plus , ($. asParser , #digit asParser plus) optional) token trim ==> [ :token | token value asNumber ]
+ ^ ($- asParser optional , #digit asParser plus , ($. asParser , #digit asParser plus) optional) flatten trim
+ ==> [ :value | value asNumber ]
!
parentheses
- ^ $( asParser flatten trim , terms , $) asParser flatten trim ==> #second
+ ^ $( asParser trim , terms , $) asParser trim
+ ==> [ :nodes | nodes second ]
!
power
- ^ (primary separatedBy: $^ asParser token trim) foldRight: [ :a :op :b | a raisedTo: b ]
+ ^ (primary separatedBy: $^ asParser trim)
+ foldRight: [ :a :op :b | a raisedTo: b ]
!
primary
@@ -54,13 +57,14 @@
!PPArithmeticParser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPArithmeticParser.st,v 1.3 2012-05-04 22:03:26 vrany Exp $'
+ ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPArithmeticParser.st,v 1.4 2014-03-04 14:33:59 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPArithmeticParser.st,v 1.3 2012-05-04 22:03:26 vrany Exp $'
+ ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPArithmeticParser.st,v 1.4 2014-03-04 14:33:59 cg Exp $'
!
version_SVN
- ^ '§Id: PPArithmeticParser.st 4 2010-12-18 17:02:23Z kursjan §'
+ ^ '$Id: PPArithmeticParser.st,v 1.4 2014-03-04 14:33:59 cg Exp $'
! !
+