From cce08337c6793f57e1216c853e781ed344d6ccf5 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 8 Feb 2020 20:45:13 +0000 Subject: [PATCH] Fix for GitHub issue #309 - allow braced expressions as macro arguments. As for parentheses, we need to ignore commas within a pair of braces when parsing a macro argument, e.g. `MACRO({a,b}) has one argument. This fix is a little crude in that it doesn't distinguish between parentheses and braces, e.g. it will accept {a,b). But any errors like that will be caught by the compiler proper. (cherry picked from commit fb29da0bd8bc6d0d7e8bcb43d7e3267cb5dc407d) --- ivlpp/lexor.lex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 56e90c79d..51de21223 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -1,7 +1,7 @@ %option prefix="yy" %{ /* - * Copyright (c) 1999-2016 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2020 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -575,7 +575,7 @@ keywords (include|define|undef|ifdef|ifndef|else|elseif|endif) {W} { macro_add_to_arg(1); } -"(" { macro_add_to_arg(0); ma_parenthesis_level++; } +[({] { macro_add_to_arg(0); ma_parenthesis_level++; } "," { if (ma_parenthesis_level > 0) @@ -584,7 +584,7 @@ keywords (include|define|undef|ifdef|ifndef|else|elseif|endif) macro_finish_arg(); } -")" { +[)}] { if (ma_parenthesis_level > 0) { macro_add_to_arg(0); ma_parenthesis_level--;