diff --git a/tools/wpp/ppl.l b/tools/wpp/ppl.l index b8716269f5e..fe2dddcafa8 100644 --- a/tools/wpp/ppl.l +++ b/tools/wpp/ppl.l @@ -143,6 +143,7 @@ %x pp_macexp %x pp_if %x pp_ifd +%x pp_endif %x pp_line %x pp_defined %x pp_ignore @@ -321,8 +322,8 @@ includelogicentry_t *pp_includelogiclist = NULL; {ws}*ifndef{ws}* pp_incl_state.seen_junk--; yy_pp_state(pp_ifd); return tIFNDEF; {ws}*if{ws}* yy_pp_state(pp_if); return tIF; {ws}*elif{ws}* yy_pp_state(pp_if); return tELIF; -{ws}*else{ws}* return tELSE; -{ws}*endif{ws}* return tENDIF; +{ws}*else{ws}* yy_pp_state(pp_endif); return tELSE; +{ws}*endif{ws}* yy_pp_state(pp_endif); return tENDIF; {ws}*line{ws}* if(yy_top_state() != pp_ignore) {yy_pp_state(pp_line); return tLINE;} else {yy_pp_state(pp_eol);} {ws}+ if(yy_top_state() != pp_ignore) {yy_pp_state(pp_line); return tGCCLINE;} else {yy_pp_state(pp_eol);} {ws}*[a-z]+ pperror("Invalid preprocessor token '%s'", pptext); @@ -389,6 +390,14 @@ includelogicentry_t *pp_includelogiclist = NULL; \\\r?\n newline(0); (\\\r?)|(.) pperror("Identifier expected"); + /* + * Handle #else and #endif. + */ +{ws}+ ; +\n newline(1); yy_pop_state(); return tNL; +\\\r?\n newline(0); +. pperror("Garbage after #else or #endif."); + /* * Handle the special 'defined' keyword. * This is necessary to get the identifier prior to any @@ -514,7 +523,7 @@ includelogicentry_t *pp_includelogiclist = NULL; /* * Comment handling (almost all start-conditions) */ -"/*" yy_push_state(pp_comment); +"/*" yy_push_state(pp_comment); [^*\n]*|"*"+[^*/\n]* ; \n newline(0); "*"+"/" yy_pop_state();