def parse()

in nubia/internal/parser.py [0:0]


def parse(text: str, expect_subcommand: bool) -> pp.ParseResults:
    expected_pattern = command_with_subcommand if expect_subcommand else command
    try:
        result = expected_pattern.parseString(text, parseAll=True)
        return result
    except pp.ParseException as e:
        exception = CommandParseError(str(e))
        remaining = e.markInputline()
        partial_result = expected_pattern.parseString(text, parseAll=False)
        exception.remaining = remaining[(remaining.find(">!<") + 3) :]
        exception.partial_result = partial_result
        exception.col = e.col
        raise exception