(20 lines)
1 # Syntax definition for some C-specific patterns2 #3 # NOTE: this is *NOT* intended to be a complete definition of the language's4 # syntax! Providing a full language grammar is overkill, because the intended5 # use case is finding/replacing string patterns. This task does not require a6 # full parse tree, and having one makes the task considerably more complicated.7 # See the accompanying README.md for more info.9 comment: "//" .. $ / "/*" ..%\n "*/"10 string: `" ..%string-escape `"11 string-escape: `\ (`x 2 Hex / 1-3 `0-7 / .)12 keyword: ("auto" / "break" / "case" / "char" / "const" / "continue" / "default" / "do" /13 "double" / "else" / "enum" / "extern" / "float" / "for" / "goto" / "if" /14 "int" / "long" / "register" / "return" / "short" / "signed" / "sizeof" /15 "static" / "struct" / "switch" / "typedef" / "union" / "unsigned" / "void" /16 "volatile" / "while")17 function-def: ^_ 2+(id / keyword / `*) % __ parens (__`; / >(__`{))18 function: function-def __ braces19 macro: ^"#define"| ..$ *(<`\ \n..$)20 import: ^"#include"| __ (string / `<..`>)