diff options
| -rw-r--r-- | bp.1 | 6 | ||||
| -rw-r--r-- | bp.c | 6 | ||||
| -rw-r--r-- | grammars/builtins.bp | 3 | ||||
| -rw-r--r-- | grammars/c++.bp | 2 | ||||
| -rw-r--r-- | grammars/c.bp | 3 | ||||
| -rw-r--r-- | grammars/go.bp | 2 | ||||
| -rw-r--r-- | grammars/javascript.bp | 2 | ||||
| -rw-r--r-- | grammars/lisp.bp | 2 | ||||
| -rw-r--r-- | grammars/lua.bp | 2 | ||||
| -rw-r--r-- | grammars/python.bp | 2 | ||||
| -rw-r--r-- | grammars/rust.bp | 2 | ||||
| -rw-r--r-- | grammars/shell.bp | 5 |
12 files changed, 21 insertions, 16 deletions
@@ -10,7 +10,7 @@ bp \- Bruce's Parsing Expression Grammar tool [\fI-e\fR|\fI--explain\fR] [\fI-j\fR|\fI--json\fR] [\fI-l\fR|\fI--list-files\fR] -[\fI-i\fR|\fI--ignore-case\fR \fI<pattern>\fR] +[\fI-i\fR|\fI--ignore-case\fR] [\fI-I\fR|\fI--inplace\fR] [\fI-C\fR|\fI--confirm\fR] [\fI-p\fR|\fI--pattern\fR \fI<pattern>\fR] @@ -19,10 +19,12 @@ bp \- Bruce's Parsing Expression Grammar tool [\fI-g\fR|\fI--grammar\fR \fI<grammar file>\fR] [\fI-G\fR|\fI--git\fR] [\fI-c\fR|\fI--context\fR \fI<N>\fR] -\fI<pattern\fR +\fI<pattern>\fR [[--] \fI<input files...>\fR] + .SH DESCRIPTION \fBbp\fR is a tool that matches parsing expression grammars using a custom syntax. + .SH OPTIONS .B \-v\fR, \fB--verbose Print debugging information. @@ -36,7 +36,7 @@ static const char *description = ( BP_NAME" - a Parsing Expression Grammar command line tool"); static const char *usage = ( "Usage:\n" - " "BP_NAME" [flags] <pattern> [<input files>...]\n\n" + " "BP_NAME" [flags] <pattern> [<files>...]\n\n" "Flags:\n" " -h --help print the usage and quit\n" " -v --verbose print verbose debugging info\n" @@ -48,10 +48,10 @@ static const char *usage = ( " -l --list-files list filenames only\n" " -p --pattern <pat> provide a pattern (equivalent to bp '\\(<pat>)')\n" " -r --replace <replacement> replace the input pattern with the given replacement\n" - " -s --skip <skip pattern> skip over the given pattern when looking for matches\n" + " -s --skip <skip-pattern> skip over the given pattern when looking for matches\n" " -c --context <context> set number of lines of context to print (all: the whole file, 0: only the match, 1: the line, N: N lines of context)\n" " -f --format auto|fancy|plain set the output format\n" - " -g --grammar <grammar file> use the specified file as a grammar"); + " -g --grammar <grammar-file> use the specified file as a grammar"); // Used as a heuristic to check if a file is binary or text: #define CHECK_FIRST_N_BYTES 128 diff --git a/grammars/builtins.bp b/grammars/builtins.bp index 8119573..6c0fc75 100644 --- a/grammars/builtins.bp +++ b/grammars/builtins.bp @@ -15,7 +15,8 @@ anglebraces: `< ..%(\n/anglebraces/string) `> brackets: `[ ..%(\n/brackets/string) `] braces: `{ ..%(\n/braces/string) `} parens: `( ..%(\n/parens/string) `) -string: `" ..%(`\.) `" / `' ..%(`\.) `' +string: `" ..%string-escape `" / `' ..%string-escape `' +string-escape: `\ (`x 2 Hex / 1-3 `0-7 / `u 1-4 Hex / .) left-id-edge: ^ / <(\x00-x7f!=id-char) / <((\xc0-xdf \x80-xbf)!=id-char) / <((\xe0-xef 2\x80-xbf)!=id-char) / <((\xf0-xf7 3\x80-xbf)!=id-char) right-id-edge: !id-char diff --git a/grammars/c++.bp b/grammars/c++.bp index a48d5a2..1553bb3 100644 --- a/grammars/c++.bp +++ b/grammars/c++.bp @@ -7,7 +7,7 @@ # See the accompanying README.md for more info. comment: "//" .. $ / "/*" ..%\n "*/" -string: `" ..%(`\.) `" +string: `" ..%string-escape `" keyword: "alignas" / "alignof" / "and" / "and_eq" / "asm" / "atomic_cancel" / "atomic_commit" / "atomic_noexcept" / "auto" / "bitand" / "bitor" / "bool" / "break" / "case" / "catch" / diff --git a/grammars/c.bp b/grammars/c.bp index 2c74c3d..9940ffe 100644 --- a/grammars/c.bp +++ b/grammars/c.bp @@ -7,7 +7,8 @@ # See the accompanying README.md for more info. comment: "//" .. $ / "/*" ..%\n "*/" -string: `" ..%(`\.) `" +string: `" ..%string-escape `" +string-escape: `\ (`x 2 Hex / 1-3 `0-7 / .) keyword: "auto" / "break" / "case" / "char" / "const" / "continue" / "default" / "do" / "double" / "else" / "enum" / "extern" / "float" / "for" / "goto" / "if" / diff --git a/grammars/go.bp b/grammars/go.bp index c9f7377..71114cf 100644 --- a/grammars/go.bp +++ b/grammars/go.bp @@ -7,7 +7,7 @@ # See the accompanying README.md for more info. comment: "//" .. $ / "/*" ..%\n "*/" -string: `" ..%(`\.) `" +string: `" ..%string-escape `" keyword: "break" / "default" / "func" / "interface" / "select" / "case" / "defer" / "go" / "map" / "struct" / "chan" / "else" / "goto" / "package" / "switch" / "const" / diff --git a/grammars/javascript.bp b/grammars/javascript.bp index fdd76a1..76fa586 100644 --- a/grammars/javascript.bp +++ b/grammars/javascript.bp @@ -7,7 +7,7 @@ # See the accompanying README.md for more info. comment: "//" .. $ / "/*" ..%\n "*/" -string: `" ..%(`\.) `" / `' ..%(`\.) `' / `/ ..%(`\.) `/ +string: `" ..%string-escape `" / `' ..%string-escape `' / `/ ..%string-escape `/ keyword: "abstract" / "arguments" / "await" / "boolean" / "break" / "byte" / "case" / "catch" / "char" / "class" / "const" / "continue" / "debugger" / "default" / diff --git a/grammars/lisp.bp b/grammars/lisp.bp index d02a458..b7b89ed 100644 --- a/grammars/lisp.bp +++ b/grammars/lisp.bp @@ -7,7 +7,7 @@ # See the accompanying README.md for more info. comment: ";" ..$ -string: `" ..%(`\.) `" +string: `" ..%string-escape `" list: parens function-def: `(__{defun}__id function: function-def ..%parens `) diff --git a/grammars/lua.bp b/grammars/lua.bp index 6967f1e..562b44a 100644 --- a/grammars/lua.bp +++ b/grammars/lua.bp @@ -7,7 +7,7 @@ # See the accompanying README.md for more info. comment: "--" (`[ @eqs=*`= `[ ..%\n (`]eqs`]) / ..$) -string: `"..%(`\.) `" / `' ..%(`\.) `' / `[ @eqs=*`= `[ ..%\n (`]eqs`]) +string: `"..%string-escape `" / `' ..%string-escape `' / `[ @eqs=*`= `[ ..%\n (`]eqs`]) table: `{ ..%(table/string/comment/\n) `} keyword: "and" / "break" / "do" / "else" / "elseif" / "end" / "false" / "for" / diff --git a/grammars/python.bp b/grammars/python.bp index 37d6a88..cb5d047 100644 --- a/grammars/python.bp +++ b/grammars/python.bp @@ -7,7 +7,7 @@ # See the accompanying README.md for more info. comment: `# ..$ -string: "'''" ..%\n "'''" / '"""' ..%\n '"""' / `" ..%(`\.) `" / `' ..%(`\.) `' +string: "'''" ..%\n "'''" / '"""' ..%\n '"""' / `" ..%string-escape `" / `' ..%string-escape `' keyword: "and" / "as" / "assert" / "break" / "class" / "continue" / "def" / "del" / "elif" / "else" / "except" / "finally" / "for" / "from" / "global" / "if" / "import" / "in" / "is" / "lambda" / "None" / "nonlocal" / diff --git a/grammars/rust.bp b/grammars/rust.bp index 97a1e73..108b41a 100644 --- a/grammars/rust.bp +++ b/grammars/rust.bp @@ -7,7 +7,7 @@ # See the accompanying README.md for more info. comment: "//" .. $ / "/*" ..%(comment / \n) "*/" -string: `" ..%(`\.) `" +string: `" ..%string-escape `" keyword: "as" / "break" / "const" / "continue" / "crate" / "else" / "enum" / "extern" / "false" / "fn" / "for" / "if" / "impl" / "in" / "let" / "loop" / "match" / diff --git a/grammars/shell.bp b/grammars/shell.bp index ff13d0b..72b83cc 100644 --- a/grammars/shell.bp +++ b/grammars/shell.bp @@ -7,8 +7,9 @@ # See the accompanying README.md for more info. comment: `#..$ -string: `" ..%(`\./subcommand/\n) `" / `' ..%\n `' / "<<" _ @delim=id _$ ..%\n (^delim$) -subcommand: `` ..%\n `` / "$" parens +string: `" ..%(string-escape / subcommand / \n) `" / `' ..%\n `' / "<<" _ @delim=id _$ ..%\n (^delim$) +string-escape: `\ `",` +subcommand: `` ..%\n `` / "$" (parens/braces) keyword: "echo" / "read" / "set" / "unset" / "readonly" / "shift" / "export" / "if" / "fi" / "else" / "while" / "do" / "done" / "for" / "until" / "case" / "esac" / "break" / |
