cppo
cppo copied to clipboard
'Invalid macro application' from unbalanced parentheses in comment
This seems to have been caused by the parser changes in 1.3.0. Minimal repro:
a(* ( *)
Here's the error message.
$ cppo main.ml
Error: File "main.ml", line 1, characters 0-2
Error: Invalid macro application
The lack of a space before the opening parenthesis of the comment is significant: when added, this parses.
Thanks for reporting the issue.
The immediate workaround is to place a space before the comment.
a( is parsed as a single token, unlike a (, and won't identify the beginning of a comment. We could introduce a new rule that would identify a(* as a single token and return a followed by a comment. It may break existing code that contains something like a(*) although this is discouraged in favor of a( * ). Perhaps we could produce a warning or an error message that gives a tentative solution.
Maybe the warning could appear in the a(*) case, since that's the one you're discouraging. Anyway, thanks for the suggestion, we'll just use the workaround for now.