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
|
/********************************************
kw.c
copyright 1991, Michael D. Brennan
This is a source file for mawk, an implementation of
the AWK programming language.
Mawk is distributed without warranty under the terms of
the GNU General Public License, version 2, 1991.
********************************************/
/* $Log: kw.c,v $
* Revision 1.2 1993/07/17 13:22:59 mike
* indent and general code cleanup
*
* Revision 1.1.1.1 1993/07/03 18:58:15 mike
* move source to cvs
*
* Revision 5.1 1991/12/05 07:56:12 brennan
* 1.1 pre-release
*
*/
/* kw.c */
#include "mawk.h"
#include "symtype.h"
#include "parse.h"
#include "init.h"
static struct kw
{
char *text ;
short kw ;
}
keywords[] =
{
"print", PRINT,
"printf", PRINTF,
"do", DO,
"while", WHILE,
"for", FOR,
"break", BREAK,
"continue", CONTINUE,
"if", IF,
"else", ELSE,
"in", IN,
"delete", DELETE,
"split", SPLIT,
"match", MATCH_FUNC,
"BEGIN", BEGIN,
"END", END,
"exit", EXIT,
"next", NEXT,
"return", RETURN,
"getline", GETLINE,
"sub", SUB,
"gsub", GSUB,
"function", FUNCTION,
(char *) 0, 0
} ;
/* put keywords in the symbol table */
void
kw_init()
{
register struct kw *p = keywords ;
register SYMTAB *q ;
while (p->text)
{
q = insert(p->text) ;
q->type = ST_KEYWORD ;
q->stval.kw = p++->kw ;
}
}
/* find a keyword to emit an error message */
char *
find_kw_str(kw_token)
int kw_token ;
{
struct kw *p ;
for (p = keywords; p->text; p++)
if (p->kw == kw_token) return p->text ;
/* search failed */
return (char *) 0 ;
}
|