1import sys
2
3if ".." not in sys.path: sys.path.insert(0,"..")
4
5from ply import lex, yacc
6
7t_A = 'A'
8t_B = 'B'
9t_C = 'C'
10
11tokens = ('A', 'B', 'C')
12
13the_lexer = lex.lex()
14
15def t_error(t):
16    pass
17
18def p_error(p):
19    pass
20
21def p_start(t):
22    '''start : A nest C'''
23    pass
24
25def p_nest(t):
26   '''nest : B'''
27   print(t[-1])
28
29the_parser = yacc.yacc(debug = False, write_tables = False)
30
31the_parser.parse('ABC', the_lexer)
32the_parser.parse('ABC', the_lexer, tracking=True)
33the_parser.parse('ABC', the_lexer, tracking=True, debug=1)
34