35 #ifndef __FREEWRL_CPARSE_LEXER_H__
36 #define __FREEWRL_CPARSE_LEXER_H__
39 #include "../scenegraph/Vector.h"
45 #define ID_UNDEFINED -1
47 #define LEXER_INPUT_STACK_MAX 16
53 char* startOfStringPtr[LEXER_INPUT_STACK_MAX];
58 char *oldNextIn[LEXER_INPUT_STACK_MAX];
61 struct Vector* userNodeTypesVec;
62 Stack* userNodeTypesStack;
63 struct Vector* user_initializeOnly;
64 struct Vector* user_inputOutput;
65 struct Vector* user_inputOnly;
66 struct Vector* user_outputOnly;
74 void lexer_destroyData(
struct VRMLLexer* me);
75 void lexer_destroyIdStack(
Stack*);
78 #define lexer_getProtoPopCnt(me) \
79 (vectorSize(me->userNodeTypesVec)-stack_top(int, me->userNodeTypesStack))
82 void lexer_fromString (
struct VRMLLexer *,
char *);
83 void lexer_forceStringCleanup (
struct VRMLLexer *me);
86 #define lexer_eof(me) \
87 ((me)->isEof && !(me)->curID)
90 #define lexer_stringUFieldName(me, index, type) \
91 vector_get(char*, me->user_##type, index)
92 #define lexer_stringUser_initializeOnly(me, index) \
93 lexer_stringUFieldName(me, index, initializeOnly)
94 #define lexer_stringUser_inputOutput(me, index) \
95 lexer_stringUFieldName(me, index, inputOutput)
96 #define lexer_stringUser_inputOnly(me, index) \
97 lexer_stringUFieldName(me, index, inputOnly)
98 #define lexer_stringUser_outputOnly(me, index) \
99 lexer_stringUFieldName(me, index, outputOnly)
101 const char* lexer_stringUser_fieldName(
struct VRMLLexer* me,
int name,
int mode);
112 void lexer_scopeOut_PROTO(
struct VRMLLexer*);
113 BOOL lexer_keyword(
struct VRMLLexer*,
int);
114 BOOL lexer_specialID(
struct VRMLLexer*,
int* retB,
int* retU,
115 const char**,
const int,
struct Vector*);
116 BOOL lexer_specialID_string(
struct VRMLLexer*,
int* retB,
int* retU,
117 const char**,
const int,
struct Vector*,
const char*);
119 #define lexer_defineNodeName(me, ret) \
120 lexer_defineID(me, ret, stack_top(struct Vector*, me->userNodeNames), TRUE)
121 #define lexer_defineNodeType(me, ret) \
122 lexer_defineID(me, ret, me->userNodeTypesVec, FALSE)
123 #define lexer_define_initializeOnly(me, ret) \
124 lexer_defineID(me, ret, me->user_initializeOnly, TRUE)
125 #define lexer_define_inputOutput(me, ret) \
126 lexer_defineID(me, ret, me->user_inputOutput, TRUE)
127 #define lexer_define_inputOnly(me, ret) \
128 lexer_defineID(me, ret, me->user_inputOnly, TRUE)
129 #define lexer_define_outputOnly(me, ret) \
130 lexer_defineID(me, ret, me->user_outputOnly, TRUE)
131 BOOL lexer_initializeOnly(
struct VRMLLexer*,
int*,
int*,
int*,
int*);
133 int*,
int*,
int*,
int*,
int routeToFrom);
134 #define lexer_inputOnly(me, node, a, b, c, d) \
135 lexer_event(me, node, a, b, c, d, ROUTED_FIELD_EVENT_IN)
136 #define lexer_outputOnly(me, node, a, b, c, d) \
137 lexer_event(me, node, a, b, c, d, ROUTED_FIELD_EVENT_OUT)
138 #define lexer_node(me, r1, r2) \
139 lexer_specialID(me, r1, r2, NODES, NODES_COUNT, me->userNodeTypesVec)
140 #define lexer_nodeName(me, ret) \
141 lexer_specialID(me, NULL, ret, NULL, 0, \
142 stack_top(struct Vector*, me->userNodeNames))
143 #define lexer_protoFieldMode(me, r) \
144 lexer_specialID(me, r, NULL, PROTOKEYWORDS, PROTOKEYWORDS_COUNT, NULL)
145 #define lexer_fieldType(me, r) \
146 lexer_specialID(me, r, NULL, FIELDTYPES, FIELDTYPES_COUNT, NULL)
147 int lexer_string2id(
const char*,
const struct Vector*);
148 #define lexer_nodeName2id(me, str) \
149 lexer_string2id(str, stack_top(struct Vector*, me->userNodeNames))
152 BOOL lexer_int32(
struct VRMLLexer*, vrmlInt32T*);
153 BOOL lexer_float(
struct VRMLLexer*, vrmlFloatT*);
154 BOOL lexer_double(
struct VRMLLexer*, vrmlDoubleT*);
158 BOOL lexer_operator(
struct VRMLLexer*,
char);
159 #define lexer_point(me) \
160 lexer_operator(me, '.')
161 #define lexer_openCurly(me) \
162 lexer_operator(me, '{')
163 #define lexer_closeCurly(me) \
164 lexer_operator(me, '}')
165 #define lexer_openSquare(me) \
166 lexer_operator(me, '[')
167 #define lexer_closeSquare(me) \
168 lexer_operator(me, ']')
169 #define lexer_colon(me) \
170 lexer_operator(me,':')
173 void skipToEndOfOpenCurly(
struct VRMLLexer *me,
int level);
175 void concatAndGiveToLexer(
struct VRMLLexer *me,
const char *str_a,
const char *str_b);
178 BOOL lexer_field(
struct VRMLLexer* me,
int* retBO,
int* retBE,
int* retUO,
int* retUE);