prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [Bug] Hydra's override grammar allows quoted resolver args, but OmegaConf does not recognize them
  # 🐛 Bug
  
  ## Description
  
  Best explained with an example (assume a basic `my_app.py` that prints the resolved config):
  
  ```bash
  python my_app.py +port='${env:PORT}'     # works, may crash if PORT is not defined
  python my_app.py +port='${env:PORT,80}'  # crashes: not recognized by Hydra's grammar
  python my_app.py +port='${env:PORT,"80"}'  # accepted by Hydra but OmegaConf does not resolve it
  ```
  
  This is because in the current version of OmegaConf, quotes are not allowed inside interpolations.
  
  ## Checklist
  - [x] I checked on the latest version of Hydra
  - [x] I created a minimal repro
  
  ## To reproduce
  
  ** Minimal Code/Config snippet to reproduce **
  
  ```python
  from omegaconf import DictConfig, OmegaConf
  import hydra
  
  @hydra.main()
  def my_app(cfg: DictConfig) -> None:
      print(OmegaConf.to_yaml(cfg, resolve=True))
  
  if __name__ == "__main__":
      my_app()
  ```
  
  Then try the examples above.
  
  ** Stack trace/error message **
  
  Just showing the last example:
  ```
  port: ${env:PORT,"80"}
  ```
  
  ## Expected Behavior
  Hydra should allow the same characters as OmegaConf.
  
  ## System information
  - **Hydra Version** :  current master (7afee097)
  - **Python version** : 3.8.3
  - **Virtual environment type and version** : conda 4.8.3
  - **Operating system** : MacOS
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `hydra/core/override_parser/overrides_parser.py`
  Content:
  ```
  1 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
  2 import sys
  3 from typing import Any, List, Optional
  4 
  5 from antlr4.error.Errors import LexerNoViableAltException, RecognitionException
  6 
  7 from hydra._internal.grammar import grammar_functions
  8 from hydra._internal.grammar.functions import Functions
  9 from hydra.core.config_loader import ConfigLoader
  10 from hydra.core.override_parser.overrides_visitor import (
  11     HydraErrorListener,
  12     HydraOverrideVisitor,
  13 )
  14 from hydra.core.override_parser.types import Override
  15 from hydra.errors import HydraException, OverrideParseException
  16 
  17 try:
  18     from hydra.grammar.gen.OverrideLexer import (
  19         CommonTokenStream,
  20         InputStream,
  21         OverrideLexer,
  22     )
  23     from hydra.grammar.gen.OverrideParser import OverrideParser
  24 
  25 except ModuleNotFoundError:
  26     print(
  27         "Error importing generated parsers, run `python setup.py antlr` to regenerate."
  28     )
  29     sys.exit(1)
  30 
  31 # The set of parser rules that require the lexer to be in lexical mode `KEY`.
  32 KEY_RULES = {"key", "override", "package", "packageOrGroup"}
  33 
  34 
  35 class OverridesParser:
  36     functions: Functions
  37 
  38     @classmethod
  39     def create(cls, config_loader: Optional[ConfigLoader] = None) -> "OverridesParser":
  40         functions = create_functions()
  41         return cls(functions=functions, config_loader=config_loader)
  42 
  43     def __init__(
  44         self, functions: Functions, config_loader: Optional[ConfigLoader] = None
  45     ):
  46         self.functions = functions
  47         self.config_loader = config_loader
  48 
  49     def parse_rule(self, s: str, rule_name: str) -> Any:
  50         error_listener = HydraErrorListener()
  51         istream = InputStream(s)
  52         lexer = OverrideLexer(istream)
  53         lexer.removeErrorListeners()
  54         lexer.addErrorListener(error_listener)
  55 
  56         # Set the lexer in the correct mode to parse the desired rule.
  57         lexer_mode = "KEY" if rule_name in KEY_RULES else "VALUE"
  58         lexer.mode(getattr(OverrideLexer, lexer_mode))
  59 
  60         stream = CommonTokenStream(lexer)
  61         parser = OverrideParser(stream)
  62         parser.removeErrorListeners()
  63         parser.addErrorListener(error_listener)
  64         visitor = HydraOverrideVisitor(self.functions)
  65         rule = getattr(parser, rule_name)
  66         tree = rule()
  67         ret = visitor.visit(tree)
  68         if isinstance(ret, Override):
  69             ret.input_line = s
  70         return ret
  71 
  72     def parse_override(self, s: str) -> Override:
  73         ret = self.parse_rule(s, "override")
  74         assert isinstance(ret, Override)
  75         return ret
  76 
  77     def parse_overrides(self, overrides: List[str]) -> List[Override]:
  78         ret: List[Override] = []
  79         for override in overrides:
  80             try:
  81                 parsed = self.parse_rule(override, "override")
  82             except HydraException as e:
  83                 cause = e.__cause__
  84                 if isinstance(cause, LexerNoViableAltException):
  85                     prefix = "LexerNoViableAltException: "
  86                     start = len(prefix) + cause.startIndex + 1
  87                     msg = f"{prefix}{override}" f"\n{'^'.rjust(start)}"
  88                     e.__cause__ = None
  89                 elif isinstance(cause, RecognitionException):
  90                     prefix = f"{e}"
  91                     msg = f"{prefix}"
  92                     e.__cause__ = None
  93                 else:
  94                     msg = f"Error parsing override '{override}'" f"\n{e}"
  95                 raise OverrideParseException(
  96                     override=override,
  97                     message=f"{msg}"
  98                     f"\nSee https://hydra.cc/docs/next/advanced/override_grammar/basic for details",
  99                 ) from e.__cause__
  100             assert isinstance(parsed, Override)
  101             parsed.config_loader = self.config_loader
  102             ret.append(parsed)
  103         return ret
  104 
  105 
  106 def create_functions() -> Functions:
  107     functions = Functions()
  108     # casts
  109     functions.register(name="int", func=grammar_functions.cast_int)
  110     functions.register(name="str", func=grammar_functions.cast_str)
  111     functions.register(name="bool", func=grammar_functions.cast_bool)
  112     functions.register(name="float", func=grammar_functions.cast_float)
  113     # sweeps
  114     functions.register(name="choice", func=grammar_functions.choice)
  115     functions.register(name="range", func=grammar_functions.range)
  116     functions.register(name="interval", func=grammar_functions.interval)
  117     # misc
  118     functions.register(name="tag", func=grammar_functions.tag)
  119     functions.register(name="sort", func=grammar_functions.sort)
  120     functions.register(name="shuffle", func=grammar_functions.shuffle)
  121     functions.register(name="glob", func=grammar_functions.glob)
  122     return functions
  123
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/hydra/core/override_parser/overrides_parser.py b/hydra/core/override_parser/overrides_parser.py
  --- a/hydra/core/override_parser/overrides_parser.py
  +++ b/hydra/core/override_parser/overrides_parser.py
  @@ -54,8 +54,8 @@
           lexer.addErrorListener(error_listener)
   
           # Set the lexer in the correct mode to parse the desired rule.
  -        lexer_mode = "KEY" if rule_name in KEY_RULES else "VALUE"
  -        lexer.mode(getattr(OverrideLexer, lexer_mode))
  +        if rule_name not in KEY_RULES:
  +            lexer.mode(OverrideLexer.VALUE_MODE)
   
           stream = CommonTokenStream(lexer)
           parser = OverrideParser(stream)
  
verification_info: {"golden_diff": "diff --git a/hydra/core/override_parser/overrides_parser.py b/hydra/core/override_parser/overrides_parser.py\n--- a/hydra/core/override_parser/overrides_parser.py\n+++ b/hydra/core/override_parser/overrides_parser.py\n@@ -54,8 +54,8 @@\n         lexer.addErrorListener(error_listener)\n \n         # Set the lexer in the correct mode to parse the desired rule.\n-        lexer_mode = \"KEY\" if rule_name in KEY_RULES else \"VALUE\"\n-        lexer.mode(getattr(OverrideLexer, lexer_mode))\n+        if rule_name not in KEY_RULES:\n+            lexer.mode(OverrideLexer.VALUE_MODE)\n \n         stream = CommonTokenStream(lexer)\n         parser = OverrideParser(stream)\n", "issue": "[Bug] Hydra's override grammar allows quoted resolver args, but OmegaConf does not recognize them\n# \ud83d\udc1b Bug\r\n\r\n## Description\r\n\r\nBest explained with an example (assume a basic `my_app.py` that prints the resolved config):\r\n\r\n```bash\r\npython my_app.py +port='${env:PORT}'     # works, may crash if PORT is not defined\r\npython my_app.py +port='${env:PORT,80}'  # crashes: not recognized by Hydra's grammar\r\npython my_app.py +port='${env:PORT,\"80\"}'  # accepted by Hydra but OmegaConf does not resolve it\r\n```\r\n\r\nThis is because in the current version of OmegaConf, quotes are not allowed inside interpolations.\r\n\r\n## Checklist\r\n- [x] I checked on the latest version of Hydra\r\n- [x] I created a minimal repro\r\n\r\n## To reproduce\r\n\r\n** Minimal Code/Config snippet to reproduce **\r\n\r\n```python\r\nfrom omegaconf import DictConfig, OmegaConf\r\nimport hydra\r\n\r\n@hydra.main()\r\ndef my_app(cfg: DictConfig) -> None:\r\n    print(OmegaConf.to_yaml(cfg, resolve=True))\r\n\r\nif __name__ == \"__main__\":\r\n    my_app()\r\n```\r\n\r\nThen try the examples above.\r\n\r\n** Stack trace/error message **\r\n\r\nJust showing the last example:\r\n```\r\nport: ${env:PORT,\"80\"}\r\n```\r\n\r\n## Expected Behavior\r\nHydra should allow the same characters as OmegaConf.\r\n\r\n## System information\r\n- **Hydra Version** :  current master (7afee097)\r\n- **Python version** : 3.8.3\r\n- **Virtual environment type and version** : conda 4.8.3\r\n- **Operating system** : MacOS\r\n\n", "before_files": [{"content": "# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\nimport sys\nfrom typing import Any, List, Optional\n\nfrom antlr4.error.Errors import LexerNoViableAltException, RecognitionException\n\nfrom hydra._internal.grammar import grammar_functions\nfrom hydra._internal.grammar.functions import Functions\nfrom hydra.core.config_loader import ConfigLoader\nfrom hydra.core.override_parser.overrides_visitor import (\n    HydraErrorListener,\n    HydraOverrideVisitor,\n)\nfrom hydra.core.override_parser.types import Override\nfrom hydra.errors import HydraException, OverrideParseException\n\ntry:\n    from hydra.grammar.gen.OverrideLexer import (\n        CommonTokenStream,\n        InputStream,\n        OverrideLexer,\n    )\n    from hydra.grammar.gen.OverrideParser import OverrideParser\n\nexcept ModuleNotFoundError:\n    print(\n        \"Error importing generated parsers, run `python setup.py antlr` to regenerate.\"\n    )\n    sys.exit(1)\n\n# The set of parser rules that require the lexer to be in lexical mode `KEY`.\nKEY_RULES = {\"key\", \"override\", \"package\", \"packageOrGroup\"}\n\n\nclass OverridesParser:\n    functions: Functions\n\n    @classmethod\n    def create(cls, config_loader: Optional[ConfigLoader] = None) -> \"OverridesParser\":\n        functions = create_functions()\n        return cls(functions=functions, config_loader=config_loader)\n\n    def __init__(\n        self, functions: Functions, config_loader: Optional[ConfigLoader] = None\n    ):\n        self.functions = functions\n        self.config_loader = config_loader\n\n    def parse_rule(self, s: str, rule_name: str) -> Any:\n        error_listener = HydraErrorListener()\n        istream = InputStream(s)\n        lexer = OverrideLexer(istream)\n        lexer.removeErrorListeners()\n        lexer.addErrorListener(error_listener)\n\n        # Set the lexer in the correct mode to parse the desired rule.\n        lexer_mode = \"KEY\" if rule_name in KEY_RULES else \"VALUE\"\n        lexer.mode(getattr(OverrideLexer, lexer_mode))\n\n        stream = CommonTokenStream(lexer)\n        parser = OverrideParser(stream)\n        parser.removeErrorListeners()\n        parser.addErrorListener(error_listener)\n        visitor = HydraOverrideVisitor(self.functions)\n        rule = getattr(parser, rule_name)\n        tree = rule()\n        ret = visitor.visit(tree)\n        if isinstance(ret, Override):\n            ret.input_line = s\n        return ret\n\n    def parse_override(self, s: str) -> Override:\n        ret = self.parse_rule(s, \"override\")\n        assert isinstance(ret, Override)\n        return ret\n\n    def parse_overrides(self, overrides: List[str]) -> List[Override]:\n        ret: List[Override] = []\n        for override in overrides:\n            try:\n                parsed = self.parse_rule(override, \"override\")\n            except HydraException as e:\n                cause = e.__cause__\n                if isinstance(cause, LexerNoViableAltException):\n                    prefix = \"LexerNoViableAltException: \"\n                    start = len(prefix) + cause.startIndex + 1\n                    msg = f\"{prefix}{override}\" f\"\\n{'^'.rjust(start)}\"\n                    e.__cause__ = None\n                elif isinstance(cause, RecognitionException):\n                    prefix = f\"{e}\"\n                    msg = f\"{prefix}\"\n                    e.__cause__ = None\n                else:\n                    msg = f\"Error parsing override '{override}'\" f\"\\n{e}\"\n                raise OverrideParseException(\n                    override=override,\n                    message=f\"{msg}\"\n                    f\"\\nSee https://hydra.cc/docs/next/advanced/override_grammar/basic for details\",\n                ) from e.__cause__\n            assert isinstance(parsed, Override)\n            parsed.config_loader = self.config_loader\n            ret.append(parsed)\n        return ret\n\n\ndef create_functions() -> Functions:\n    functions = Functions()\n    # casts\n    functions.register(name=\"int\", func=grammar_functions.cast_int)\n    functions.register(name=\"str\", func=grammar_functions.cast_str)\n    functions.register(name=\"bool\", func=grammar_functions.cast_bool)\n    functions.register(name=\"float\", func=grammar_functions.cast_float)\n    # sweeps\n    functions.register(name=\"choice\", func=grammar_functions.choice)\n    functions.register(name=\"range\", func=grammar_functions.range)\n    functions.register(name=\"interval\", func=grammar_functions.interval)\n    # misc\n    functions.register(name=\"tag\", func=grammar_functions.tag)\n    functions.register(name=\"sort\", func=grammar_functions.sort)\n    functions.register(name=\"shuffle\", func=grammar_functions.shuffle)\n    functions.register(name=\"glob\", func=grammar_functions.glob)\n    return functions\n", "path": "hydra/core/override_parser/overrides_parser.py"}], "after_files": [{"content": "# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\nimport sys\nfrom typing import Any, List, Optional\n\nfrom antlr4.error.Errors import LexerNoViableAltException, RecognitionException\n\nfrom hydra._internal.grammar import grammar_functions\nfrom hydra._internal.grammar.functions import Functions\nfrom hydra.core.config_loader import ConfigLoader\nfrom hydra.core.override_parser.overrides_visitor import (\n    HydraErrorListener,\n    HydraOverrideVisitor,\n)\nfrom hydra.core.override_parser.types import Override\nfrom hydra.errors import HydraException, OverrideParseException\n\ntry:\n    from hydra.grammar.gen.OverrideLexer import (\n        CommonTokenStream,\n        InputStream,\n        OverrideLexer,\n    )\n    from hydra.grammar.gen.OverrideParser import OverrideParser\n\nexcept ModuleNotFoundError:\n    print(\n        \"Error importing generated parsers, run `python setup.py antlr` to regenerate.\"\n    )\n    sys.exit(1)\n\n# The set of parser rules that require the lexer to be in lexical mode `KEY`.\nKEY_RULES = {\"key\", \"override\", \"package\", \"packageOrGroup\"}\n\n\nclass OverridesParser:\n    functions: Functions\n\n    @classmethod\n    def create(cls, config_loader: Optional[ConfigLoader] = None) -> \"OverridesParser\":\n        functions = create_functions()\n        return cls(functions=functions, config_loader=config_loader)\n\n    def __init__(\n        self, functions: Functions, config_loader: Optional[ConfigLoader] = None\n    ):\n        self.functions = functions\n        self.config_loader = config_loader\n\n    def parse_rule(self, s: str, rule_name: str) -> Any:\n        error_listener = HydraErrorListener()\n        istream = InputStream(s)\n        lexer = OverrideLexer(istream)\n        lexer.removeErrorListeners()\n        lexer.addErrorListener(error_listener)\n\n        # Set the lexer in the correct mode to parse the desired rule.\n        if rule_name not in KEY_RULES:\n            lexer.mode(OverrideLexer.VALUE_MODE)\n\n        stream = CommonTokenStream(lexer)\n        parser = OverrideParser(stream)\n        parser.removeErrorListeners()\n        parser.addErrorListener(error_listener)\n        visitor = HydraOverrideVisitor(self.functions)\n        rule = getattr(parser, rule_name)\n        tree = rule()\n        ret = visitor.visit(tree)\n        if isinstance(ret, Override):\n            ret.input_line = s\n        return ret\n\n    def parse_override(self, s: str) -> Override:\n        ret = self.parse_rule(s, \"override\")\n        assert isinstance(ret, Override)\n        return ret\n\n    def parse_overrides(self, overrides: List[str]) -> List[Override]:\n        ret: List[Override] = []\n        for override in overrides:\n            try:\n                parsed = self.parse_rule(override, \"override\")\n            except HydraException as e:\n                cause = e.__cause__\n                if isinstance(cause, LexerNoViableAltException):\n                    prefix = \"LexerNoViableAltException: \"\n                    start = len(prefix) + cause.startIndex + 1\n                    msg = f\"{prefix}{override}\" f\"\\n{'^'.rjust(start)}\"\n                    e.__cause__ = None\n                elif isinstance(cause, RecognitionException):\n                    prefix = f\"{e}\"\n                    msg = f\"{prefix}\"\n                    e.__cause__ = None\n                else:\n                    msg = f\"Error parsing override '{override}'\" f\"\\n{e}\"\n                raise OverrideParseException(\n                    override=override,\n                    message=f\"{msg}\"\n                    f\"\\nSee https://hydra.cc/docs/next/advanced/override_grammar/basic for details\",\n                ) from e.__cause__\n            assert isinstance(parsed, Override)\n            parsed.config_loader = self.config_loader\n            ret.append(parsed)\n        return ret\n\n\ndef create_functions() -> Functions:\n    functions = Functions()\n    # casts\n    functions.register(name=\"int\", func=grammar_functions.cast_int)\n    functions.register(name=\"str\", func=grammar_functions.cast_str)\n    functions.register(name=\"bool\", func=grammar_functions.cast_bool)\n    functions.register(name=\"float\", func=grammar_functions.cast_float)\n    # sweeps\n    functions.register(name=\"choice\", func=grammar_functions.choice)\n    functions.register(name=\"range\", func=grammar_functions.range)\n    functions.register(name=\"interval\", func=grammar_functions.interval)\n    # misc\n    functions.register(name=\"tag\", func=grammar_functions.tag)\n    functions.register(name=\"sort\", func=grammar_functions.sort)\n    functions.register(name=\"shuffle\", func=grammar_functions.shuffle)\n    functions.register(name=\"glob\", func=grammar_functions.glob)\n    return functions\n", "path": "hydra/core/override_parser/overrides_parser.py"}]}