diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-01-17 19:42:11 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-01-17 19:42:11 -0800 |
| commit | 51313c4773f0af62121b2192ff0cca9560b7ab44 (patch) | |
| tree | 5873f54aafe2cd537e286a88b368ba0315d3e15d /grammars/c.bp | |
| parent | 23f9b7ade9eccc6aee2e6c2a6737630a9d0cc77d (diff) | |
Adding more language grammars
Diffstat (limited to 'grammars/c.bp')
| -rw-r--r-- | grammars/c.bp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/grammars/c.bp b/grammars/c.bp new file mode 100644 index 0000000..2b2e1d9 --- /dev/null +++ b/grammars/c.bp @@ -0,0 +1,23 @@ +# Syntax definition for some C-specific patterns +# +# NOTE: this is *NOT* intended to be a complete definition of the language's +# syntax! Providing a full language grammar is overkill, because the intended +# use case is finding/replacing string patterns. This task does not require a +# full parse tree, and having one makes the task considerably more complicated. +# See the accompanying README.md for more info. + +comment: "//" .. $ / "/*" .. "*/" % \n +string: `"..`" % (`\.) +char: `' [`\] . `' +array: `{..`} % (array/comment/\n) +struct: array +keyword: |( + "auto" / "break" / "case" / "char" / "const" / "continue" / "default" / "do" / + "double" / "else" / "enum" / "extern" / "float" / "for" / "goto" / "if" / + "int" / "long" / "register" / "return" / "short" / "signed" / "sizeof" / + "static" / "struct" / "switch" / "typedef" / "union" / "unsigned" / "void" / + "volatile" / "while" +)| +function-def: ^_ 2+(keyword / id / `*) % __ parens (__`; / >(__`{)) +function: function-def __ braces +macro: ^"#define " ..$ *(<`\ \n..$) |
