summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse/parse_c/bitbakescanner.l
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/parse/parse_c/bitbakescanner.l')
-rw-r--r--bitbake/lib/bb/parse/parse_c/bitbakescanner.l67
1 files changed, 48 insertions, 19 deletions
diff --git a/bitbake/lib/bb/parse/parse_c/bitbakescanner.l b/bitbake/lib/bb/parse/parse_c/bitbakescanner.l
index 782bc57a0f..f69a7325c3 100644
--- a/bitbake/lib/bb/parse/parse_c/bitbakescanner.l
+++ b/bitbake/lib/bb/parse/parse_c/bitbakescanner.l
@@ -83,6 +83,7 @@ extern void bbparseTrace(FILE *TraceFILE, char *zTracePrompt);
83//static const char* rgbInput; 83//static const char* rgbInput;
84//static size_t cbInput; 84//static size_t cbInput;
85 85
86extern "C" {
86 87
87int lineError; 88int lineError;
88int errorParse; 89int errorParse;
@@ -93,6 +94,8 @@ enum {
93 errorUnsupportedFeature, 94 errorUnsupportedFeature,
94}; 95};
95 96
97}
98
96#define YY_EXTRA_TYPE lex_t* 99#define YY_EXTRA_TYPE lex_t*
97 100
98 /* Read from buffer */ 101 /* Read from buffer */
@@ -112,6 +115,8 @@ static const char* fixup_escapes (const char* sz);
112C_SP [ \t] 115C_SP [ \t]
113COMMENT #.*\n 116COMMENT #.*\n
114OP_ASSIGN "=" 117OP_ASSIGN "="
118OP_PREDOT ".="
119OP_POSTDOT "=."
115OP_IMMEDIATE ":=" 120OP_IMMEDIATE ":="
116OP_PREPEND "=+" 121OP_PREPEND "=+"
117OP_APPEND "+=" 122OP_APPEND "+="
@@ -166,6 +171,10 @@ PROC \({C_SP}*\)
166 yyextra->accept (T_OP_IMMEDIATE); } 171 yyextra->accept (T_OP_IMMEDIATE); }
167{OP_ASSIGN} { BEGIN S_RVALUE; 172{OP_ASSIGN} { BEGIN S_RVALUE;
168 yyextra->accept (T_OP_ASSIGN); } 173 yyextra->accept (T_OP_ASSIGN); }
174{OP_PREDOT} { BEGIN S_RVALUE;
175 yyextra->accept (T_OP_PREDOT); }
176{OP_POSTDOT} { BEGIN S_RVALUE;
177 yyextra->accept (T_OP_POSTDOT); }
169{OP_COND} { BEGIN S_RVALUE; 178{OP_COND} { BEGIN S_RVALUE;
170 yyextra->accept (T_OP_COND); } 179 yyextra->accept (T_OP_COND); }
171 180
@@ -254,35 +263,55 @@ void lex_t::accept (int token, const char* sz)
254 parse (parser, token, t, this); 263 parse (parser, token, t, this);
255} 264}
256 265
266void lex_t::input (char *buf, int *result, int max_size)
267{
268 printf("lex_t::input %p %d\n", buf, max_size);
269 *result = fread(buf, 1, max_size, file);
270 printf("lex_t::input result %d\n", *result);
271}
272
257int lex_t::line ()const 273int lex_t::line ()const
258{ 274{
275 printf("lex_t::line\n");
259 return yyget_lineno (scanner); 276 return yyget_lineno (scanner);
260} 277}
261 278
262void parse (FILE* file, PyObject* data)
263{
264 void* parser = bbparseAlloc (malloc);
265 yyscan_t scanner;
266 lex_t lex;
267 279
268 yylex_init (&scanner); 280extern "C" {
281
282 void parse (FILE* file, PyObject* data)
283 {
284 printf("parse bbparseAlloc\n");
285 void* parser = bbparseAlloc (malloc);
286 yyscan_t scanner;
287 lex_t lex;
288
289 printf("parse yylex_init\n");
290 yylex_init (&scanner);
269 291
270 lex.parser = parser; 292 lex.parser = parser;
271 lex.scanner = scanner; 293 lex.scanner = scanner;
272 lex.file = file; 294 lex.file = file;
273 lex.data = data; 295 lex.data = data;
274 lex.parse = bbparse; 296 lex.parse = bbparse;
275 yyset_extra (&lex, scanner); 297 printf("parse yyset_extra\n");
298 yyset_extra (&lex, scanner);
276 299
300 printf("parse yylex\n");
301 int result = yylex (scanner);
302
303 printf("parse result %d\n", result);
277 304
278 int result = yylex (scanner); 305 lex.accept (0);
306 printf("parse lex.accept\n");
307 bbparseTrace (NULL, NULL);
308 printf("parse bbparseTrace\n");
279 309
280 lex.accept (0); 310 if (result != T_EOF)
281 bbparseTrace (NULL, NULL); 311 printf ("premature end of file\n");
282 312
283 if (result != T_EOF) 313 yylex_destroy (scanner);
284 printf ("premature end of file\n"); 314 bbparseFree (parser, free);
315 }
285 316
286 yylex_destroy (scanner);
287 bbparseFree (parser, free);
288} 317}