-
Notifications
You must be signed in to change notification settings - Fork 27
/
gram.zil
187 lines (151 loc) · 4.92 KB
/
gram.zil
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
"GRAM file: imitates old parser and worth an ounce of cure.
Copyright (C) 1988 Infocom, Inc. All rights reserved."
<USE "LALR" "PSTACK" "REDS">
<IFFLAG (IN-ZILCH
<USE "ZILCH">)
(T <USE "ZIL">)>
<INCLUDE "SYMBOLS" "BASEDEFS" "LALRDEFS">
"TERMINALS are defined in DEFS, so they'll be around for compiling
stuff. This resets everything else, so we can regenerate the grammar."
<RESET-SYMBOLS ;"!-SYMBOLS!-PACKAGE">
<ADD-WORD END.OF.INPUT END-OF-INPUT>
<ADD-WORD "." END-OF-INPUT>
<ADD-WORD "?" END-OF-INPUT>
<ADD-WORD "!" END-OF-INPUT>
<ADD-WORD "THEN" END-OF-INPUT>
<ADD-WORD ONE NOUN>
<ADD-WORD BUT PREP>
<ADD-WORD NOT PREP>
<ADD-WORD EXCEPT PREP>
<COMPILATION-FLAG-DEFAULT P-PS-COMMA <>>
<ADD-WORD AND <IFFLAG (P-PS-COMMA COMMA) (T MISCWORD)>>
;<ADD-WORD OR <IFFLAG (P-PS-COMMA COMMA) (T MISCWORD)>>
<ADD-WORD "," <IFFLAG (P-PS-COMMA COMMA) (T MISCWORD)>>
<COMPILATION-FLAG-DEFAULT P-PS-APOSTR <>>
<ADD-WORD "'" <IFFLAG (P-PS-APOSTR APOSTR) (T MISCWORD)>>
<COMPILATION-FLAG-DEFAULT P-PS-OFWORD <>>
<ADD-WORD OF <IFFLAG (P-PS-OFWORD OFWORD) (T MISCWORD ;PREP)>>
<COMPILATION-FLAG-DEFAULT P-PS-THEWORD <>>
<ADD-WORD THE <IFFLAG (P-PS-THEWORD ARTICLE) (T MISCWORD)>>
<ADD-WORD FROM PREP>
<ADD-WORD IN PREP>
<ADD-WORD ON PREP>
<IF-P-PS-ADV
<ADD-WORD ONCE ADV>
<ADD-WORD TWICE ADV>
<ADD-WORD THRICE ADV>
<ADD-WORD "DON'T" ADV>>
<IFFLAG (P-PS-ADV <PRODUCTION RED-SP SP 1 (?PERS S ?ADV)>)
(T <PRODUCTION RED-SP SP 1 (?PERS S)>)>
<PRODUCTION RED-SV S 2 (VP ?PARTICLE)>
<PRODUCTION RED-SVN S 2 (VP ?PARTICLE NPP)>
<PRODUCTION RED-SVNP S 2 (VP NPP PARTICLE)>
<PRODUCTION RED-SVPNN S 2 (VP ?PARTICLE NPP NPP)>
<PRODUCTION RED-SVNPN S 2 (VP NPP ?PARTICLE NPP)>
<PRODUCTION RED-SVPNPN S 2 (VP ?PARTICLE NPP ?PARTICLE NPP)>
<PRODUCTION RED-SD S 2 (DIR)>
<PRODUCTION RED-SVD S 2 (VP DIR)>
<IFFLAG (P-BE-VERB
<IFFLAG (P-PS-ADV
<PRODUCTION RED-VP VP 3 (?CANDO ?ADV VERB ?ADV)>)
(T
<PRODUCTION RED-VP VP 3 (?CANDO VERB)>)>
<PRODUCTION RED-CANDO ?CANDO 3 ()
(NP)
(?QW1 CANDO NP ?NOT)
(?QW1 CANDO NOT NP)>)
(T
<IFFLAG (P-PS-ADV
<PRODUCTION RED-VP VP 3 (?ADV VERB ?ADV)>)
(T
<PRODUCTION RED-VP VP 3 (VERB)>)>)>
<IFFLAG (P-PS-OFWORD
<PRODUCTION RED-PART ?PARTICLE 1 ()
(PARTICLE OFWORD)
(PARTICLE ?PARTICLE)>)
(T
<PRODUCTION RED-PART ?PARTICLE 1 ()
(PARTICLE MISCWORD ;"OF")
(PARTICLE ?PARTICLE)>)>
<IF-P-PS-ADV <PRODUCTION RED-FCN ?ADV 1 () (ADV)>>
<IFFLAG (P-PS-COMMA
<PRODUCTION RED-NPP NPP 4 (NP)
(NPP PP)
(NPP COMMA NP)>)
(T
<PRODUCTION RED-NPP NPP 4 (NP)
(NPP PP)
(NPP MISCWORD NP)>)>
<PRODUCTION RED-NP NP 6 (;?DET ADJ* NOUN)>
<IFFLAG (P-PS-OFWORD <PRODUCTION RED-OF NP 5 (NP OFWORD NP)>)
(T <PRODUCTION RED-OF NP 5 (NP MISCWORD NP)>)>
<PRODUCTION RED-QT NP 7 (QUANT)>
<PRODUCTION RED-QN NP 5 (QUANT NP)>
<COMPILATION-FLAG-DEFAULT P-PS-QUOTE <>>
<ADD-WORD \" <IFFLAG (P-PS-QUOTE QUOTE) (T MISCWORD)>>
<IFFLAG (P-PS-QUOTE
<PRODUCTION RED-QUOTE NP 7 (QUOTE)>)
(T
<PRODUCTION RED-QUOTE NP 7 (MISCWORD)>)>
<IFFLAG (P-PS-OFWORD
<PRODUCTION RED-PP PP 3 (PREP NPP)
(PARTICLE NPP)
(PREP OFWORD NPP)
(PARTICLE OFWORD NPP)>)
(T
<PRODUCTION RED-PP PP 3 (PREP NPP)
(PARTICLE NPP)
(PREP MISCWORD;"OF" NPP)
(PARTICLE MISCWORD;"OF" NPP)>)>
<IFFLAG (P-PS-THEWORD
<PRODUCTION RED-ADJ ADJ* 8 ()
(ADJ ADJ*) ;"switched by SWG"
(ARTICLE ADJ*)
(POSSESSIVE ADJ*)>)
(T
<PRODUCTION RED-ADJ ADJ* 8 ()
(ADJ ADJ*) ;"switched by SWG"
(MISCWORD ADJ*) ;"article"
(POSSESSIVE ADJ*)>)>
<IFFLAG (P-PS-APOSTR
<PRODUCTION RED-POSS POSSESSIVE 8 (NP APOSTR MISCWORD) ;"FOO'S"
;(ADJ) ;"HER HIS etc.">)
(T
<PRODUCTION RED-POSS POSSESSIVE 8 (NP MISCWORD MISCWORD) ;"FOO'S"
;(ADJ) ;"HER HIS etc.">)>
<IF-P-BE-VERB
<PRODUCTION RED-BE-FORM BE-FORM 3 (TOBE)>
<PRODUCTION RED-SNBN S 2 (NP BE-FORM ?NOT ?BE NPP)>
<PRODUCTION RED-SNBA S 2 (NP BE-FORM ?NOT ?BE ADJ)>
<PRODUCTION RED-SNBP S 2 (NP BE-FORM ?NOT ?BE PP)>
<PRODUCTION RED-FCN ?QW1 3 () (QWORD)>
<PRODUCTION RED-SQBN S 2 (QWORD BE-FORM NP)>
;<PRODUCTION RED-SQBA S 2 (QWORD BE-FORM ADJ)>
;<PRODUCTION RED-SQBP S 2 (QWORD BE-FORM PP)>
<PRODUCTION RED-SBNN S 2 (?QW1 BE-FORM NP ?NOT ?BE NPP)
(?QW1 BE-FORM NOT NP ?BE NPP)>
<PRODUCTION RED-SBNA S 2 (?QW1 BE-FORM NP ?NOT ?BE ADJ)
(?QW1 BE-FORM NOT NP ?BE ADJ)>
<PRODUCTION RED-SBNP S 2 (?QW1 BE-FORM NP ?NOT ?BE PP)
(?QW1 BE-FORM NOT NP ?BE PP)>
<ADD-WORD BE MISCWORD>
<PRODUCTION RED-BE ?BE 3 () (MISCWORD ;"BE")>
<ADD-WORD NOT MISCWORD>
<PRODUCTION RED-NOT ?NOT 3 () (MISCWORD ;"NOT")>
<PRODUCTION RED-NOT NOT 3 (MISCWORD ;"NOT")>
>
<IFFLAG (P-PS-COMMA
<PRODUCTION RED-PERS ?PERS 2 ()
(NPP COMMA)
(ASKWORD NPP PARTICLE ;"TO")>)
(T
<PRODUCTION RED-PERS ?PERS 2 ()
(NPP MISCWORD)
(ASKWORD NPP PARTICLE ;"TO")>)>
<PRODUCTION RED-O-NP S 1 (NP) ;"was NPP"
(NP PP)>
<PRODUCTION RED-O-ADJ S 1 (;ADJ ADJ*)>
<PRODUCTION RED-O-PP S 1 (PP)
(PARTICLE NP)>
<STARTING-SYMBOL SP>
<MAKE-TABLES <LALR>>