Skip to content
Snippets Groups Projects
Commit 86a08f54 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

macroprocessor: support multi-line comments. #4

parent 066942ef
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,8 @@ using token = Macro::parser::token; ...@@ -41,6 +41,8 @@ using token = Macro::parser::token;
Unfortunately yyterminate by default returns 0, which is Unfortunately yyterminate by default returns 0, which is
not of token_type. */ not of token_type. */
#define yyterminate() return Macro::parser::token_type (0); #define yyterminate() return Macro::parser::token_type (0);
int macro_comment_caller;
%} %}
%option c++ %option c++
...@@ -49,6 +51,7 @@ using token = Macro::parser::token; ...@@ -49,6 +51,7 @@ using token = Macro::parser::token;
%option case-insensitive noyywrap nounput batch debug never-interactive %option case-insensitive noyywrap nounput batch debug never-interactive
%x COMMENT
%x STMT %x STMT
%x EXPR %x EXPR
%x FOR_BODY %x FOR_BODY
...@@ -74,6 +77,9 @@ CONT \\\\ ...@@ -74,6 +77,9 @@ CONT \\\\
// Ignore inline comments // Ignore inline comments
<INITIAL,STMT,EXPR,FOR_BODY,THEN_BODY,ELSE_BODY>%.* { yylloc->step(); ECHO; } <INITIAL,STMT,EXPR,FOR_BODY,THEN_BODY,ELSE_BODY>%.* { yylloc->step(); ECHO; }
<INITIAL,STMT,EXPR,FOR_BODY,THEN_BODY,ELSE_BODY>\/{2}.* { yylloc->step(); ECHO; } <INITIAL,STMT,EXPR,FOR_BODY,THEN_BODY,ELSE_BODY>\/{2}.* { yylloc->step(); ECHO; }
<INITIAL,STMT,EXPR,FOR_BODY,THEN_BODY,ELSE_BODY>"/*" { ECHO; macro_comment_caller = YY_START; BEGIN COMMENT; }
<COMMENT>"*/" { BEGIN macro_comment_caller; ECHO; }
<COMMENT>. { yylloc->step(); ECHO; }
<INITIAL>^{SPC}*@#{SPC}*includepath{SPC}+\"([^\"\r\n:;|<>]*){1}(:[^\"\r\n:;|<>]*)*\"{SPC}*{EOL} { <INITIAL>^{SPC}*@#{SPC}*includepath{SPC}+\"([^\"\r\n:;|<>]*){1}(:[^\"\r\n:;|<>]*)*\"{SPC}*{EOL} {
yylloc->lines(1); yylloc->lines(1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment