34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
| def t_error(t):
raise TypeError("Unknown text '%s'" % (t.value,))
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 = "GF_G,/2"
lex.input(s)
for tok in iter(lex.token, None):
print repr(tok.type), repr(tok.value)
# Parse (yacc)
|
|
| 34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
| def t_error(t):
raise TypeError("Unknown text '%s'" % (t.value,))
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"/2'''
#s = "GF_G,/2"
lex.input(s)
for tok in iter(lex.token, None):
print repr(tok.type), repr(tok.value)
# Parse (yacc)
|
83
84
85
86
87
88
89
90
91
92
93
94
95
96
| '''
p[0] = p[1]
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(p):
'''chord : QUOTE pitch QUOTE
|
>
>
>
>
>
>
>
| 83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
| '''
p[0] = p[1]
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
def p_chord(p):
'''chord : QUOTE pitch QUOTE
|