1// This file is part of SmallBASIC
2//
3// SB Keywords in English - Latin1
4//
5// Rules:
6// * Names can be 15 chars long. (defined on scan.h)
7// * Names must defined always with capitals. lower-case means invisible keywords.
8// * Spaces are not allowed. Only letters, digits and the character '_'.
9// * Alias supported just repeat the keyword.
10// Example:
11// { "GOTO", kwGOTO },
12// { "GOTHERE", kwGOTO },
13// This means the command GOTO it is known to the compiler with the
14// names "GOTO" and "GOTHERE".
15//
16// This program is distributed under the terms of the GPL v2.0 or later
17// Download the GNU Public License (GPL) from www.gnu.org
18//
19// Copyright(C) 2000 Nicholas Christopoulos
20
21/*
22 * GENERIC KEYWORDS (basic bc-types & oldest code)
23 *
24 * This table is limited to 256 elements
25 */
26struct keyword_s keyword_table[] = {
27/* real commands */
28{ "LOCAL", kwLOCAL },
29{ "SUB", kwPROC },
30{ "FUNC", kwFUNC },
31{ "DEF", kwFUNC },
32{ "BYREF", kwBYREF },
33{ "DECLARE", kwDECLARE },
34{ "IMPORT", kwIMPORT },
35{ "EXPORT", kwEXPORT },
36{ "UNIT", kwUNIT },
37{ "LET", kwLET },
38{ "CONST", kwCONST },
39{ "DIM", kwDIM },
40{ "REDIM", kwREDIM },
41{ "STOP", kwSTOP },
42{ "END", kwEND },
43{ "PRINT", kwPRINT },
44{ "SPRINT", kwSPRINT },
45{ "INPUT", kwINPUT },
46{ "SINPUT", kwSINPUT },
47{ "REM", kwREM },
48{ "CHAIN", kwCHAIN },
49{ "ON", kwON },
50{ "LABEL", kwLABEL },
51{ "GOTO", kwGOTO },
52{ "IF", kwIF },
53{ "THEN", kwTHEN },
54{ "ELSE", kwELSE },
55{ "ELIF", kwELIF },
56{ "ELSEIF", kwELIF },
57{ "ENDIF", kwENDIF },
58{ "FI", kwENDIF },
59{ "FOR", kwFOR },
60{ "TO", kwTO },
61{ "STEP", kwSTEP },
62{ "NEXT", kwNEXT },
63{ "WHILE", kwWHILE },
64{ "WEND", kwWEND },
65{ "REPEAT", kwREPEAT },
66{ "UNTIL", kwUNTIL },
67{ "SELECT", kwSELECT },
68{ "CASE", kwCASE },
69{ "GOSUB", kwGOSUB },
70{ "RETURN", kwRETURN },
71{ "READ", kwREAD },
72{ "DATA", kwDATA },
73{ "RESTORE", kwRESTORE },
74{ "EXIT", kwEXIT },
75{ "ERASE", kwERASE },
76{ "USE", kwUSE },
77{ "USING", kwUSING },
78{ "USG", kwUSING },
79{ "LINE", kwLINE },
80{ "COLOR", kwCOLOR },
81{ "RUN", kwRUN },
82{ "EXEC", kwEXEC },
83{ "OPEN", kwOPEN },
84{ "APPEND", kwAPPEND },
85{ "AS", kwAS }, // OPEN's args
86{ "CLOSE", kwCLOSE },
87{ "LINEINPUT", kwLINEINPUT }, // The QB's keyword is "LINE INPUT"
88{ "LINPUT", kwLINEINPUT }, // The QB's keyword is "LINE INPUT"
89{ "SEEK", kwSEEK },
90{ "WRITE", kwFILEWRITE },
91{ "INSERT", kwINSERT },
92{ "DELETE", kwDELETE },
93{ "TRY", kwTRY },
94{ "CATCH", kwCATCH },
95{ "END TRY", kwENDTRY },
96
97/* DEBUG */
98{ "TRON", kwTRON },
99{ "TROFF", kwTROFF },
100{ "OPTION", kwOPTION },
101{ "BG", kwBACKG },
102{ "LOGPRINT", kwLOGPRINT },
103
104/* for debug */
105/* by using small letters, */
106/* the keywords are invisible by compiler */
107{ "$i32", kwTYPE_INT },
108{ "$r64", kwTYPE_NUM },
109{ "$str", kwTYPE_STR },
110{ "$log", kwTYPE_LOGOPR },
111{ "$cmp", kwTYPE_CMPOPR },
112{ "$add", kwTYPE_ADDOPR },
113{ "$mul", kwTYPE_MULOPR },
114{ "$pow", kwTYPE_POWOPR },
115{ "$unr", kwTYPE_UNROPR },
116{ "$var", kwTYPE_VAR },
117{ "$tln", kwTYPE_LINE },
118{ "$lpr", kwTYPE_LEVEL_BEGIN },
119{ "$rpr", kwTYPE_LEVEL_END },
120{ "$crv", kwTYPE_CRVAR },
121{ "$sep", kwTYPE_SEP },
122{ "$biF", kwTYPE_CALLF },
123{ "$biP", kwTYPE_CALLP },
124{ "$exF", kwTYPE_CALLEXTF },
125{ "$exP", kwTYPE_CALLEXTP },
126{ "$ret", kwTYPE_RET },
127{ "$udp", kwTYPE_CALL_UDP },
128{ "$udf", kwTYPE_CALL_UDF },
129{ "", 0 }
130};
131
132/*
133 * OPERATORS (not the symbols)
134 */
135struct opr_keyword_s opr_table[] = {
136{ "AND", kwTYPE_LOGOPR, '&' },
137{ "OR", kwTYPE_LOGOPR, '|' },
138{ "BAND", kwTYPE_LOGOPR, OPLOG_BAND },
139{ "BOR", kwTYPE_LOGOPR, OPLOG_BOR },
140{ "XOR", kwTYPE_LOGOPR, '~' },
141{ "NOT", kwTYPE_UNROPR, '!' },
142{ "MOD", kwTYPE_MULOPR, OPLOG_MOD },
143{ "MDL", kwTYPE_MULOPR, OPLOG_MDL },
144{ "EQV", kwTYPE_LOGOPR, OPLOG_EQV },
145{ "IMP", kwTYPE_LOGOPR, OPLOG_IMP },
146{ "NAND", kwTYPE_LOGOPR, OPLOG_NAND },
147{ "NOR", kwTYPE_LOGOPR, OPLOG_NOR },
148{ "XNOR", kwTYPE_LOGOPR, OPLOG_XNOR },
149{ "IN", kwTYPE_CMPOPR, OPLOG_IN },
150{ "LIKE", kwTYPE_CMPOPR, OPLOG_LIKE },
151{ "LSHIFT", kwTYPE_LOGOPR, OPLOG_LSHIFT },
152{ "RSHIFT", kwTYPE_LOGOPR, OPLOG_RSHIFT },
153{ "", 0, 0 }
154};
155
156/*
157 * SPECIAL SEPERATORS
158 *
159 * This keywords are used on commands but are not commands nor operators
160 *
161 * example:
162 * print USING ...
163 * for f IN x
164 * open x FOR INPUT ...
165 */
166struct spopr_keyword_s spopr_table[] = {
167{ "COLOR", kwCOLOR },
168{ "FILLED", kwFILLED },
169{ "FOR", kwFORSEP },
170{ "INPUT", kwINPUTSEP },
171{ "OUTPUT", kwOUTPUTSEP },
172{ "APPEND", kwAPPENDSEP },
173{ "USING", kwUSING },
174{ "USG", kwUSING },
175{ "AS", kwAS },
176{ "TO", kwTO },
177{ "DO", kwDO },
178{ "STEP", kwSTEP },
179{ "THEN", kwTHEN },
180{ "SUB", kwPROCSEP },
181{ "FUNC", kwFUNCSEP },
182{ "DEF", kwFUNCSEP },
183{ "LOOP", kwLOOPSEP },
184{ "ON", kwON },
185{ "OFF", kwOFF },
186{ "USE", kwUSE },
187{ "BG", kwBACKG },
188{ "", 0 }
189};
190
191/*
192 * BUILDIN-FUNCTIONS
193 */
194struct func_keyword_s func_table[] = {
195{ "ASC", kwASC },
196{ "VAL", kwVAL },
197{ "CHR", kwCHR },
198{ "STR", kwSTR },
199{ "OCT", kwOCT },
200{ "HEX", kwHEX },
201{ "LCASE", kwLCASE },
202{ "LOWER", kwLCASE },
203{ "UCASE", kwUCASE },
204{ "UPPER", kwUCASE },
205{ "LTRIM", kwLTRIM },
206{ "RTRIM", kwRTRIM },
207{ "SPACE", kwSPACE },
208{ "SPC", kwSPACE },
209{ "TAB", kwTAB },
210{ "CAT", kwCAT },
211{ "ENV", kwENVIRONF },
212{ "TRIM", kwTRIM },
213{ "STRING", kwSTRING },
214{ "SQUEEZE", kwSQUEEZE },
215{ "LEFT", kwLEFT },
216{ "RIGHT", kwRIGHT },
217{ "LEFTOF", kwLEFTOF },
218{ "RIGHTOF", kwRIGHTOF },
219{ "LEFTOFLAST", kwLEFTOFLAST },
220{ "RIGHTOFLAST", kwRIGHTOFLAST },
221{ "MID", kwMID },
222{ "REPLACE", kwREPLACE },
223{ "RUN", kwRUNF },
224{ "INKEY", kwINKEY },
225{ "TIME", kwTIME },
226{ "DATE", kwDATE },
227{ "INSTR", kwINSTR },
228{ "RINSTR", kwRINSTR },
229{ "LBOUND", kwLBOUND },
230{ "UBOUND", kwUBOUND },
231{ "LEN", kwLEN },
232{ "EMPTY", kwEMPTY },
233{ "ISARRAY", kwISARRAY },
234{ "ISNUMBER", kwISNUMBER },
235{ "ISSTRING", kwISSTRING },
236{ "ISMAP", kwISMAP },
237{ "ATAN2", kwATAN2 },
238{ "POW", kwPOW },
239{ "ROUND", kwROUND },
240{ "COS", kwCOS },
241{ "SIN", kwSIN },
242{ "TAN", kwTAN },
243{ "COSH", kwCOSH },
244{ "SINH", kwSINH },
245{ "TANH", kwTANH },
246{ "ACOS", kwACOS },
247{ "ASIN", kwASIN },
248{ "ATAN", kwATAN },
249{ "ATN", kwATAN },
250{ "ACOSH", kwACOSH },
251{ "ASINH", kwASINH },
252{ "ATANH", kwATANH },
253{ "SEC", kwSEC },
254{ "ASEC", kwASEC },
255{ "SECH", kwSECH },
256{ "ASECH", kwASECH },
257{ "CSC", kwCSC },
258{ "ACSC", kwACSC },
259{ "CSCH", kwCSCH },
260{ "ACSCH", kwACSCH },
261{ "COT", kwCOT },
262{ "ACOT", kwACOT },
263{ "COTH", kwCOTH },
264{ "ACOTH", kwACOTH },
265{ "SQR", kwSQR },
266{ "ABS", kwABS },
267{ "EXP", kwEXP },
268{ "LOG", kwLOG },
269{ "LOG10", kwLOG10 },
270{ "FIX", kwFIX },
271{ "INT", kwINT },
272{ "CDBL", kwCDBL },
273{ "CREAL", kwCDBL },
274{ "DEG", kwDEG },
275{ "RAD", kwRAD },
276{ "PEN", kwPENF },
277{ "FLOOR", kwFLOOR },
278{ "CEIL", kwCEIL },
279{ "FRAC", kwFRAC },
280{ "FRE", kwFRE },
281{ "SGN", kwSGN },
282{ "CINT", kwCINT },
283{ "EOF", kwEOF },
284{ "SEEK", kwSEEKF },
285{ "LOF", kwLOF },
286{ "RND", kwRND },
287{ "MAX", kwMAX },
288{ "MIN", kwMIN },
289{ "ABSMAX", kwABSMAX },
290{ "ABSMIN", kwABSMIN },
291{ "SUM", kwSUM },
292{ "SUMSQ", kwSUMSV },
293{ "STATMEAN", kwSTATMEAN },
294{ "STATMEANDEV", kwSTATMEANDEV },
295{ "STATSPREADS", kwSTATSPREADS },
296{ "STATSPREADP", kwSTATSPREADP },
297{ "SEGCOS", kwSEGCOS },
298{ "SEGSIN", kwSEGSIN },
299{ "SEGLEN", kwSEGLEN },
300{ "POLYAREA", kwPOLYAREA },
301{ "POLYCENT", kwPOLYCENT },
302{ "PTDISTSEG", kwPTDISTSEG },
303{ "PTSIGN", kwPTSIGN },
304{ "PTDISTLN", kwPTDISTLN },
305{ "POINT", kwPOINT },
306{ "XPOS", kwXPOS },
307{ "YPOS", kwYPOS },
308{ "INPUT", kwINPUTF },
309{ "LINEQN", kwGAUSSJORDAN },
310{ "FILES", kwFILES },
311{ "INVERSE", kwINVERSE },
312{ "DETERM", kwDETERM },
313{ "JULIAN", kwJULIAN },
314{ "DATEFMT", kwDATEFMT },
315{ "WEEKDAY", kwWDAY },
316{ "IF", kwIFF },
317{ "IFF", kwIFF },
318{ "FORMAT", kwFORMAT },
319{ "FREEFILE", kwFREEFILE },
320{ "TICKS", kwTICKS },
321{ "TIMER", kwTIMER },
322{ "PROGLINE", kwPROGLINE },
323{ "RUN", kwRUNF },
324{ "TXTW", kwTEXTWIDTH },
325{ "TXTH", kwTEXTHEIGHT },
326{ "TEXTWIDTH", kwTEXTWIDTH },
327{ "TEXTHEIGHT", kwTEXTHEIGHT },
328{ "EXIST", kwEXIST },
329{ "ISFILE", kwISFILE },
330{ "ISDIR", kwISDIR },
331{ "ISLINK", kwISLINK },
332{ "ACCESS", kwACCESSF },
333{ "RGB", kwRGB },
334{ "RGBF", kwRGBF },
335{ "BIN", kwBIN },
336{ "ENCLOSE", kwENCLOSE },
337{ "DISCLOSE", kwDISCLOSE },
338{ "TRANSLATE", kwTRANSLATEF },
339{ "CHOP", kwCHOP },
340{ "BGETC", kwBGETC },
341{ "SEQ", kwSEQ },
342{ "CBS", kwCBS },
343{ "BCS", kwBCS },
344{ "CALL", kwCALLCF },
345{ "IMAGE", kwIMAGE },
346{ "ARRAY", kwARRAY },
347{ "FORM", kwFORM },
348{ "WINDOW", kwWINDOW },
349{ "TIMESTAMP", kwTIMESTAMP },
350{ "", 0 }
351};
352
353/*
354 * BUILD-IN PROCEDURES
355 */
356struct proc_keyword_s proc_table[] = {
357{ "CLS", kwCLS },
358{ "THROW", kwTHROW },
359{ "ENV", kwENVIRON },
360{ "LOCATE", kwLOCATE },
361{ "AT", kwAT },
362{ "PEN", kwPEN },
363{ "DATEDMY", kwDATEDMY },
364{ "BEEP", kwBEEP },
365{ "SOUND", kwSOUND },
366{ "NOSOUND", kwNOSOUND },
367{ "PSET", kwPSET },
368{ "RECT", kwRECT },
369{ "CIRCLE", kwCIRCLE },
370{ "RANDOMIZE", kwRANDOMIZE },
371{ "SPLIT", kwSPLIT },
372{ "JOIN", kwWJOIN },
373{ "PAUSE", kwPAUSE },
374{ "DELAY", kwDELAY },
375{ "ARC", kwARC },
376{ "DRAW", kwDRAW },
377{ "PAINT", kwPAINT },
378{ "PLAY", kwPLAY },
379{ "SORT", kwSORT },
380{ "SEARCH", kwSEARCH },
381{ "ROOT", kwROOT },
382{ "DIFFEQN", kwDIFFEQ },
383{ "CHART", kwCHART },
384{ "WINDOW", kwWINDOW },
385{ "VIEW", kwVIEW },
386{ "DRAWPOLY", kwDRAWPOLY },
387{ "M3IDENT", kwM3IDENT },
388{ "M3ROTATE", kwM3ROTATE },
389{ "M3SCALE", kwM3SCALE },
390{ "M3TRANS", kwM3TRANSLATE },
391{ "M3APPLY", kwM3APPLY },
392{ "INTERSECT", kwSEGINTERSECT },
393{ "POLYEXT", kwPOLYEXT },
394{ "DERIV", kwDERIV },
395{ "KILL", kwKILL },
396{ "RENAME", kwRENAME },
397{ "COPY", kwCOPY },
398{ "CHDIR", kwCHDIR },
399{ "MKDIR", kwMKDIR },
400{ "RMDIR", kwRMDIR },
401{ "TLOAD", kwLOADLN },
402{ "TSAVE", kwSAVELN },
403{ "LOCK", kwFLOCK },
404{ "CHMOD", kwCHMOD },
405{ "PLOT", kwPLOT },
406{ "SWAP", kwSWAP },
407{ "DIRWALK", kwDIRWALK },
408{ "BPUTC", kwBPUTC },
409{ "BLOAD", kwBLOAD },
410{ "BSAVE", kwBSAVE },
411{ "TIMEHMS", kwTIMEHMS },
412{ "EXPRSEQ", kwEXPRSEQ },
413{ "CALL", kwCALLCP },
414{ "DEFINEKEY", kwDEFINEKEY },
415{ "SHOWPAGE", kwSHOWPAGE },
416{ "TIMER", kwTIMER },
417
418#if !defined(OS_LIMITED)
419{ "STKDUMP", kwSTKDUMP },
420#endif
421
422{ "", 0 }
423};
424
425/*
426 * in some cases (preprocessor) there is needed the texts
427 * (single-line IFs, option keyword, include, fast-cut of 'rem's. '@' ->
428 * byref, procedures declarations, etc)
429 *
430 * _WS = With spaces (one left and one right)
431 * _WRS = With one space at right
432 */
433#define LCN_PRINT "PRINT"
434#define LCN_REM "REM"
435#define LCN_THEN_WS " THEN "
436#define LCN_GOTO_WRS "GOTO "
437#define LCN_GOTO_WS " GOTO "
438#define LCN_ELSE "ELSE"
439#define LCN_BASE_WRS "BASE "
440#define LCN_PCRE_CASELESS "MATCH PCRE CASELESS"
441#define LCN_PCRE "MATCH PCRE"
442#define LCN_SIMPLE "MATCH SIMPLE"
443#define LCN_PREDEF_WRS "PREDEF "
444#define LCN_IMPORT_WRS "IMPORT "
445#define LCN_UNIT_WRS "UNIT "
446#define LCN_BYREF_WRS "BYREF "
447#define LCN_END "END"
448#define LCN_ENDIF "ENDIF"
449#define LCN_GOSUB_WS " GOSUB "
450#define LCN_DO_WS " DO "
451#define LCN_NEXT "NEXT"
452#define LCN_IN_WS " IN "
453#define LCN_WEND "WEND"
454#define LCN_IF "IF"
455#define LCN_SELECT "SELECT"
456#define LCN_END_SELECT "END SELECT"
457#define LCN_CASE "CASE"
458#define LCN_INPUT_WRS "INPUT "
459#define LCN_OPTION "OPTION"
460#define LCN_PREDEF "PREDEF"
461#define LCN_QUIET "QUIET"
462#define LCN_GRMODE "GRMODE"
463#define LCN_TEXTMODE "TEXTMODE"
464#define LCN_SBASICPATH "SBASICPATH"
465#define LCN_COMMAND "COMMAND"
466#define LCN_INC "INCLUDE"
467#define LCN_SUB_WRS "SUB "
468#define LCN_FUNC_WRS "FUNC "
469#define LCN_DEF_WRS "DEF "
470#define LCN_END_WRS "END "
471#define LCN_END_WNL "END\n"
472#define LCN_SHOWPAGE "SHOWPAGE"
473#define LCN_TRY "TRY"
474#define LCN_CATCH "CATCH"
475#define LCN_END_TRY "END TRY"
476#define LCN_ANTIALIAS "ANTIALIAS"
477#define LCN_LOAD_MODULES "LOAD MODULES"
478#define LCN_AUTOLOCAL "AUTOLOCAL"
479#define LCN_AS_WRS "AS "
480#define LCN_CONST "CONST"
481
482/* system variables */
483#define LCN_SV_SBVER "SBVER"
484#define LCN_SV_PI "PI"
485#define LCN_SV_XMAX "XMAX"
486#define LCN_SV_YMAX "YMAX"
487#define LCN_SV_TRUE "TRUE"
488#define LCN_SV_FALSE "FALSE"
489#define LCN_SV_CWD "CWD"
490#define LCN_SV_HOME "HOME"
491#define LCN_SV_COMMAND "COMMAND"
492#define LCN_SV_X "X"
493#define LCN_SV_Y "Y"
494#define LCN_SV_SELF "SELF"
495#define LCN_SV_NIL "NIL"
496#define LCN_SV_MAXINT "MAXINT"
497
498// fast cut of comments (pp)
499#define LCN_REM_1 ":rem "
500#define LCN_REM_2 ":rem\t"
501#define LCN_REM_3 "rem "
502#define LCN_REM_4 "rem\n"
503
504#define SYS_MAIN_SECTION_NAME "Main"
505