Skip to content

Commit

Permalink
grammar: Allow pipe character | in unquoted strings (#1850)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasha10 committed Oct 22, 2021
1 parent ac1b6bf commit 949ad62
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion hydra/grammar/OverrideLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ BOOL:

NULL: [Nn][Uu][Ll][Ll];

UNQUOTED_CHAR: [/\-\\+.$%*@?]; // other characters allowed in unquoted strings
UNQUOTED_CHAR: [/\-\\+.$%*@?|]; // other characters allowed in unquoted strings
ID: (CHAR|'_') (CHAR|DIGIT|'_')*;
// Note: when adding more characters to the ESC rule below, also add them to
// the `_ESC` string in `_internal/grammar/utils.py`.
Expand Down
4 changes: 2 additions & 2 deletions hydra/grammar/OverrideParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ primitive:
| FLOAT // 3.14, -20.0, 1e-1, -10e3
| BOOL // true, TrUe, false, False
| INTERPOLATION // ${foo.bar}, ${oc.env:USER,me}
| UNQUOTED_CHAR // /, -, \, +, ., $, %, *, @, ?
| UNQUOTED_CHAR // /, -, \, +, ., $, %, *, @, ?, |
| COLON // :
| ESC // \\, \(, \), \[, \], \{, \}, \:, \=, \ , \\t, \,
| WS // whitespaces
Expand All @@ -72,7 +72,7 @@ dictKey:
| INT // 0, 10, -20, 1_000_000
| FLOAT // 3.14, -20.0, 1e-1, -10e3
| BOOL // true, TrUe, false, False
| UNQUOTED_CHAR // /, -, \, +, ., $, %, *, @, ?
| UNQUOTED_CHAR // /, -, \, +, ., $, %, *, @, ?, |
| ESC // \\, \(, \), \[, \], \{, \}, \:, \=, \ , \\t, \,
| WS // whitespaces
)+;
1 change: 1 addition & 0 deletions news/1850.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enable the use of the pipe symbol `|` in unquoted strings when parsing command-line overrides.
2 changes: 1 addition & 1 deletion tests/test_overrides_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)
from hydra.errors import HydraException

UNQUOTED_SPECIAL = r"/-\+.$%*@?" # special characters allowed in unquoted strings
UNQUOTED_SPECIAL = r"/-\+.$%*@?|" # special characters allowed in unquoted strings

parser = OverridesParser(create_functions())

Expand Down
4 changes: 2 additions & 2 deletions website/docs/advanced/override_grammar/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ primitive:
| FLOAT // 3.14, -20.0, 1e-1, -10e3
| BOOL // true, TrUe, false, False
| INTERPOLATION // ${foo.bar}, ${oc.env:USER,me}
| UNQUOTED_CHAR // /, -, \, +, ., $, %, *, @, ?
| UNQUOTED_CHAR // /, -, \, +, ., $, %, *, @, ?, |
| COLON // :
| ESC // \\, \(, \), \[, \], \{, \}, \:, \=, \ , \\t, \,
| WS // whitespaces
Expand All @@ -97,7 +97,7 @@ dictKey:
| INT // 0, 10, -20, 1_000_000
| FLOAT // 3.14, -20.0, 1e-1, -10e3
| BOOL // true, TrUe, false, False
| UNQUOTED_CHAR // /, -, \, +, ., $, %, *, @, ?
| UNQUOTED_CHAR // /, -, \, +, ., $, %, *, @, ?, |
| ESC // \\, \(, \), \[, \], \{, \}, \:, \=, \ , \\t, \,
| WS // whitespaces
)+;
Expand Down

0 comments on commit 949ad62

Please sign in to comment.