mhulden / foma

Automatically exported from code.google.com/p/foma
115 stars 90 forks source link

Comments not allowed embedded within function definitions #75

Open cscott opened 6 years ago

cscott commented 6 years ago

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); }
cscott commented 6 years ago

Patch at 10b30be34359b8e7950b2a0c3566490fe0e80bc7