Remove Pharoisms to make code more portable and running on Smalltalk/X
* Use ANSI `(Character codePoint: 13)` (`10`) instead of `Character cr` (`lf`), This is more portable
and does not depend on dialects interpretation of `#cr` - Smalltalk/X convert it according to
platform line end convention (UNIX/Windows/Mac)
* Do not assume exact value of a printstring in tests, i.e., instead of
`msg includesSubstring: '$a'
code
`msg includesSubstring: $a printString.
This way, the test is independent on the printString value, which may differ among dialects.
Q: Is printString value of String and/or Character defined in ANSI?
* In assestions, instead of `#equals:` use plain old `#=`, which is more portable.
* Removed Character>>- used to create range parser. Use portable `(Interval from: $a to: $z) asParser`
instead of just `$a - $z`. Do not use ($a to: $z) asParser as in Pharo, Character>>to:
does not create an Interval but an Array (sigh).
"{ Package: 'stx:goodies/petitparser/tests' }"
PPCompositeParser subclass:#PPLambdaParser
instanceVariableNames:'expression abstraction application variable'
classVariableNames:''
poolDictionaries:''
category:'PetitTests-Examples'
!
!PPLambdaParser class methodsFor:'curch-booleans'!
and
^ self parse: '\p.\q.((p q) p)'
!
false
^ self parse: '\x.\y.y'
!
ifthenelse
^ self parse: '\p.p'
!
not
^ self parse: '\p.\a.\b.((p b) a)'
!
or
^ self parse: '\p.\q.((p p) q)'
!
true
^ self parse: '\x.\y.x'
! !
!PPLambdaParser methodsFor:'accessing'!
start
^ expression end
! !
!PPLambdaParser methodsFor:'productions'!
abstraction
^ $\ asParser trim , variable , $. asParser trim , expression ==> [ :node | Array with: node second with: node fourth ]
!
application
^ $( asParser trim , expression , expression , $) asParser trim ==> [ :node | Array with: node second with: node third ]
!
expression
^ variable / abstraction / application
!
variable
^ (#letter asParser , #word asParser star) flatten trim
! !
!PPLambdaParser class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLambdaParser.st,v 1.4 2014-03-04 14:34:00 cg Exp $'
!
version_CVS
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLambdaParser.st,v 1.4 2014-03-04 14:34:00 cg Exp $'
!
version_HG
^ '$Changeset: <not expanded> $'
!
version_SVN
^ '$Id: PPLambdaParser.st,v 1.4 2014-03-04 14:34:00 cg Exp $'
! !