equal
deleted
inserted
replaced
|
1 "{ Package: 'stx:goodies/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 trim , variable , $. asParser trim , expression ==> [ :node | Array with: node second with: node fourth ] |
|
47 ! |
|
48 |
|
49 application |
|
50 ^ $( asParser trim , expression , expression , $) asParser 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) flatten trim |
|
59 ! ! |
|
60 |
|
61 !PPLambdaParser class methodsFor:'documentation'! |
|
62 |
|
63 version |
|
64 ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLambdaParser.st,v 1.4 2014-03-04 14:34:00 cg Exp $' |
|
65 ! |
|
66 |
|
67 version_CVS |
|
68 ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLambdaParser.st,v 1.4 2014-03-04 14:34:00 cg Exp $' |
|
69 ! |
|
70 |
|
71 version_SVN |
|
72 ^ '$Id: PPLambdaParser.st,v 1.4 2014-03-04 14:34:00 cg Exp $' |
|
73 ! ! |
|
74 |