1 /* Copyright (c) 2003, David Leonard. All rights reserved. */
2 
3 #ifndef _SEE_h_lex_
4 #define _SEE_h_lex_
5 
6 /*
7  * The lexical analyser returns the next syntactic token from
8  * the input stream.
9  */
10 
11 struct SEE_input;
12 struct SEE_string;
13 
14 struct lex {
15 	struct SEE_input  *input;
16 	struct SEE_value   value;
17 	int		   next;		/* single token lookahead */
18 	int		   next_lineno;		/* line number of next */
19 	struct SEE_string *next_filename;	/* source id for line number */
20 	SEE_boolean_t	   next_follows_nl;	/* next was preceeded by NL */
21 	SEE_boolean_t	   next_at_bol;		/* input at beginning of line */
22 };
23 
24 void SEE_lex_init(struct lex *lex, struct SEE_input *input);
25 int  SEE_lex_next(struct lex *lex);
26 void SEE_lex_regex(struct lex *lex);
27 
28 int SEE_lex_number(struct SEE_interpreter *i,
29 	struct SEE_string *s, struct SEE_value *res);
30 
31 /*
32  * tokens returned by SEE_lex_next()
33  * (single-character tokens, like ';', are represented by their ASCII value)
34  */
35 
36 #define tEND		(-1)		/* end of file */
37 #define tANDAND		257
38 #define tANDEQ		258
39 #define tBREAK		259
40 #define tCASE		260
41 #define tCATCH		261
42 #define tCONTINUE	262
43 #define tDEFAULT	263
44 #define tDELETE		264
45 #define tDIV		'/'
46 #define tDIVEQ		266
47 #define tDO		267
48 #define tELSE		268
49 #define tEQ		269
50 #define tFINALLY	270
51 #define tFOR		271
52 #define tFUNCTION	272
53 #define tGE		273
54 #define tIF		274
55 #define tIN		275
56 #define tINSTANCEOF	276
57 #define tLE		277
58 #define tLSHIFT		278
59 #define tLSHIFTEQ	279
60 #define tMINUSEQ	280
61 #define tMINUSMINUS	281
62 #define tMODEQ		282
63 #define tNE		283
64 #define tNEW		284
65 #define tOREQ		285
66 #define tOROR		286
67 #define tPLUSEQ		287
68 #define tPLUSPLUS	288
69 #define tREGEX		289
70 #define tRESERVED	290	/* any "reserved" keyword */
71 #define tRETURN		291
72 #define tRSHIFT		292
73 #define tRSHIFTEQ	293
74 #define tSEQ		294
75 #define tSNE		295
76 #define tSTAREQ		296
77 #define tSWITCH		297
78 #define tTHIS		298
79 #define tTHROW		299
80 #define tTRY		300
81 #define tTYPEOF		301
82 #define tURSHIFT	302
83 #define tURSHIFTEQ	303
84 #define tVAR		304
85 #define tVOID		305
86 #define tWHILE		306
87 #define tWITH		307
88 #define tXOREQ		308
89 #define tNUMBER		309	/* numeric constant */
90 #define tSTRING		310	/* string constant */
91 #define tIDENT		311	/* non-keyword identifier */
92 #define tCOMMENT	312	/* internal: any kind of comment */
93 #define tLINETERMINATOR	313	/* internal: end of line */
94 #define tTRUE		314
95 #define tNULL		315
96 #define tFALSE		316
97 #define tSGMLCOMMENT	317	/* internal: '<!--' */
98 #define tSGMLCOMMENTEND	318	/* internal: '-->'  */
99 
100 #endif /* _SEE_h_lex_ */
101