From ef0d653ea75ed9ad41ca03bfb5ff2aa24f45b440 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 14 Feb 2004 16:47:13 +0000 Subject: [PATCH] Handle function pointer arguments in expressions. --- mad | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mad b/mad index c0ab70d..a9481c5 100755 --- a/mad +++ b/mad @@ -56,6 +56,7 @@ for r in reserved: def t_STRING(t): r'\$[^$]*\$' t.value = t.value[1:-1] + t.value = re.sub("\n\s*", "", t.value) return t def t_FUNCALL(t): @@ -695,6 +696,8 @@ def prinC1(t): for dim in t[2]: res += '[' + print_C_expr(dim) + ']' return res + elif t[0] == 'funptr': + return t[1] elif t[0] == 'apply': madfunc = t[1][:-1] return madfunc_map.get(madfunc, madfunc) + '(' + ', '.join(map(prinC1, t[2])) + ')' @@ -1073,7 +1076,7 @@ if __name__ == '__main__': # Put them after every newline, then remove if they're followed # by whitespace and a continuation digit source = source.replace("\n", " eos\n") - source = re.sub('eos\n(\s*)[0-9]+', '\n\\1', source) + source = re.sub('eos\n(\s*)[0-9]+\s*', '\n\\1', source) # Transform some adjacent groups of keywords into # agglomerates. This lets us get away with stuff like SET LIST # TO LIST that the parser would otherwise choke on, because -- 2.43.0