Comments not allowed embedded within function definitions
cscott opened this issue · comments
C. Scott Ananian commented
This works as you'd expect:
define TEST2 [ a
! test
|
# test2
b ! t
! test3
| c # test4
];
(That is, TEST2 is equivalent to a|b|c
.)
But this doesn't:
define TEST3(x) [ a
! test
|
# test2
b ! t
! test3
| c # test4
];
The issue seems to be that interface.l
is parsing the latter with <FUNC_4>
instead of <REGEX>
, and <FUNC_4>
is missing the lines which recognize and remove embedded comments. I think this should fix the problem:
diff --git a/foma/interface.l b/foma/interface.l
index c2129b5..8871cf2 100644
--- a/foma/interface.l
+++ b/foma/interface.l
@@ -419,6 +419,7 @@ NOSPEQ [\001-\177]{-}[\040\041\043\075]|[\300-\337].|[\340-\357]..|[\360-\36
<FUNC_4>{BRACED} { strcat(funcdef, interfacetext); }
<FUNC_4>%{ANY} { strcat(funcdef, interfacetext); }
<FUNC_4>{QUOTED} { strcat(funcdef, interfacetext); }
+<FUNC_4>(#|!).* { }
<FUNC_4>; { strcat(funcdef, interfacetext); add_defined_function(g_defines_f, func_name, funcdef, (func_arg_no-1));clear_func_args(); xxfree(func_name); BEGIN(INITIAL); }
<FUNC_4>.|\.#\. { strcat(funcdef, interfacetext); }
C. Scott Ananian commented
Patch at 10b30be