1988-10-26 15:21:11 +00:00
|
|
|
/* T O K E N D E F I N I T I O N S */
|
|
|
|
|
2013-05-14 19:47:04 +00:00
|
|
|
#include "parameters.h"
|
1988-10-26 15:21:11 +00:00
|
|
|
#include "Lpars.h"
|
|
|
|
#include "idf.h"
|
|
|
|
#include "tokenname.h"
|
|
|
|
|
|
|
|
/* To centralize the declaration of %tokens, their presence in this
|
|
|
|
file is taken as their declaration. The Makefile will produce
|
|
|
|
a grammar file (tokenfile.g) from this file. This scheme ensures
|
|
|
|
that all tokens have a printable name.
|
|
|
|
Also, the "symbol2str.c" file is produced from this file.
|
|
|
|
*/
|
|
|
|
|
1991-03-26 13:38:36 +00:00
|
|
|
#ifdef ____
|
1988-10-26 15:21:11 +00:00
|
|
|
struct tokenname tkspec[] = { /* the names of the special tokens */
|
|
|
|
{IDENT, "identifier"},
|
|
|
|
{STRING, "string"},
|
|
|
|
{INTEGER, "integer"},
|
|
|
|
{REAL, "real"},
|
|
|
|
{0, ""}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tokenname tkcomp[] = { /* names of the composite tokens */
|
|
|
|
{LESSEQUAL, "<="},
|
|
|
|
{GREATEREQUAL, ">="},
|
|
|
|
{NOTEQUAL, "<>"},
|
|
|
|
{UPTO, ".."},
|
|
|
|
{BECOMES, ":="},
|
|
|
|
{0, ""}
|
|
|
|
};
|
1991-03-26 13:38:36 +00:00
|
|
|
#endif /* ____ */
|
1988-10-26 15:21:11 +00:00
|
|
|
|
|
|
|
struct tokenname tkidf[] = { /* names of the identifier tokens */
|
|
|
|
{AND, "and"},
|
|
|
|
{ARRAY, "array"},
|
|
|
|
{BEGIN, "begin"},
|
|
|
|
{CASE, "case"},
|
|
|
|
{CONST, "const"},
|
|
|
|
{DIV, "div"},
|
|
|
|
{DO, "do"},
|
|
|
|
{DOWNTO, "downto"},
|
|
|
|
{ELSE, "else"},
|
|
|
|
{END, "end"},
|
|
|
|
{FILE, "file"},
|
|
|
|
{FOR, "for"},
|
|
|
|
{FUNCTION, "function"},
|
|
|
|
{GOTO, "goto"},
|
|
|
|
{IF, "if"},
|
|
|
|
{IN, "in"},
|
|
|
|
{LABEL, "label"},
|
|
|
|
{MOD, "mod"},
|
|
|
|
{NIL, "nil"},
|
|
|
|
{NOT, "not"},
|
|
|
|
{OF, "of"},
|
|
|
|
{OR, "or"},
|
|
|
|
{PACKED, "packed"},
|
|
|
|
{PROCEDURE, "procedure"},
|
|
|
|
{PROGRAM, "program"},
|
|
|
|
{RECORD, "record"},
|
|
|
|
{REPEAT, "repeat"},
|
|
|
|
{SET, "set"},
|
|
|
|
{THEN, "then"},
|
|
|
|
{TO, "to"},
|
|
|
|
{TYPE, "type"},
|
|
|
|
{UNTIL, "until"},
|
|
|
|
{VAR, "var"},
|
|
|
|
{WHILE, "while"},
|
|
|
|
{WITH, "with"},
|
|
|
|
{0, ""}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tokenname tkstandard[] = { /* standard identifiers */
|
|
|
|
/* These are the only standard identifiers entered here, because
|
|
|
|
* they can get a variable number of arguments, and there are
|
|
|
|
* special syntaxrules in the grammar for them
|
|
|
|
*/
|
|
|
|
{READ, "read"},
|
|
|
|
{READLN, "readln"},
|
|
|
|
{WRITE, "write"},
|
|
|
|
{WRITELN, "writeln"},
|
|
|
|
{0, ""}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Some routines to handle tokennames */
|
|
|
|
|
|
|
|
reserve(resv)
|
|
|
|
register struct tokenname *resv;
|
|
|
|
{
|
|
|
|
/* The names of the tokens described in resv are entered
|
|
|
|
as reserved words.
|
|
|
|
*/
|
|
|
|
register struct idf *p;
|
|
|
|
|
|
|
|
while( resv->tn_symbol ) {
|
|
|
|
p = str2idf(resv->tn_name, 0);
|
|
|
|
if( !p ) fatal("out of Memory");
|
|
|
|
p->id_reserved = resv->tn_symbol;
|
|
|
|
resv++;
|
|
|
|
}
|
|
|
|
}
|