include/tokenizer.h

Tue, 15 Feb 2005 18:57:52 +0100

author
tailor@f281.ttorni.ton.tut.fi
date
Tue, 15 Feb 2005 18:57:52 +0100
changeset 0
86b7f6f9c5c0
child 1
6e704fc09528
permissions
-rw-r--r--

Tailorization of trunk
Import of the upstream sources from the repository

http://tao.uab.es/ion/svn/libtu/trunk

as of revision 2

0
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
1 /*
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
2 * libtu/tokenizer.h
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
3 *
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2000.
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
5 *
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
6 * This file is distributed under the terms of the "Artistic License".
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
7 * See the included file LICENSE for details.
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
8 */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
9
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
10 #ifndef __LIBTU_TOKENIZER_H
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
11 #define __LIBTU_TOKENIZER_H
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
12
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
13 #include <stdio.h>
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
14 #include "types.h"
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
15
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
16
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
17 #define TOK_SET_LONG(TOK, VAL) {(TOK)->type=TOK_LONG; (TOK)->u.lval=VAL;}
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
18 #define TOK_SET_DOUBLE(TOK, VAL) {(TOK)->type=TOK_DOUBLE; (TOK)->u.dval=VAL;}
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
19 #define TOK_SET_CHAR(TOK, VAL) {(TOK)->type=TOK_CHAR; (TOK)->u.cval=VAL;}
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
20 #define TOK_SET_STRING(TOK, VAL) {(TOK)->type=TOK_STRING; (TOK)->u.sval=VAL;}
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
21 #define TOK_SET_IDENT(TOK, VAL) {(TOK)->type=TOK_IDENT; (TOK)->u.sval=VAL;}
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
22 #define TOK_SET_COMMENT(TOK, VAL) {(TOK)->type=TOK_COMMENT; (TOK)->u.sval=VAL;}
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
23 #define TOK_SET_OP(TOK, VAL) {(TOK)->type=TOK_OP; (TOK)->u.opval=VAL;}
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
24
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
25 #define TOK_TYPE(TOK) ((TOK)->type)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
26 #define TOK_LONG_VAL(TOK) ((TOK)->u.lval)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
27 #define TOK_DOUBLE_VAL(TOK) ((TOK)->u.dval)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
28 #define TOK_CHAR_VAL(TOK) ((TOK)->u.cval)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
29 #define TOK_STRING_VAL(TOK) ((TOK)->u.sval)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
30 #define TOK_IDENT_VAL(TOK) ((TOK)->u.sval)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
31 #define TOK_COMMENT_VAL(TOK) ((TOK)->u.sval)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
32 #define TOK_OP_VAL(TOK) ((TOK)->u.opval)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
33
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
34 #define TOK_IS_LONG(TOK) ((TOK)->type==TOK_LONG)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
35 #define TOK_IS_DOUBLE(TOK) ((TOK)->type==TOK_DOUBLE)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
36 #define TOK_IS_CHAR(TOK) ((TOK)->type==TOK_CHAR)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
37 #define TOK_IS_STRING(TOK) ((TOK)->type==TOK_STRING)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
38 #define TOK_IS_IDENT(TOK) ((TOK)->type==TOK_IDENT)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
39 #define TOK_IS_COMMENT(TOK) ((TOK)->type==TOK_COMMENT)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
40 #define TOK_IS_OP(TOK) ((TOK)->type==TOK_OP)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
41
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
42 #define TOK_OP_IS(TOK, OP) ((TOK)->type==TOK_OP && (TOK)->u.opval==(OP))
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
43
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
44 #define TOK_TAKE_STRING_VAL(TOK) ((TOK)->type=TOK_INVALID, (TOK)->u.sval)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
45 #define TOK_TAKE_IDENT_VAL(TOK) ((TOK)->type=TOK_INVALID, (TOK)->u.sval)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
46 #define TOK_TAKE_COMMENT_VAL(TOK) ((TOK)->type=TOK_INVALID, (TOK)->u.sval)
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
47
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
48
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
49 enum{
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
50 TOK_INVALID=0,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
51 TOK_LONG,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
52 TOK_DOUBLE,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
53 TOK_CHAR,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
54 TOK_STRING,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
55 TOK_IDENT,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
56 TOK_COMMENT,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
57 TOK_OP
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
58 };
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
59
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
60
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
61 enum{
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
62 #define OP2(X,Y) ((X)|((Y)<<8))
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
63 #define OP3(X,Y,Z) ((X)|((Y)<<8)|((Z)<<16))
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
64
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
65 OP_L_PAR= '(', OP_R_PAR= ')', OP_L_BRK= '[', OP_R_BRK= ']',
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
66 OP_L_BRC= '{', OP_R_BRC= '}', OP_COMMA= ',', OP_SCOLON= ';',
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
67
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
68 OP_PLUS= '+', OP_MINUS= '-', OP_MUL= '*', OP_DIV= '/',
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
69 OP_MOD= '%', OP_POW= '^', OP_OR= '|', OP_AND= '&',
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
70 /*OP_NOT= '~',*/ OP_NOT= '!', OP_ASGN= '=', OP_LT= '<',
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
71 OP_GT= '>', OP_DOT= '.', OP_COLON= ':', OP_QMARK= '?',
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
72 OP_AT= '@',
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
73 OP_NEXTLINE='\n',OP_EOF= -1,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
74
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
75 OP_INC= OP2('+','+'), OP_DEC= OP2('-','-'),
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
76 OP_LSHIFT= OP2('<','<'), OP_RSHIFT= OP2('>','>'),
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
77 OP_AS_INC= OP2('+','='), OP_AS_DEC= OP2('-','='),
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
78 OP_AS_MUL= OP2('*','='), OP_AS_DIV= OP2('/','='),
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
79 OP_AS_MOD= OP2('%','='), OP_AS_POW= OP2('^','='),
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
80
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
81 /* AS_OR= OP2('|','='), AS_AND= OP2('&','='), */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
82 OP_EQ= OP2('=','='), OP_NE= OP2('!','='),
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
83 OP_LE= OP2('<','='), OP_GE= OP2('>','=')
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
84
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
85 /* L_AND= OP2('&','&'), L_OR= OP2('|','|'),
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
86 L_XOR= OP2('^','^'), */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
87
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
88 /* AsLShift= OP3('<','<','='),
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
89 AsRShift= OP3('>','>','='), */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
90
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
91 #undef OP2
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
92 #undef OP3
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
93 };
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
94
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
95
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
96 typedef struct{
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
97 int type;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
98 int line;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
99 union{
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
100 long lval;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
101 double dval;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
102 char cval;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
103 char *sval;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
104 int opval;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
105 } u;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
106 } Token;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
107
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
108 #define TOK_INIT {0, 0, {0}}
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
109
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
110
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
111 extern void tok_free(Token*tok);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
112 extern void tok_init(Token*tok);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
113
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
114
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
115 /* */
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
116
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
117
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
118 enum{
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
119 TOKZ_IGNORE_NEXTLINE=0x1,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
120 TOKZ_READ_COMMENTS=0x2,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
121 TOKZ_PARSER_INDENT_MODE=0x4
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
122 };
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
123
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
124
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
125 enum{
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
126 E_TOKZ_UNEXPECTED_EOF=1,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
127 E_TOKZ_UNEXPECTED_EOL,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
128 E_TOKZ_EOL_EXPECTED,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
129 E_TOKZ_INVALID_CHAR,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
130 E_TOKZ_TOOBIG,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
131 E_TOKZ_NUMFMT,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
132 E_TOKZ_NUM_JUNK,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
133 E_TOKZ_NOTINT,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
134 E_TOKZ_RANGE,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
135 E_TOKZ_MULTICHAR,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
136
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
137 E_TOKZ_TOKEN_LIMIT,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
138 E_TOKZ_UNKNOWN_OPTION,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
139 E_TOKZ_SYNTAX,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
140 E_TOKZ_INVALID_ARGUMENT,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
141 E_TOKZ_EOS_EXPECTED,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
142 E_TOKZ_TOO_FEW_ARGS,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
143 E_TOKZ_TOO_MANY_ARGS,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
144 E_TOKZ_MAX_NEST,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
145 E_TOKZ_UNEXPECTED_EOS,
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
146 E_TOKZ_IDENTIFIER_EXPECTED
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
147 };
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
148
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
149
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
150 struct _ConfOpt;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
151
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
152 typedef struct{
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
153 FILE *file;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
154 const char *name;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
155 int flags;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
156 int line;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
157 int ungetc;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
158 const struct _ConfOpt **optstack;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
159 int nest_lvl;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
160 void *user_data;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
161 } Tokenizer;
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
162
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
163
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
164 extern Tokenizer *tokz_open(const char *fname);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
165 extern Tokenizer *tokz_open_file(FILE *file);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
166 extern void tokz_close(Tokenizer *tokz);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
167 extern bool tokz_get_token(Tokenizer *tokz, Token *tok);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
168 extern void tokz_warn_error(const Tokenizer *tokz, int line, int e);
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
169
86b7f6f9c5c0 Tailorization of trunk
tailor@f281.ttorni.ton.tut.fi
parents:
diff changeset
170 #endif /* __LIBTU_TOKENIZER_H */

mercurial