module languages/cpp/syntax/Macros imports languages/cpp/syntax/Text languages/cpp/syntax/Replacement exports context-free syntax %% Constants Id -> CId "#" "define" id:CId replacement:Replacement? NewLine -> Line {cons("def-const")} %% the prefer is needed because there can be comments %% instead of a real replacement, which is recognized %% as a replacement, and thus an ambiguity arises. "#" "define" id:CId NewLine -> Line {cons("def-const"),prefer} %% Macros Id -> FId id:FId "(" args:{Id ","}* ")" -> Signature {cons("fix-args")} id:FId "(" args:{Id ","}+ "," "..." ")" -> Signature {cons("fix-var-args")} id:FId "(" "..." ")" -> Signature {cons("var-args")} "#" "define" signature:Signature replacement:Replacement? NewLine -> Line {cons("def-macro")} "#" "undef" id:Id NewLine -> Line {cons("undef")} context-free restrictions CId -/- [\(] FId -/- [\t\ ]