4
|
1 |
"{ Package: 'stx:goodies/petitparser' }"
|
0
|
2 |
|
|
3 |
PPCompositeParser subclass:#PPLambdaParser
|
|
4 |
instanceVariableNames:'expression abstraction application variable'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'PetitTests-Examples'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!PPLambdaParser class methodsFor:'curch-booleans'!
|
|
12 |
|
|
13 |
and
|
|
14 |
^ self parse: '\p.\q.((p q) p)'
|
|
15 |
!
|
|
16 |
|
|
17 |
false
|
|
18 |
^ self parse: '\x.\y.y'
|
|
19 |
!
|
|
20 |
|
|
21 |
ifthenelse
|
|
22 |
^ self parse: '\p.p'
|
|
23 |
!
|
|
24 |
|
|
25 |
not
|
|
26 |
^ self parse: '\p.\a.\b.((p b) a)'
|
|
27 |
!
|
|
28 |
|
|
29 |
or
|
|
30 |
^ self parse: '\p.\q.((p p) q)'
|
|
31 |
!
|
|
32 |
|
|
33 |
true
|
|
34 |
^ self parse: '\x.\y.x'
|
|
35 |
! !
|
|
36 |
|
|
37 |
!PPLambdaParser methodsFor:'accessing'!
|
|
38 |
|
|
39 |
start
|
|
40 |
^ expression end
|
|
41 |
! !
|
|
42 |
|
|
43 |
!PPLambdaParser methodsFor:'productions'!
|
|
44 |
|
|
45 |
abstraction
|
|
46 |
^ $\ asParser token trim , variable , $. asParser token trim , expression ==> [ :node | Array with: node second with: node fourth ]
|
|
47 |
!
|
|
48 |
|
|
49 |
application
|
|
50 |
^ $( asParser token trim , expression , expression , $) asParser token trim ==> [ :node | Array with: node second with: node third ]
|
|
51 |
!
|
|
52 |
|
|
53 |
expression
|
|
54 |
^ variable / abstraction / application
|
|
55 |
!
|
|
56 |
|
|
57 |
variable
|
|
58 |
^ (#letter asParser , #word asParser star) token trim ==> [ :token | token value ]
|
|
59 |
! !
|
|
60 |
|
|
61 |
!PPLambdaParser class methodsFor:'documentation'!
|
|
62 |
|
29
|
63 |
version
|
|
64 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLambdaParser.st,v 1.3 2012-05-04 22:03:02 vrany Exp $'
|
|
65 |
!
|
|
66 |
|
|
67 |
version_CVS
|
|
68 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLambdaParser.st,v 1.3 2012-05-04 22:03:02 vrany Exp $'
|
|
69 |
!
|
|
70 |
|
0
|
71 |
version_SVN
|
29
|
72 |
^ '§Id: PPLambdaParser.st 4 2010-12-18 17:02:23Z kursjan §'
|
0
|
73 |
! !
|