equal
deleted
inserted
replaced
|
1 "{ Package: 'squeak:petitparser' }" |
|
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 |
|
63 version_SVN |
|
64 ^ '$Id: PPLambdaParser.st,v 1.1 2011-08-18 18:56:17 cg Exp $' |
|
65 ! ! |