Output:

i = 0 if text[i] == '': i += 1 while text[i] != '': ... Write (using a parser combinator library):

parser = Lark(grammar, parser="lalr") tree = parser.parse("let x = 42") print(tree.pretty())

start let x = 42 use nom:: sequence::delimited, bytes::complete::tag, character::complete::alpha1, space0, digit1, combinator::map, sequence::tuple, IResult, ; fn assignment(input: &str) -> IResult<&str, (&str, u32)> (name, val.parse().unwrap()) )(input)