Index: parse.py ================================================================== --- parse.py +++ parse.py @@ -36,11 +36,11 @@ lex.lex() #lex.input("GFG B'AB,, | g/2fg gab | GFG BAB | d2A AFD") #s = "GFG B'AB,, | g/2fg gab | GFG BAB | d2A AFD" -s = '''I IV V VI I "I" "ii"''' +s = '''I IV V VI I "I" "ii"/2''' #s = "GF_G,/2" lex.input(s) for tok in iter(lex.token, None): print repr(tok.type), repr(tok.value) @@ -85,10 +85,17 @@ def p_note_length(p): ''' note : note NOTE_LENGTH ''' + new_note = p[1] + new_note.duration = p[2] + p[0] = new_note + +def p_chord_length(p): + ''' chord : chord NOTE_LENGTH + ''' new_note = p[1] new_note.duration = p[2] p[0] = new_note