diff --git a/omegaconf/grammar/OmegaConfGrammarLexer.g4 b/omegaconf/grammar/OmegaConfGrammarLexer.g4 index 30c9458fe..f7ab2044a 100644 --- a/omegaconf/grammar/OmegaConfGrammarLexer.g4 +++ b/omegaconf/grammar/OmegaConfGrammarLexer.g4 @@ -66,7 +66,7 @@ BOOL: NULL: [Nn][Uu][Ll][Ll]; UNQUOTED_CHAR: [/\-\\+.$%*@?|]; // other characters allowed in unquoted strings -ID: (CHAR|'_') (CHAR|DIGIT|'_')*; +ID: (CHAR|'_') (CHAR|DIGIT|'_'|'-')*; ESC: (ESC_BACKSLASH | '\\(' | '\\)' | '\\[' | '\\]' | '\\{' | '\\}' | '\\:' | '\\=' | '\\,' | '\\ ' | '\\\t')+; WS: [ \t]+; diff --git a/omegaconf/grammar_parser.py b/omegaconf/grammar_parser.py index 85a931154..3c883c2cf 100644 --- a/omegaconf/grammar_parser.py +++ b/omegaconf/grammar_parser.py @@ -25,7 +25,7 @@ _node_access = f"\\.{_key_maybe_brackets}" # .foo, [foo], [$bar] _node_path = f"(\\.)*({_key_maybe_brackets})({_node_access})*" # [foo].bar, .foo[bar] _node_inter = f"\\${{\\s*{_node_path}\\s*}}" # node interpolation ${foo.bar} -_id = "[a-zA-Z_]\\w*" # foo, foo_bar, abc123 +_id = "[a-zA-Z_][\\w\\-]*" # foo, foo_bar, foo-bar, abc123 _resolver_name = f"({_id}(\\.{_id})*)?" # foo, ns.bar3, ns_1.ns_2.b0z _arg = r"[a-zA-Z_0-9/\-\+.$%*@?|]+" # string representing a resolver argument _args = f"{_arg}(\\s*,\\s*{_arg})*" # list of resolver arguments diff --git a/tests/test_grammar.py b/tests/test_grammar.py index 830aec8d0..f4bfa0028 100644 --- a/tests/test_grammar.py +++ b/tests/test_grammar.py @@ -613,6 +613,7 @@ def visit() -> Any: "x ${ab.cd.ef.gh} y", "$ ${foo} ${bar} ${boz} $", "${foo:bar}", + "${foo-bar:bar-foo}", "${foo : bar, baz, boz}", "${foo:bar,0,a-b+c*d/$.%@?|}", r"\${foo}",