# Path: omegaconf/errors.py
# class GrammarParseError(OmegaConfBaseException):
#     """
#     Thrown when failing to parse an expression according to the ANTLR grammar.
#     """
# 
# Path: omegaconf/grammar_visitor.py
# class GrammarVisitor(OmegaConfGrammarParserVisitor):
#     def __init__(
#         self,
#         node_interpolation_callback: Callable[
#             [str, Optional[Set[int]]],
#             Optional["Node"],
#         ],
#         resolver_interpolation_callback: Callable[..., Any],
#         memo: Optional[Set[int]],
#         **kw: Dict[Any, Any],
#     ):
#     def aggregateResult(self, aggregate: List[Any], nextResult: Any) -> List[Any]:
#     def defaultResult(self) -> List[Any]:
#     def visitConfigKey(self, ctx: OmegaConfGrammarParser.ConfigKeyContext) -> str:
#     def visitConfigValue(self, ctx: OmegaConfGrammarParser.ConfigValueContext) -> Any:
#     def visitDictKey(self, ctx: OmegaConfGrammarParser.DictKeyContext) -> Any:
#     def visitDictContainer(
#         self, ctx: OmegaConfGrammarParser.DictContainerContext
#     ) -> Dict[Any, Any]:
#     def visitElement(self, ctx: OmegaConfGrammarParser.ElementContext) -> Any:
#     def visitInterpolation(
#         self, ctx: OmegaConfGrammarParser.InterpolationContext
#     ) -> Any:
#     def visitInterpolationNode(
#         self, ctx: OmegaConfGrammarParser.InterpolationNodeContext
#     ) -> Optional["Node"]:
#     def visitInterpolationResolver(
#         self, ctx: OmegaConfGrammarParser.InterpolationResolverContext
#     ) -> Any:
#     def visitDictKeyValuePair(
#         self, ctx: OmegaConfGrammarParser.DictKeyValuePairContext
#     ) -> Tuple[Any, Any]:
#     def visitListContainer(
#         self, ctx: OmegaConfGrammarParser.ListContainerContext
#     ) -> List[Any]:
#     def visitPrimitive(self, ctx: OmegaConfGrammarParser.PrimitiveContext) -> Any:
#     def visitQuotedValue(self, ctx: OmegaConfGrammarParser.QuotedValueContext) -> str:
#     def visitResolverName(self, ctx: OmegaConfGrammarParser.ResolverNameContext) -> str:
#     def visitSequence(
#         self, ctx: OmegaConfGrammarParser.SequenceContext
#     ) -> Generator[Any, None, None]:
#         def empty_str_warning() -> None:
#     def visitSingleElement(
#         self, ctx: OmegaConfGrammarParser.SingleElementContext
#     ) -> Any:
#     def visitText(self, ctx: OmegaConfGrammarParser.TextContext) -> Any:
#     def _createPrimitive(
#         self,
#         ctx: Union[
#             OmegaConfGrammarParser.PrimitiveContext,
#             OmegaConfGrammarParser.DictKeyContext,
#         ],
#     ) -> Any:
#     def _unescape(
#         self,
#         seq: List[Union[TerminalNode, OmegaConfGrammarParser.InterpolationContext]],
#     ) -> str:


import re
import threading
from typing import Any
from antlr4 import CommonTokenStream, InputStream, ParserRuleContext
from antlr4.error.ErrorListener import ErrorListener
from .errors import GrammarParseError
from .grammar_visitor import (  # type: ignore
    OmegaConfGrammarLexer,
    OmegaConfGrammarParser,
)
        # to change the grammar in such a way that this warning cannot be
        # avoided (another option would be to switch to SLL parsing mode).
        raise GrammarParseError(
            "ANTLR error: Attempting Full Context"
        )  # pragma: no cover

    def reportContextSensitivity(
        self,
        recognizer: Any,
        dfa: Any,
        startIndex: Any,
        stopIndex: Any,
        prediction: Any,
        configs: Any,
    ) -> None:
        raise GrammarParseError("ANTLR error: ContextSensitivity")  # pragma: no cover


def parse(
    value: str, parser_rule: str = "configValue", lexer_mode: str = "DEFAULT_MODE"
) -> ParserRuleContext:
    """
    Parse interpolated string `value` (and return the parse tree).
    """
    l_mode = getattr(OmegaConfGrammarLexer, lexer_mode)
    istream = InputStream(value)

    cached = getattr(_grammar_cache, "data", None)
    if cached is None:
        error_listener = OmegaConfErrorListener()

# Path: omegaconf/errors.py
# class GrammarParseError(OmegaConfBaseException):
#     """
#     Thrown when failing to parse an expression according to the ANTLR grammar.
#     """
# 
# Path: omegaconf/grammar_visitor.py
# class GrammarVisitor(OmegaConfGrammarParserVisitor):
#     def __init__(
#         self,
#         node_interpolation_callback: Callable[
#             [str, Optional[Set[int]]],
#             Optional["Node"],
#         ],
#         resolver_interpolation_callback: Callable[..., Any],
#         memo: Optional[Set[int]],
#         **kw: Dict[Any, Any],
#     ):
#     def aggregateResult(self, aggregate: List[Any], nextResult: Any) -> List[Any]:
#     def defaultResult(self) -> List[Any]:
#     def visitConfigKey(self, ctx: OmegaConfGrammarParser.ConfigKeyContext) -> str:
#     def visitConfigValue(self, ctx: OmegaConfGrammarParser.ConfigValueContext) -> Any:
#     def visitDictKey(self, ctx: OmegaConfGrammarParser.DictKeyContext) -> Any:
#     def visitDictContainer(
#         self, ctx: OmegaConfGrammarParser.DictContainerContext
#     ) -> Dict[Any, Any]:
#     def visitElement(self, ctx: OmegaConfGrammarParser.ElementContext) -> Any:
#     def visitInterpolation(
#         self, ctx: OmegaConfGrammarParser.InterpolationContext
#     ) -> Any:
#     def visitInterpolationNode(
#         self, ctx: OmegaConfGrammarParser.InterpolationNodeContext
#     ) -> Optional["Node"]:
#     def visitInterpolationResolver(
#         self, ctx: OmegaConfGrammarParser.InterpolationResolverContext
#     ) -> Any:
#     def visitDictKeyValuePair(
#         self, ctx: OmegaConfGrammarParser.DictKeyValuePairContext
#     ) -> Tuple[Any, Any]:
#     def visitListContainer(
#         self, ctx: OmegaConfGrammarParser.ListContainerContext
#     ) -> List[Any]:
#     def visitPrimitive(self, ctx: OmegaConfGrammarParser.PrimitiveContext) -> Any:
#     def visitQuotedValue(self, ctx: OmegaConfGrammarParser.QuotedValueContext) -> str:
#     def visitResolverName(self, ctx: OmegaConfGrammarParser.ResolverNameContext) -> str:
#     def visitSequence(
#         self, ctx: OmegaConfGrammarParser.SequenceContext
#     ) -> Generator[Any, None, None]:
#         def empty_str_warning() -> None:
#     def visitSingleElement(
#         self, ctx: OmegaConfGrammarParser.SingleElementContext
#     ) -> Any:
#     def visitText(self, ctx: OmegaConfGrammarParser.TextContext) -> Any:
#     def _createPrimitive(
#         self,
#         ctx: Union[
#             OmegaConfGrammarParser.PrimitiveContext,
#             OmegaConfGrammarParser.DictKeyContext,
#         ],
#     ) -> Any:
#     def _unescape(
#         self,
#         seq: List[Union[TerminalNode, OmegaConfGrammarParser.InterpolationContext]],
#     ) -> str:


# Path: omegaconf/grammar_parser.py
import re
import threading
from typing import Any
from antlr4 import CommonTokenStream, InputStream, ParserRuleContext
from antlr4.error.ErrorListener import ErrorListener
from .errors import GrammarParseError
from .grammar_visitor import (  # type: ignore
    OmegaConfGrammarLexer,
    OmegaConfGrammarParser,
)

        # to change the grammar in such a way that this warning cannot be
        # avoided (another option would be to switch to SLL parsing mode).
        raise GrammarParseError(
            "ANTLR error: Attempting Full Context"
        )  # pragma: no cover

    def reportContextSensitivity(
        self,
        recognizer: Any,
        dfa: Any,
        startIndex: Any,
        stopIndex: Any,
        prediction: Any,
        configs: Any,
    ) -> None:
        raise GrammarParseError("ANTLR error: ContextSensitivity")  # pragma: no cover


def parse(
    value: str, parser_rule: str = "configValue", lexer_mode: str = "DEFAULT_MODE"
) -> ParserRuleContext:
    """
    Parse interpolated string `value` (and return the parse tree).
    """
    l_mode = getattr(OmegaConfGrammarLexer, lexer_mode)
    istream = InputStream(value)

    cached = getattr(_grammar_cache, "data", None)
    if cached is None:
        error_listener = OmegaConfErrorListener()

        lexer = OmegaConfGrammarLexer(istream)