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.
This commit is contained in:
Martin Whitaker 2020-02-08 20:45:13 +00:00
parent 97edccceab
commit fb29da0bd8
1 changed files with 3 additions and 3 deletions

View File

@ -1,7 +1,7 @@
%option prefix="yy"
%{
/*
* Copyright (c) 1999-2017 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)
<MA_ADD>{W} { macro_add_to_arg(1); }
<MA_ADD>"(" { macro_add_to_arg(0); ma_parenthesis_level++; }
<MA_ADD>[({] { macro_add_to_arg(0); ma_parenthesis_level++; }
<MA_ADD>"," {
if (ma_parenthesis_level > 0)
@ -584,7 +584,7 @@ keywords (include|define|undef|ifdef|ifndef|else|elseif|endif)
macro_finish_arg();
}
<MA_ADD>")" {
<MA_ADD>[)}] {
if (ma_parenthesis_level > 0) {
macro_add_to_arg(0);
ma_parenthesis_level--;