cppo icon indicating copy to clipboard operation
cppo copied to clipboard

'Invalid macro application' from unbalanced parentheses in comment

Open dariusf opened this issue 9 years ago • 2 comments
trafficstars

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.

dariusf avatar Mar 09 '16 02:03 dariusf

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.

mjambon avatar Mar 09 '16 03:03 mjambon

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.

dariusf avatar Mar 12 '16 02:03 dariusf