From 86a08f54aedbd401929790e7b25bb150486190d2 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Mon, 9 Jul 2018 16:55:08 +0200
Subject: [PATCH] macroprocessor: support multi-line comments. #4

---
 src/macro/MacroFlex.ll | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/macro/MacroFlex.ll b/src/macro/MacroFlex.ll
index b33411c2..96905460 100644
--- a/src/macro/MacroFlex.ll
+++ b/src/macro/MacroFlex.ll
@@ -41,6 +41,8 @@ using token = Macro::parser::token;
    Unfortunately yyterminate by default returns 0, which is
    not of token_type.  */
 #define yyterminate() return Macro::parser::token_type (0);
+
+int macro_comment_caller;
 %}
 
 %option c++
@@ -49,6 +51,7 @@ using token = Macro::parser::token;
 
 %option case-insensitive noyywrap nounput batch debug never-interactive
 
+%x COMMENT
 %x STMT
 %x EXPR
 %x FOR_BODY
@@ -74,6 +77,9 @@ CONT \\\\
  // Ignore inline comments
 <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>"/*"    { 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} {
                               yylloc->lines(1);
-- 
GitLab