PPLambdaParser.st
author Claus Gittinger <cg@exept.de>
Tue, 04 Mar 2014 15:33:00 +0100
changeset 170 38bf7423a5d4
parent 29 2235aaee7da6
child 184 dff934a0213f
permissions -rw-r--r--
update

"{ Package: 'stx:goodies/petitparser' }"

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 token trim , variable , $. asParser token trim , expression ==> [ :node | Array with: node second with: node fourth ]
!

application
	^ $( asParser token trim , expression , expression , $) asParser token trim ==> [ :node | Array with: node second with: node third ]
!

expression
	^ variable / abstraction / application
!

variable
	^ (#letter asParser , #word asParser star) token trim ==> [ :token | token value ]
! !

!PPLambdaParser class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLambdaParser.st,v 1.3 2012-05-04 22:03:02 vrany Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLambdaParser.st,v 1.3 2012-05-04 22:03:02 vrany Exp $'
!

version_SVN
    ^ '§Id: PPLambdaParser.st 4 2010-12-18 17:02:23Z kursjan §'
! !