All pastes #453511 Raw Edit

Mine

public text v1 · immutable
·published 2007-04-23 01:43 UTC
rendered paste body
END = 0
LIT = 1
PLUS = 2
TIMES = 3

tokens = [LIT, PLUS, LIT, TIMES, END]

# now write a parser that will take an expression like this and
# tell me if there's a syntax error
# using the slightly improved expression grammar:
#
# mult_expr: LIT * mult_expr
#          | LIT
# expr: mult_expr + add_expr
#     | mult_expr
#