2 * Copyright (C) 2022 Nick Downing <nick@ndcode.org>
3 * SPDX-License-Identifier: GPL-2.0-only
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; version 2.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
38 %token TOKEN_INPUT 132
44 %token TOKEN_PR_HASH 138
45 %token TOKEN_IN_HASH 139
52 %token TOKEN_HCOLOR_EQUAL 146
53 %token TOKEN_HPLOT 147
55 %token TOKEN_XDRAW 149
58 %token TOKEN_ROT_EQUAL 152
59 %token TOKEN_SCALE_EQUAL 153
60 %token TOKEN_SHLOAD 154
61 %token TOKEN_TRACE 155
62 %token TOKEN_NOTRACE 156
63 %token TOKEN_NORMAL 157
64 %token TOKEN_INVERSE 158
65 %token TOKEN_FLASH 159
66 %token TOKEN_COLOR_EQUAL 160
69 %token TOKEN_HIMEM_COLON 163
70 %token TOKEN_LOMEM_COLON 164
71 %token TOKEN_ONERR 165
72 %token TOKEN_RESUME 166
73 %token TOKEN_RECALL 167
74 %token TOKEN_STORE 168
75 %token TOKEN_SPEED_EQUAL 169
80 %token TOKEN_RESTORE 174
81 %token TOKEN_AMPERSAND 175
82 %token TOKEN_GOSUB 176
83 %token TOKEN_RETURN 177
92 %token TOKEN_PRINT 186
95 %token TOKEN_CLEAR 189
98 %token TOKEN_TAB_LPAREN 192
101 %token TOKEN_SPC_LPAREN 195
102 %token TOKEN_THEN 196
105 %token TOKEN_STEP 199
106 %token TOKEN_PLUS 200
107 %token TOKEN_MINUS 201
108 %token TOKEN_ASTERISK 202
109 %token TOKEN_SLASH 203
110 %token TOKEN_CARET 204
113 %token TOKEN_GREATER_THAN 207
114 %token TOKEN_EQUAL 208
115 %token TOKEN_LESS_THAN 209
121 %token TOKEN_SCRN_LPAREN 215
132 %token TOKEN_PEEK 226
134 %token TOKEN_STR_DOLLAR 228
137 %token TOKEN_CHR_DOLLAR 231
138 %token TOKEN_LEFT_DOLLAR 232
139 %token TOKEN_RIGHT_DOLLAR 233
140 %token TOKEN_MID_DOLLAR 234
145 %left TOKEN_LESS_THAN TOKEN_EQUAL TOKEN_GREATER_THAN OPERATOR_GE OPERATOR_LE OPERATOR_NE
146 %left TOKEN_PLUS TOKEN_MINUS
147 %left TOKEN_ASTERISK TOKEN_SLASH
149 %right UNARY TOKEN_NOT
155 | program %space (?E{t_def.Line}INT_LITERAL statement_list) '\n'
157 yyerror('Syntax error\n')
164 | statement_list ':' statement_opt
169 | %space (?E{t_def.StatementEnd}TOKEN_END)
170 | %space (?E{t_def.StatementFor}TOKEN_FOR VARIABLE_NAME TOKEN_EQUAL rvalue TOKEN_TO rvalue)
171 | %space (?E{t_def.StatementFor}TOKEN_FOR VARIABLE_NAME TOKEN_EQUAL rvalue TOKEN_TO rvalue TOKEN_STEP rvalue)
172 | %space (?E{t_def.StatementNext}TOKEN_NEXT)
173 | %space (?E{t_def.StatementNext}TOKEN_NEXT VARIABLE_NAME)
174 | %space (?E{t_def.StatementData}TOKEN_DATA data_item_list)
175 | %space (?E{t_def.StatementInput}TOKEN_INPUT lvalue)
176 | %space (?E{t_def.StatementInput}TOKEN_INPUT STR_LITERAL ';' lvalue)
177 | %space (?E{t_def.StatementDel}TOKEN_DEL)
178 | %space (?E{t_def.StatementDim}TOKEN_DIM dim_item_list)
179 | %space (?E{t_def.StatementRead}TOKEN_READ lvalue_list)
180 | %space (?E{t_def.StatementGr}TOKEN_GR)
181 | %space (?E{t_def.StatementText}TOKEN_TEXT)
182 | %space (?E{t_def.StatementPrHash}TOKEN_PR_HASH rvalue)
183 | %space (?E{t_def.StatementInHash}TOKEN_IN_HASH rvalue)
184 | %space (?E{t_def.StatementCall}TOKEN_CALL rvalue)
185 | %space (?E{t_def.StatementPlot}TOKEN_PLOT rvalue ',' rvalue)
186 | %space (?E{t_def.StatementHLin}TOKEN_HLIN rvalue ',' rvalue TOKEN_AT rvalue)
187 | %space (?E{t_def.StatementVLin}TOKEN_VLIN rvalue ',' rvalue TOKEN_AT rvalue)
188 | %space (?E{t_def.StatementHGR2}TOKEN_HGR2)
189 | %space (?E{t_def.StatementHGR}TOKEN_HGR)
190 | %space (?E{t_def.StatementHColorEqual}TOKEN_HCOLOR_EQUAL rvalue)
191 | %space (?E{t_def.StatementHPlot}TOKEN_HPLOT)
192 | %space (?E{t_def.StatementDraw}TOKEN_DRAW)
193 | %space (?E{t_def.StatementXDraw}TOKEN_XDRAW)
194 | %space (?E{t_def.StatementHTab}TOKEN_HTAB rvalue)
195 | %space (?E{t_def.StatementHome}TOKEN_HOME)
196 | %space (?E{t_def.StatementRotEqual}TOKEN_ROT_EQUAL rvalue)
197 | %space (?E{t_def.StatementScaleEqual}TOKEN_SCALE_EQUAL rvalue)
198 | %space (?E{t_def.StatementShLoad}TOKEN_SHLOAD)
199 | %space (?E{t_def.StatementTrace}TOKEN_TRACE)
200 | %space (?E{t_def.StatementNoTrace}TOKEN_NOTRACE)
201 | %space (?E{t_def.StatementNormal}TOKEN_NORMAL)
202 | %space (?E{t_def.StatementInverse}TOKEN_INVERSE)
203 | %space (?E{t_def.StatementFlash}TOKEN_FLASH)
204 | %space (?E{t_def.StatementColorEqual}TOKEN_COLOR_EQUAL rvalue)
205 | %space (?E{t_def.StatementPop}TOKEN_POP)
206 | %space (?E{t_def.StatementVTab}TOKEN_VTAB rvalue)
207 | %space (?E{t_def.StatementHimemColon}TOKEN_HIMEM_COLON rvalue)
208 | %space (?E{t_def.StatementLomemColon}TOKEN_LOMEM_COLON rvalue)
209 | %space (?E{t_def.StatementOnErr}TOKEN_ONERR TOKEN_GOTO INT_LITERAL)
210 | %space (?E{t_def.StatementResume}TOKEN_RESUME)
211 | %space (?E{t_def.StatementRecall}TOKEN_RECALL)
212 | %space (?E{t_def.StatementStore}TOKEN_STORE)
213 | %space (?E{t_def.StatementSpeedEqual}TOKEN_SPEED_EQUAL rvalue)
214 | %space (?E{t_def.StatementLet}lvalue TOKEN_EQUAL rvalue)
215 | %space (?E{t_def.StatementLet}TOKEN_LET lvalue TOKEN_EQUAL rvalue)
216 | %space (?E{t_def.StatementGoto}TOKEN_GOTO INT_LITERAL)
217 | %space (?E{t_def.StatementRun}TOKEN_RUN)
218 | %space (?E{t_def.StatementIf}TOKEN_IF rvalue TOKEN_THEN) statement_opt
219 | %space (?E{t_def.StatementIf}TOKEN_IF rvalue TOKEN_THEN) %space (?E{t_def.StatementGoto}INT_LITERAL)
220 | %space (?E{t_def.StatementRestore}TOKEN_RESTORE)
221 | %space (?E{t_def.StatementAmpersand}TOKEN_AMPERSAND)
222 | %space (?E{t_def.StatementGosub}TOKEN_GOSUB INT_LITERAL)
223 | %space (?E{t_def.StatementReturn}TOKEN_RETURN)
224 | %space (?E{t_def.StatementRem}TOKEN_REM REM_TEXT)
225 | %space (?E{t_def.StatementStop}TOKEN_STOP)
226 | %space (?E{t_def.StatementOnGoto}TOKEN_ON rvalue TOKEN_GOTO int_literal_list_opt)
227 | %space (?E{t_def.StatementOnGosub}TOKEN_ON rvalue TOKEN_GOSUB int_literal_list_opt)
228 | %space (?E{t_def.StatementWait}TOKEN_WAIT)
229 | %space (?E{t_def.StatementLoad}TOKEN_LOAD)
230 | %space (?E{t_def.StatementSave}TOKEN_SAVE)
231 | %space (?E{t_def.StatementDef}TOKEN_DEF)
232 | %space (?E{t_def.StatementPoke}TOKEN_POKE rvalue ',' rvalue)
233 | %space (?E{t_def.StatementPrint, semicolon = False}TOKEN_PRINT print_item_list0)
234 | %space (?E{t_def.StatementPrint, semicolon = True}TOKEN_PRINT print_item_list1)
235 | %space (?E{t_def.StatementCont}TOKEN_CONT)
236 | %space (?E{t_def.StatementList}TOKEN_LIST)
237 | %space (?E{t_def.StatementClear}TOKEN_CLEAR)
238 | %space (?E{t_def.StatementGet}TOKEN_GET lvalue)
239 | %space (?E{t_def.StatementNew}TOKEN_NEW)
244 | print_item_list0 print_item
245 | print_item_list1 print_item
249 : print_item_list0 ';'
250 | print_item_list1 ';'
255 | %space (?E{t_def.RValueTabLParen}TOKEN_TAB_LPAREN rvalue ')')
260 | lvalue_list ',' lvalue
270 | int_literal_list ',' INT_LITERAL
275 | data_item_list ',' data_item
279 : (?E{t_def.DataText} %empty)
286 | dim_item_list ',' dim_item
290 : %space (?E{t_def.DimItem}VARIABLE_NAME '(' rvalue_list ')')
295 | rvalue_list ',' rvalue
301 | %space (?E{t_def.RValueStrLiteral}STR_LITERAL)
302 | %space (?E{t_def.RValueFloatLiteral}FLOAT_LITERAL)
303 | %space (?E{t_def.RValueIntLiteral}INT_LITERAL)
304 | %space (?E{t_def.RValueSpcLParen}TOKEN_SPC_LPAREN rvalue ')')
305 | %space (?E{t_def.RValueNot}TOKEN_NOT rvalue)
306 | %space (?E{t_def.RValueSign, sign = 1}TOKEN_PLUS rvalue) %prec UNARY
307 | %space (?E{t_def.RValueSign, sign = -1}TOKEN_MINUS rvalue) %prec UNARY
308 | %space (?E{t_def.RValueAdd}rvalue TOKEN_PLUS rvalue)
309 | %space (?E{t_def.RValueSubtract}rvalue TOKEN_MINUS rvalue)
310 | %space (?E{t_def.RValueMultiply}rvalue TOKEN_ASTERISK rvalue)
311 | %space (?E{t_def.RValueDivide}rvalue TOKEN_SLASH rvalue)
312 | %space (?E{t_def.RValuePower}rvalue TOKEN_CARET rvalue)
313 | %space (?E{t_def.RValueAnd}rvalue TOKEN_AND rvalue)
314 | %space (?E{t_def.RValueOr}rvalue TOKEN_OR rvalue)
315 | %space (?E{t_def.RValueGT}rvalue TOKEN_GREATER_THAN rvalue)
316 | %space (?E{t_def.RValueEqual}rvalue TOKEN_EQUAL rvalue)
317 | %space (?E{t_def.RValueLT}rvalue TOKEN_LESS_THAN rvalue)
318 | %space (?E{t_def.RValueGE}rvalue OPERATOR_GE rvalue)
319 | %space (?E{t_def.RValueLE}rvalue OPERATOR_LE rvalue)
320 | %space (?E{t_def.RValueNE}rvalue OPERATOR_NE rvalue)
321 | %space (?E{t_def.RValueSgn}TOKEN_SGN '(' rvalue ')')
322 | %space (?E{t_def.RValueInt}TOKEN_INT '(' rvalue ')')
323 | %space (?E{t_def.RValueAbs}TOKEN_ABS '(' rvalue ')')
324 | %space (?E{t_def.RValueUsr}TOKEN_USR '(' rvalue ')' ',' STR_LITERAL)
325 | %space (?E{t_def.RValueFre}TOKEN_FRE '(' rvalue ')')
326 | %space (?E{t_def.RValueScrnLParen}TOKEN_SCRN_LPAREN rvalue ',' rvalue ')')
327 | %space (?E{t_def.RValuePdl}TOKEN_PDL '(' rvalue ')')
328 | %space (?E{t_def.RValuePos}TOKEN_POS '(' rvalue ')')
329 | %space (?E{t_def.RValueSqr}TOKEN_SQR '(' rvalue ')')
330 | %space (?E{t_def.RValueRnd}TOKEN_RND '(' rvalue ')')
331 | %space (?E{t_def.RValueLog}TOKEN_LOG '(' rvalue ')')
332 | %space (?E{t_def.RValueExp}TOKEN_EXP '(' rvalue ')')
333 | %space (?E{t_def.RValueCos}TOKEN_COS '(' rvalue ')')
334 | %space (?E{t_def.RValueSin}TOKEN_SIN '(' rvalue ')')
335 | %space (?E{t_def.RValueTan}TOKEN_TAN '(' rvalue ')')
336 | %space (?E{t_def.RValueAtn}TOKEN_ATN '(' rvalue ')')
337 | %space (?E{t_def.RValuePeek}TOKEN_PEEK '(' rvalue ')')
338 | %space (?E{t_def.RValueLen}TOKEN_LEN '(' rvalue ')')
339 | %space (?E{t_def.RValueStrDollar}TOKEN_STR_DOLLAR '(' rvalue ')')
340 | %space (?E{t_def.RValueVal}TOKEN_VAL '(' rvalue ')')
341 | %space (?E{t_def.RValueAsc}TOKEN_ASC '(' rvalue ')')
342 | %space (?E{t_def.RValueChrDollar}TOKEN_CHR_DOLLAR '(' rvalue ')')
343 | %space (?E{t_def.RValueLeftDollar}TOKEN_LEFT_DOLLAR '(' rvalue ',' rvalue ')')
344 | %space (?E{t_def.RValueRightDollar}TOKEN_RIGHT_DOLLAR '(' rvalue ',' rvalue ')')
345 | %space (?E{t_def.RValueMidDollar}TOKEN_MID_DOLLAR '(' rvalue ',' rvalue ')')
346 | %space (?E{t_def.RValueMidDollar}TOKEN_MID_DOLLAR '(' rvalue ',' rvalue ',' rvalue ')')
350 : %space (?E{t_def.LValueVariable}VARIABLE_NAME)
351 | %space (?E{t_def.LValueArray}VARIABLE_NAME '(' rvalue_list ')')
356 sys.stdout.write('{0:s}\n'.format(s))