Commit | Line | Data |
---|---|---|
a7e60862 WJ |
1 | |
2 | /******************************************** | |
3 | scan.h | |
4 | copyright 1991, Michael D. Brennan | |
5 | ||
6 | This is a source file for mawk, an implementation of | |
7 | the AWK programming language. | |
8 | ||
9 | Mawk is distributed without warranty under the terms of | |
10 | the GNU General Public License, version 2, 1991. | |
11 | ********************************************/ | |
12 | ||
13 | ||
14 | /* $Log: scan.h,v $ | |
15 | * Revision 5.1 91/12/05 07:59:33 brennan | |
16 | * 1.1 pre-release | |
17 | * | |
18 | */ | |
19 | ||
20 | ||
21 | /* scan.h */ | |
22 | ||
23 | #ifndef SCAN_H_INCLUDED | |
24 | #define SCAN_H_INCLUDED 1 | |
25 | ||
26 | #include <stdio.h> | |
27 | ||
28 | #ifndef MAKESCAN | |
29 | #include "symtype.h" | |
30 | #include "parse.h" | |
31 | #endif | |
32 | ||
33 | ||
34 | extern char scan_code[256] ; | |
35 | ||
36 | /* the scan codes to compactify the main switch */ | |
37 | ||
38 | #define SC_SPACE 1 | |
39 | #define SC_NL 2 | |
40 | #define SC_SEMI_COLON 3 | |
41 | #define SC_FAKE_SEMI_COLON 4 | |
42 | #define SC_LBRACE 5 | |
43 | #define SC_RBRACE 6 | |
44 | #define SC_QMARK 7 | |
45 | #define SC_COLON 8 | |
46 | #define SC_OR 9 | |
47 | #define SC_AND 10 | |
48 | #define SC_PLUS 11 | |
49 | #define SC_MINUS 12 | |
50 | #define SC_MUL 13 | |
51 | #define SC_DIV 14 | |
52 | #define SC_MOD 15 | |
53 | #define SC_POW 16 | |
54 | #define SC_LPAREN 17 | |
55 | #define SC_RPAREN 18 | |
56 | #define SC_LBOX 19 | |
57 | #define SC_RBOX 20 | |
58 | #define SC_IDCHAR 21 | |
59 | #define SC_DIGIT 22 | |
60 | #define SC_DQUOTE 23 | |
61 | #define SC_ESCAPE 24 | |
62 | #define SC_COMMENT 25 | |
63 | #define SC_EQUAL 26 | |
64 | #define SC_NOT 27 | |
65 | #define SC_LT 28 | |
66 | #define SC_GT 29 | |
67 | #define SC_COMMA 30 | |
68 | #define SC_DOT 31 | |
69 | #define SC_MATCH 32 | |
70 | #define SC_DOLLAR 33 | |
71 | #define SC_UNEXPECTED 34 | |
72 | ||
73 | #ifndef MAKESCAN | |
74 | ||
75 | /* global functions in scan.c */ | |
76 | ||
77 | void PROTO(scan_init, (char *) ) ; | |
78 | void PROTO(scan_cleanup, (void) ) ; | |
79 | void PROTO(eat_nl, (void) ) ; | |
80 | int PROTO(yylex, (void) ) ; | |
81 | ||
82 | ||
83 | extern YYSTYPE yylval ; | |
84 | ||
85 | #define ct_ret(x) return current_token = (x) | |
86 | ||
87 | #define next() (*buffp ? *buffp++ : slow_next()) | |
88 | #define un_next() buffp-- | |
89 | ||
90 | #define test1_ret(c,x,d) if ( next() == (c) ) ct_ret(x) ;\ | |
91 | else { un_next() ; ct_ret(d) ; } | |
92 | ||
93 | #define test2_ret(c1,x1,c2,x2,d) switch( next() )\ | |
94 | { case c1: ct_ret(x1) ;\ | |
95 | case c2: ct_ret(x2) ;\ | |
96 | default: un_next() ;\ | |
97 | ct_ret(d) ; } | |
98 | #endif /* ! MAKESCAN */ | |
99 | #endif |