diff options
author | David Walter Seikel | 2012-01-12 06:42:08 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-12 06:42:08 +1000 |
commit | c42c2c574da1dc7e4a0e9a5fbf8a41fa09d64cd4 (patch) | |
tree | bb685cfb1177af10ca2a596eb2bf1d71c8315e8f /LuaSL/src | |
parent | Space reduction. (diff) | |
download | SledjHamr-c42c2c574da1dc7e4a0e9a5fbf8a41fa09d64cd4.zip SledjHamr-c42c2c574da1dc7e4a0e9a5fbf8a41fa09d64cd4.tar.gz SledjHamr-c42c2c574da1dc7e4a0e9a5fbf8a41fa09d64cd4.tar.bz2 SledjHamr-c42c2c574da1dc7e4a0e9a5fbf8a41fa09d64cd4.tar.xz |
Make the lexer more reentrant, and piss off yyerror.
Diffstat (limited to 'LuaSL/src')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.c | 8 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 10 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_lexer.l | 166 |
3 files changed, 90 insertions, 94 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.c b/LuaSL/src/LuaSL_LSL_tree.c index 2b4d882..65ccbc8 100644 --- a/LuaSL/src/LuaSL_LSL_tree.c +++ b/LuaSL/src/LuaSL_LSL_tree.c | |||
@@ -411,6 +411,7 @@ int main(int argc, char **argv) | |||
411 | char buffer[PATH_MAX]; | 411 | char buffer[PATH_MAX]; |
412 | char fileName[PATH_MAX]; | 412 | char fileName[PATH_MAX]; |
413 | LuaSL_yyparseParam param; | 413 | LuaSL_yyparseParam param; |
414 | LuaSL_yyparseExtra extra; | ||
414 | int file; | 415 | int file; |
415 | int count; | 416 | int count; |
416 | boolean badArgs = FALSE; | 417 | boolean badArgs = FALSE; |
@@ -499,7 +500,8 @@ int main(int argc, char **argv) | |||
499 | 500 | ||
500 | param.ast = NULL; | 501 | param.ast = NULL; |
501 | param.lval = calloc(1, sizeof(LSL_Leaf)); | 502 | param.lval = calloc(1, sizeof(LSL_Leaf)); |
502 | if (yylex_init(&(param.scanner))) | 503 | memset(&extra, 0, sizeof(extra)); |
504 | if (yylex_init_extra(&extra, &(param.scanner))) | ||
503 | return 1; | 505 | return 1; |
504 | 506 | ||
505 | #ifdef LUASL_DEBUG | 507 | #ifdef LUASL_DEBUG |
@@ -561,8 +563,8 @@ int main(int argc, char **argv) | |||
561 | sprintf(buffer, "diff %s %s", fileName, outName); | 563 | sprintf(buffer, "diff %s %s", fileName, outName); |
562 | count = system(buffer); | 564 | count = system(buffer); |
563 | printf("Return value of %s is %d\n", buffer, count); | 565 | printf("Return value of %s is %d\n", buffer, count); |
564 | if (0 != count} | 566 | if (0 != count) |
565 | printf(stderr, "%s says they are different!\n", buffer); | 567 | fprintf(stderr, "%s says they are different!\n", buffer); |
566 | 568 | ||
567 | } | 569 | } |
568 | else | 570 | else |
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index bb29399..533237a 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h | |||
@@ -168,6 +168,13 @@ struct _LSL_Script | |||
168 | LSL_Identifier *variables; | 168 | LSL_Identifier *variables; |
169 | }; | 169 | }; |
170 | 170 | ||
171 | typedef struct | ||
172 | { | ||
173 | char *ignorableText; | ||
174 | int column; | ||
175 | int line; | ||
176 | } LuaSL_yyparseExtra; | ||
177 | |||
171 | 178 | ||
172 | // define the type for flex and lemon3 | 179 | // define the type for flex and lemon3 |
173 | #define YYSTYPE LSL_Leaf | 180 | #define YYSTYPE LSL_Leaf |
@@ -177,7 +184,6 @@ struct _LSL_Script | |||
177 | #include "LuaSL_lexer.h" | 184 | #include "LuaSL_lexer.h" |
178 | #endif | 185 | #endif |
179 | 186 | ||
180 | |||
181 | typedef struct | 187 | typedef struct |
182 | { | 188 | { |
183 | yyscan_t scanner; | 189 | yyscan_t scanner; |
@@ -200,8 +206,6 @@ LSL_Leaf *addOperation(LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right); | |||
200 | LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Leaf *rval); | 206 | LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Leaf *rval); |
201 | LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr); | 207 | LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr); |
202 | 208 | ||
203 | int yyerror(const char *msg); | ||
204 | |||
205 | void *ParseAlloc(void *(*mallocProc)(size_t)); | 209 | void *ParseAlloc(void *(*mallocProc)(size_t)); |
206 | void ParseTrace(FILE *TraceFILE, char *zTracePrompt); | 210 | void ParseTrace(FILE *TraceFILE, char *zTracePrompt); |
207 | void Parse(void *yyp, int yymajor, LSL_Leaf *yyminor, LuaSL_yyparseParam *param); | 211 | void Parse(void *yyp, int yymajor, LSL_Leaf *yyminor, LuaSL_yyparseParam *param); |
diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l index 50f2624..b4a1444 100644 --- a/LuaSL/src/LuaSL_lexer.l +++ b/LuaSL/src/LuaSL_lexer.l | |||
@@ -4,7 +4,7 @@ | |||
4 | #include "LuaSL_LSL_tree.h" | 4 | #include "LuaSL_LSL_tree.h" |
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | 6 | ||
7 | int common(YYSTYPE *lval, char *text, boolean checkIgnorable, int type); | 7 | int common(YYSTYPE *lval, char *text, LuaSL_yyparseExtra *extra, boolean checkIgnorable, int type); |
8 | 8 | ||
9 | %} | 9 | %} |
10 | 10 | ||
@@ -13,6 +13,7 @@ int common(YYSTYPE *lval, char *text, boolean checkIgnorable, int type); | |||
13 | %option noreject noyymore | 13 | %option noreject noyymore |
14 | %option backup debug perf-report perf-report verbose warn | 14 | %option backup debug perf-report perf-report verbose warn |
15 | %option align full | 15 | %option align full |
16 | %option extra-type="LuaSL_yyparseExtra *" | ||
16 | 17 | ||
17 | HEX [[:xdigit:]] | 18 | HEX [[:xdigit:]] |
18 | INTEGER [[:digit:]]+ | 19 | INTEGER [[:digit:]]+ |
@@ -27,138 +28,127 @@ IDENTIFIER [[:alpha:]](_|[[:alpha:]]|[[:digit:]])* | |||
27 | /* The order here is important, in mysterious ways. The more specific the lower in case of ambiguities like "floats contain integers". I think, not tested that well yet. */ | 28 | /* The order here is important, in mysterious ways. The more specific the lower in case of ambiguities like "floats contain integers". I think, not tested that well yet. */ |
28 | 29 | ||
29 | /* Ignorables. */ | 30 | /* Ignorables. */ |
30 | [[:space:]]+ %{ common(yylval, yytext, FALSE, LSL_SPACE); %} | 31 | [[:space:]]+ %{ common(yylval, yytext, yyextra, FALSE, LSL_SPACE); %} |
31 | /* Yes I know this will have problems with huge comments, just being simple to get it to work for now. */ | 32 | /* Yes I know this will have problems with huge comments, just being simple to get it to work for now. */ |
32 | "/*"([^"*/"]*)"*/" %{ common(yylval, yytext, FALSE, LSL_COMMENT); %} | 33 | "/*"([^"*/"]*)"*/" %{ common(yylval, yytext, yyextra, FALSE, LSL_COMMENT); %} |
33 | "//"[^\n]* %{ common(yylval, yytext, FALSE, LSL_COMMENT_LINE); %} | 34 | "//"[^\n]* %{ common(yylval, yytext, yyextra, FALSE, LSL_COMMENT_LINE); %} |
34 | 35 | ||
35 | /* Operations. */ | 36 | /* Operations. */ |
36 | "&&" { return common(yylval, yytext, TRUE, LSL_BOOL_AND); } | 37 | "&&" { return common(yylval, yytext, yyextra, TRUE, LSL_BOOL_AND); } |
37 | "||" { return common(yylval, yytext, TRUE, LSL_BOOL_OR); } | 38 | "||" { return common(yylval, yytext, yyextra, TRUE, LSL_BOOL_OR); } |
38 | "|" { return common(yylval, yytext, TRUE, LSL_BIT_OR); } | 39 | "|" { return common(yylval, yytext, yyextra, TRUE, LSL_BIT_OR); } |
39 | "^" { return common(yylval, yytext, TRUE, LSL_BIT_XOR); } | 40 | "^" { return common(yylval, yytext, yyextra, TRUE, LSL_BIT_XOR); } |
40 | "&" { return common(yylval, yytext, TRUE, LSL_BIT_AND); } | 41 | "&" { return common(yylval, yytext, yyextra, TRUE, LSL_BIT_AND); } |
41 | "!=" { return common(yylval, yytext, TRUE, LSL_NOT_EQUAL); } | 42 | "!=" { return common(yylval, yytext, yyextra, TRUE, LSL_NOT_EQUAL); } |
42 | "==" { return common(yylval, yytext, TRUE, LSL_EQUAL); } | 43 | "==" { return common(yylval, yytext, yyextra, TRUE, LSL_EQUAL); } |
43 | ">=" { return common(yylval, yytext, TRUE, LSL_GREATER_EQUAL); } | 44 | ">=" { return common(yylval, yytext, yyextra, TRUE, LSL_GREATER_EQUAL); } |
44 | "<=" { return common(yylval, yytext, TRUE, LSL_LESS_EQUAL); } | 45 | "<=" { return common(yylval, yytext, yyextra, TRUE, LSL_LESS_EQUAL); } |
45 | ">" { return common(yylval, yytext, TRUE, LSL_GREATER_THAN); } | 46 | ">" { return common(yylval, yytext, yyextra, TRUE, LSL_GREATER_THAN); } |
46 | "<" { return common(yylval, yytext, TRUE, LSL_LESS_THAN); } | 47 | "<" { return common(yylval, yytext, yyextra, TRUE, LSL_LESS_THAN); } |
47 | ">>" { return common(yylval, yytext, TRUE, LSL_RIGHT_SHIFT); } | 48 | ">>" { return common(yylval, yytext, yyextra, TRUE, LSL_RIGHT_SHIFT); } |
48 | "<<" { return common(yylval, yytext, TRUE, LSL_LEFT_SHIFT); } | 49 | "<<" { return common(yylval, yytext, yyextra, TRUE, LSL_LEFT_SHIFT); } |
49 | "+" { return common(yylval, yytext, TRUE, LSL_ADD); } | 50 | "+" { return common(yylval, yytext, yyextra, TRUE, LSL_ADD); } |
50 | "-" { return common(yylval, yytext, TRUE, LSL_SUBTRACT); } | 51 | "-" { return common(yylval, yytext, yyextra, TRUE, LSL_SUBTRACT); } |
51 | "*" { return common(yylval, yytext, TRUE, LSL_MULTIPLY); } | 52 | "*" { return common(yylval, yytext, yyextra, TRUE, LSL_MULTIPLY); } |
52 | "%" { return common(yylval, yytext, TRUE, LSL_MODULO); } | 53 | "%" { return common(yylval, yytext, yyextra, TRUE, LSL_MODULO); } |
53 | "/" { return common(yylval, yytext, TRUE, LSL_DIVIDE); } | 54 | "/" { return common(yylval, yytext, yyextra, TRUE, LSL_DIVIDE); } |
54 | "!" { return common(yylval, yytext, TRUE, LSL_BOOL_NOT); } | 55 | "!" { return common(yylval, yytext, yyextra, TRUE, LSL_BOOL_NOT); } |
55 | "~" { return common(yylval, yytext, TRUE, LSL_BIT_NOT); } | 56 | "~" { return common(yylval, yytext, yyextra, TRUE, LSL_BIT_NOT); } |
56 | "[" { return common(yylval, yytext, TRUE, LSL_BRACKET_OPEN); } | 57 | "[" { return common(yylval, yytext, yyextra, TRUE, LSL_BRACKET_OPEN); } |
57 | "]" { return common(yylval, yytext, TRUE, LSL_BRACKET_CLOSE); } | 58 | "]" { return common(yylval, yytext, yyextra, TRUE, LSL_BRACKET_CLOSE); } |
58 | "(" { return common(yylval, yytext, TRUE, LSL_PARENTHESIS_OPEN); } | 59 | "(" { return common(yylval, yytext, yyextra, TRUE, LSL_PARENTHESIS_OPEN); } |
59 | ")" { return common(yylval, yytext, TRUE, LSL_PARENTHESIS_CLOSE); } | 60 | ")" { return common(yylval, yytext, yyextra, TRUE, LSL_PARENTHESIS_CLOSE); } |
60 | "+=" { return common(yylval, yytext, TRUE, LSL_ASSIGNMENT_ADD); } | 61 | "+=" { return common(yylval, yytext, yyextra, TRUE, LSL_ASSIGNMENT_ADD); } |
61 | "-=" { return common(yylval, yytext, TRUE, LSL_ASSIGNMENT_SUBTRACT); } | 62 | "-=" { return common(yylval, yytext, yyextra, TRUE, LSL_ASSIGNMENT_SUBTRACT); } |
62 | "*=" { return common(yylval, yytext, TRUE, LSL_ASSIGNMENT_MULTIPLY); } | 63 | "*=" { return common(yylval, yytext, yyextra, TRUE, LSL_ASSIGNMENT_MULTIPLY); } |
63 | "%=" { return common(yylval, yytext, TRUE, LSL_ASSIGNMENT_MODULO); } | 64 | "%=" { return common(yylval, yytext, yyextra, TRUE, LSL_ASSIGNMENT_MODULO); } |
64 | "/=" { return common(yylval, yytext, TRUE, LSL_ASSIGNMENT_DIVIDE); } | 65 | "/=" { return common(yylval, yytext, yyextra, TRUE, LSL_ASSIGNMENT_DIVIDE); } |
65 | "=" { return common(yylval, yytext, TRUE, LSL_ASSIGNMENT_PLAIN); } | 66 | "=" { return common(yylval, yytext, yyextra, TRUE, LSL_ASSIGNMENT_PLAIN); } |
66 | "." { return common(yylval, yytext, TRUE, LSL_DOT); } | 67 | "." { return common(yylval, yytext, yyextra, TRUE, LSL_DOT); } |
67 | "--" { return common(yylval, yytext, TRUE, LSL_DECREMENT_PRE); } | 68 | "--" { return common(yylval, yytext, yyextra, TRUE, LSL_DECREMENT_PRE); } |
68 | "++" { return common(yylval, yytext, TRUE, LSL_INCREMENT_PRE); } | 69 | "++" { return common(yylval, yytext, yyextra, TRUE, LSL_INCREMENT_PRE); } |
69 | "," { return common(yylval, yytext, TRUE, LSL_COMMA); } | 70 | "," { return common(yylval, yytext, yyextra, TRUE, LSL_COMMA); } |
70 | 71 | ||
71 | /* Types. */ | 72 | /* Types. */ |
72 | {INTEGER} %{ yylval->value.integerValue = atoi(yytext); return common(yylval, yytext, TRUE, LSL_INTEGER); %} | 73 | {INTEGER} %{ yylval->value.integerValue = atoi(yytext); return common(yylval, yytext, yyextra, TRUE, LSL_INTEGER); %} |
73 | {FLOAT} %{ yylval->value.floatValue = atof(yytext); return common(yylval, yytext, TRUE, LSL_FLOAT); %} | 74 | {FLOAT} %{ yylval->value.floatValue = atof(yytext); return common(yylval, yytext, yyextra, TRUE, LSL_FLOAT); %} |
74 | 75 | ||
75 | /* Type keywords. */ | 76 | /* Type keywords. */ |
76 | "float" %{ return common(yylval, yytext, TRUE, LSL_TYPE_FLOAT); %} | 77 | "float" %{ return common(yylval, yytext, yyextra, TRUE, LSL_TYPE_FLOAT); %} |
77 | "integer" %{ return common(yylval, yytext, TRUE, LSL_TYPE_INTEGER); %} | 78 | "integer" %{ return common(yylval, yytext, yyextra, TRUE, LSL_TYPE_INTEGER); %} |
78 | "key" %{ return common(yylval, yytext, TRUE, LSL_TYPE_KEY); %} | 79 | "key" %{ return common(yylval, yytext, yyextra, TRUE, LSL_TYPE_KEY); %} |
79 | "list" %{ return common(yylval, yytext, TRUE, LSL_TYPE_LIST); %} | 80 | "list" %{ return common(yylval, yytext, yyextra, TRUE, LSL_TYPE_LIST); %} |
80 | "quaternion" %{ return common(yylval, yytext, TRUE, LSL_TYPE_ROTATION); %} | 81 | "quaternion" %{ return common(yylval, yytext, yyextra, TRUE, LSL_TYPE_ROTATION); %} |
81 | "rotation" %{ return common(yylval, yytext, TRUE, LSL_TYPE_ROTATION); %} | 82 | "rotation" %{ return common(yylval, yytext, yyextra, TRUE, LSL_TYPE_ROTATION); %} |
82 | "string" %{ return common(yylval, yytext, TRUE, LSL_TYPE_STRING); %} | 83 | "string" %{ return common(yylval, yytext, yyextra, TRUE, LSL_TYPE_STRING); %} |
83 | "vector" %{ return common(yylval, yytext, TRUE, LSL_TYPE_VECTOR); %} | 84 | "vector" %{ return common(yylval, yytext, yyextra, TRUE, LSL_TYPE_VECTOR); %} |
84 | 85 | ||
85 | /* Statement keywords. */ | 86 | /* Statement keywords. */ |
86 | "do" %{ return common(yylval, yytext, TRUE, LSL_DO); %} | 87 | "do" %{ return common(yylval, yytext, yyextra, TRUE, LSL_DO); %} |
87 | "for" %{ return common(yylval, yytext, TRUE, LSL_FOR); %} | 88 | "for" %{ return common(yylval, yytext, yyextra, TRUE, LSL_FOR); %} |
88 | "else" %{ return common(yylval, yytext, TRUE, LSL_ELSE); %} | 89 | "else" %{ return common(yylval, yytext, yyextra, TRUE, LSL_ELSE); %} |
89 | "if" %{ return common(yylval, yytext, TRUE, LSL_IF); %} | 90 | "if" %{ return common(yylval, yytext, yyextra, TRUE, LSL_IF); %} |
90 | "jump" %{ return common(yylval, yytext, TRUE, LSL_JUMP); %} | 91 | "jump" %{ return common(yylval, yytext, yyextra, TRUE, LSL_JUMP); %} |
91 | "return" %{ return common(yylval, yytext, TRUE, LSL_RETURN); %} | 92 | "return" %{ return common(yylval, yytext, yyextra, TRUE, LSL_RETURN); %} |
92 | "state" %{ return common(yylval, yytext, TRUE, LSL_STATE_CHANGE); %} | 93 | "state" %{ return common(yylval, yytext, yyextra, TRUE, LSL_STATE_CHANGE); %} |
93 | "while" %{ return common(yylval, yytext, TRUE, LSL_WHILE); %} | 94 | "while" %{ return common(yylval, yytext, yyextra, TRUE, LSL_WHILE); %} |
94 | 95 | ||
95 | {IDENTIFIER} %{ /* yylval->value.identifierValue = strdup(yytext); */ common(yylval, yytext, TRUE, LSL_IDENTIFIER); %} | 96 | {IDENTIFIER} %{ /* yylval->value.identifierValue = strdup(yytext); */ common(yylval, yytext, yyextra, TRUE, LSL_IDENTIFIER); %} |
96 | 97 | ||
97 | /* Other symbols. */ | 98 | /* Other symbols. */ |
98 | "@" %{ return common(yylval, yytext, TRUE, LSL_LABEL); %} | 99 | "@" %{ return common(yylval, yytext, yyextra, TRUE, LSL_LABEL); %} |
99 | "{" %{ return common(yylval, yytext, TRUE, LSL_BLOCK_OPEN); %} | 100 | "{" %{ return common(yylval, yytext, yyextra, TRUE, LSL_BLOCK_OPEN); %} |
100 | "}" %{ return common(yylval, yytext, TRUE, LSL_BLOCK_CLOSE); %} | 101 | "}" %{ return common(yylval, yytext, yyextra, TRUE, LSL_BLOCK_CLOSE); %} |
101 | ";" %{ return common(yylval, yytext, TRUE, LSL_STATEMENT); %} | 102 | ";" %{ return common(yylval, yytext, yyextra, TRUE, LSL_STATEMENT); %} |
102 | 103 | ||
103 | <<EOF>> { return common(yylval, yytext, TRUE, LSL_SCRIPT); } | 104 | <<EOF>> { return common(yylval, yytext, yyextra, TRUE, LSL_SCRIPT); } |
104 | 105 | ||
105 | /* Everything else */ | 106 | /* Everything else */ |
106 | . %{ printf(" unexpected character.\n"); yylval->value.unknownValue = strdup(yytext); common(yylval, yytext, TRUE, LSL_UNKNOWN); %} | 107 | . %{ printf(" unexpected character.\n"); yylval->value.unknownValue = strdup(yytext); common(yylval, yytext, yyextra, TRUE, LSL_UNKNOWN); %} |
107 | 108 | ||
108 | %% | 109 | %% |
109 | 110 | ||
110 | // TODO - this is not reentrant, should make it so. | 111 | int common(YYSTYPE *lval, char *text, LuaSL_yyparseExtra *extra, boolean checkIgnorable, int type) |
111 | static char *ignorableText = NULL; | ||
112 | static int column = 0; | ||
113 | static int line = 0; | ||
114 | |||
115 | int common(YYSTYPE *lval, char *text, boolean checkIgnorable, int type) | ||
116 | { | 112 | { |
117 | int i; | 113 | int i; |
118 | 114 | ||
119 | for (i = 0; text[i] != '\0'; i++) | 115 | for (i = 0; text[i] != '\0'; i++) |
120 | if (text[i] == '\n') | 116 | if (text[i] == '\n') |
121 | { | 117 | { |
122 | column = 0; | 118 | extra->column = 0; |
123 | line++; | 119 | extra->line++; |
124 | } | 120 | } |
125 | else if (text[i] == '\t') | 121 | else if (text[i] == '\t') |
126 | column += 8 - (column % 8); | 122 | extra->column += 8 - (extra->column % 8); |
127 | else | 123 | else |
128 | column++; | 124 | extra->column++; |
129 | 125 | ||
130 | lval->token = tokens[type - lowestToken]; | 126 | lval->token = tokens[type - lowestToken]; |
131 | lval->line = line; | 127 | lval->line = extra->line; |
132 | lval->column = column; | 128 | lval->column = extra->column; |
133 | 129 | ||
134 | if (checkIgnorable) | 130 | if (checkIgnorable) |
135 | { | 131 | { |
136 | lval->ignorableText = ignorableText; | 132 | lval->ignorableText = extra->ignorableText; |
137 | ignorableText = NULL; | 133 | extra->ignorableText = NULL; |
138 | } | 134 | } |
139 | else | 135 | else |
140 | { | 136 | { |
141 | if (ignorableText) | 137 | if (extra->ignorableText) |
142 | { | 138 | { |
143 | int lenI = strlen(ignorableText); | 139 | int lenI = strlen(extra->ignorableText); |
144 | int lenT = strlen(text); | 140 | int lenT = strlen(text); |
145 | 141 | ||
146 | ignorableText = realloc(ignorableText, lenI + lenT + 1); | 142 | extra->ignorableText = realloc(extra->ignorableText, lenI + lenT + 1); |
147 | sprintf(&ignorableText[lenI], "%s", text); | 143 | sprintf(&(extra->ignorableText[lenI]), "%s", text); |
148 | } | 144 | } |
149 | else | 145 | else |
150 | ignorableText = strdup(text); | 146 | extra->ignorableText = strdup(text); |
151 | } | 147 | } |
152 | 148 | ||
153 | return type; | 149 | return type; |
154 | } | 150 | } |
155 | 151 | ||
156 | int yyerror(const char *msg) | ||
157 | { | ||
158 | fprintf(stderr, "Parser error on line %d, column %d: %s\n", line, column, msg); | ||
159 | return 0; | ||
160 | } | ||
161 | |||
162 | int yywrap(yyscan_t yyscanner) | 152 | int yywrap(yyscan_t yyscanner) |
163 | { | 153 | { |
164 | #ifdef FLEX_SCANNER | 154 | #ifdef FLEX_SCANNER |