author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 03 Oct 2014 01:59:10 +0100 | |
changeset 376 | a2656b27cace |
parent 375 | e2b2f08d054e |
child 380 | 8fe3cb4e607f |
permissions | -rw-r--r-- |
376
a2656b27cace
Added monticelloName to package definition to ease export to .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
375
diff
changeset
|
1 |
"{ Package: 'stx:goodies/petitparser/tests' }" |
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 |
|
184 | 46 |
^ $\ asParser trim , variable , $. asParser trim , expression ==> [ :node | Array with: node second with: node fourth ] |
0 | 47 |
! |
48 |
||
49 |
application |
|
184 | 50 |
^ $( asParser trim , expression , expression , $) asParser trim ==> [ :node | Array with: node second with: node third ] |
0 | 51 |
! |
52 |
||
53 |
expression |
|
54 |
^ variable / abstraction / application |
|
55 |
! |
|
56 |
||
57 |
variable |
|
184 | 58 |
^ (#letter asParser , #word asParser star) flatten trim |
0 | 59 |
! ! |
60 |
||
61 |
!PPLambdaParser class methodsFor:'documentation'! |
|
62 |
||
29 | 63 |
version |
184 | 64 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLambdaParser.st,v 1.4 2014-03-04 14:34:00 cg Exp $' |
29 | 65 |
! |
66 |
||
67 |
version_CVS |
|
184 | 68 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLambdaParser.st,v 1.4 2014-03-04 14:34:00 cg Exp $' |
29 | 69 |
! |
70 |
||
0 | 71 |
version_SVN |
184 | 72 |
^ '$Id: PPLambdaParser.st,v 1.4 2014-03-04 14:34:00 cg Exp $' |
0 | 73 |
! ! |
184 | 74 |