spiffyscore

Diff
Login

Differences From Artifact [b5bfbaf68d]:

To Artifact [ba81961e5a]:


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96





97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
...
114
115
116
117
118
119
120





121
122
123
124
125
126
127

t_ignore = " |"

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 = "GF_G,"
lex.input(s)
for tok in iter(lex.token, None):
    print repr(tok.type), repr(tok.value)


# Parse (yacc)

................................................................................
#                    | REST
#    '''
#    p[0] = p[1]
#
#def p_pitch(p):

def p_pitch_list(p):
    '''score : score pitch
    '''
    p[0] = p[1] + [p[2]]

def p_sore(p):
    '''score : pitch
    '''
    p[0] = [p[1]]


def p_pitch_more(p):
    ''' score : pitch NOTE_LENGTH
    '''
    print "stuff"





    new_note = p[1]
    new_note.duration = p[2]
    p[0] = new_note

def p_pitch(p):
    '''pitch : BASENOTE
    '''
    p[0] = Note(p[1])

def p_accidental(p):
    '''pitch : ACCIDENTAL pitch
    '''
    p[2].accidental = p[1]
    p[0] = p[2]

def p_octave(p):
................................................................................
    '''
    count = len(p[2])
    increment_or_decrement = 1 if p[2][0] == "," else -1
    octave = 8 + (count * increment_or_decrement)
    p[1].octave = octave
    p[0] = p[1]






def p_error(p):
    print "Syntax error at '%s' of element type %s" % (p.value, p.type)
    
yacc.yacc()

#print yacc.parse("GFG B'AB,, | g/2fg gab | GFG BAB | d2A AFD")
print yacc.parse(s)







|







 







|



|
|




|
|

|
>
>
>
>
>




<
<
<
<
<







 







>
>
>
>
>







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105





106
107
108
109
110
111
112
...
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

t_ignore = " |"

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 = "GF_G,/2"
lex.input(s)
for tok in iter(lex.token, None):
    print repr(tok.type), repr(tok.value)


# Parse (yacc)

................................................................................
#                    | REST
#    '''
#    p[0] = p[1]
#
#def p_pitch(p):

def p_pitch_list(p):
    '''score : score note
    '''
    p[0] = p[1] + [p[2]]

def p_score(p):
    '''score : note
    '''
    p[0] = [p[1]]


def p_note(p):
    '''note : pitch
    '''
    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_accidental(p):
    '''pitch : ACCIDENTAL pitch
    '''
    p[2].accidental = p[1]
    p[0] = p[2]

def p_octave(p):
................................................................................
    '''
    count = len(p[2])
    increment_or_decrement = 1 if p[2][0] == "," else -1
    octave = 8 + (count * increment_or_decrement)
    p[1].octave = octave
    p[0] = p[1]

def p_pitch(p):
    '''pitch : BASENOTE
    '''
    p[0] = Note(p[1])

def p_error(p):
    print "Syntax error at '%s' of element type %s" % (p.value, p.type)
    
yacc.yacc()

#print yacc.parse("GFG B'AB,, | g/2fg gab | GFG BAB | d2A AFD")
print yacc.parse(s)