PPLambdaParser.st
author Claus Gittinger <cg@exept.de>
Mon, 12 Sep 2011 19:47:59 +0200
changeset 2 acb3822c73db
parent 0 739fe9b7253e
child 4 90de244a7fa2
permissions -rw-r--r--
initial checkin

"{ Package: 'squeak: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_SVN
    ^ '$Id: PPLambdaParser.st,v 1.1 2011-08-18 18:56:17 cg Exp $'
! !