spiffyscore

Diff
Login

Diff

Differences From Artifact [503badc6f2]:

To Artifact [00dc77f47f]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python

from ply import lex, yacc
class Note():
    def __init__(self, value, duration=.25, octave=8):
        self.value = value
        self.duration = duration
        self.octave = octave
        self.accidental = None
    def __repr__(self):
        return "Note %s %s %s" % (self.value, self.duration, self.octave)

class Chord():
    def __init__(self, value, duration=.25, chord_type="major"):
        self.value = value
        self.duration = duration
        self.chord_type = chord_type
    def __repr__(self):
        return "Chord %s %s %s" % (self.value, self.duration, self.chord_type)















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python

from ply import lex, yacc
class Note():
    def __init__(self, value, duration=.25, octave=8):
        self.value = value
        self.duration = duration
        self.octave = octave
        self.accidental = None
    def __repr__(self):
        return "Note %s %s %s" % (self.value, self.duration, self.octave)

class Chord():
    def __init__(self, value, duration=.5, chord_type="major"):
        self.value = value
        self.duration = duration
        self.chord_type = chord_type
    def __repr__(self):
        return "Chord %s %s %s" % (self.value, self.duration, self.chord_type)


100
101
102
103
104
105
106


107
108
109
110
111
112
113
114
        p[0] = new_note


    def p_chord(p):
        '''chord : QUOTE pitch QUOTE
                | QUOTE pitch CHORD_TYPE QUOTE
        '''


        p[0] = Chord(value=p[2].value)
        if len(p) > 3:
            p[0].chord_type = p[3]


    def p_accidental(p):
        '''pitch : ACCIDENTAL pitch
        '''







>
>
|







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
        p[0] = new_note


    def p_chord(p):
        '''chord : QUOTE pitch QUOTE
                | QUOTE pitch CHORD_TYPE QUOTE
        '''
        pitch = p[2].value
        pitch = pitch.upper()
        p[0] = Chord(value=pitch)
        if len(p) > 3:
            p[0].chord_type = p[3]


    def p_accidental(p):
        '''pitch : ACCIDENTAL pitch
        '''