4 Ann Hell Ex Machina - Music Software
5 Copyright (C) 2003/2004 Angel Ortega <angel@triptico.com>
7 compiler.y - Scripting language YACC parser
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 http://www.triptico.com
31 void yyerror(char * s
);
42 %token
<i
> INTEGER INCDEC
44 %token
<i
> NOTE_P NOTE_M NOTE_O
45 %token
<c
> NOTE_T3 NOTE_T5
46 %token
<p
> NEW_MARK GOTO_MARK ASSERT_MARK
48 %token
<p
> BLOCK BLK_ASSIGN BLK_INSERT FILE_INSERT
53 %token SS_SEP SS_WAV SS_PAT SS_SUSTAIN
54 %token SS_EFF_DELAY SS_EFF_ECHO SS_EFF_COMB SS_EFF_ALLPASS
55 %token SS_EFF_FLANGER SS_EFF_WOBBLE SS_EFF_SQWOBBLE SS_EFF_FADER
57 %type
<i
> note note_pitch rest z_note
58 %type
<d
> number note_length
60 %type
<d
> arp_list arp_note
65 script stmt
{ printf
("function stmt\n"); }
70 note
{ printf
("Note: %d\n", $1); }
71 | rest
{ printf
("Rest\n"); }
72 | z_note
{ printf
("Zero note\n"); }
73 |
'o' INTEGER
{ printf
("Octave abs: %d\n", $2); }
74 |
'o' INCDEC
{ printf
("Octave rel: %d\n", $2); }
75 |
't' INTEGER
{ printf
("Transpose: %d\n", $2); }
76 |
's' number
{ printf
("Staccato: %lf\n", $2); }
77 |
'<' { printf
("Start of group\n"); }
78 |
';' { printf
("Group delim\n"); }
79 |
'>' { printf
("End of group\n"); }
80 |
'l' note_length
{ printf
("Glissando: %lf\n", $2); }
81 |
'|' { printf
("Measure mark\n"); }
82 | arp
{ printf
("arp\n"); }
83 | NEW_MARK
{ printf
("New mark: %s\n", $1); }
84 | GOTO_MARK
{ printf
("Goto mark: %s\n", $1); }
85 | ASSERT_MARK
{ printf
("Assert mark: %s\n", $1); }
86 |
'T' number
{ printf
("Tempo: %lf\n", $2); }
87 |
'M' INTEGER
'/' INTEGER
{ printf
("Measure: %d/%d\n", $2, $4); }
88 |
'\\' { printf
("New track\n"); }
89 | ss_cmd
{ printf
("ss_cmd\n"); }
91 printf
("repeat block '%s' %d times\n", $1, $3);
94 | BLOCK BLK_ASSIGN
{ printf
("Assign block '%s' to %s\n", $1, $2); }
95 | BLK_INSERT
{ printf
("Insert block named %s\n", $1); }
96 | FILE_INSERT
{ printf
("Insert file '%s' here\n", $1); }
100 INTEGER
{ $$
= (double) $1; }
105 note_pitch
{ $$
= $1; }
106 | note note_length
{ $$
= $1; printf
("length: %lf\n", $2); }
107 | note
'~' number
{ $$
= $1; printf
("volume: %lf\n", $3); }
112 | note_pitch
'-' { $$
= $1 - 1; }
113 | note_pitch
'#' { $$
= $1 + 1; }
114 | note_pitch NOTE_O
{ $$
= $1; printf
("imm octave: %d\n", $2); }
118 INTEGER
{ $$
= 1 / (double) $1; }
119 | note_length NOTE_T3
{ $$
= $1 * 2.0 / 3.0; }
120 | note_length NOTE_T5
{ $$
= $1 * 4.0 / 5.0; }
121 | note_length
'*' number
{ $$
= $1 * $3; }
122 | note_length
'.' { $$
= $1 * 1.5; }
127 | rest note_length
{ $$
= $1; printf
("rest length: %lf\n", $2); }
131 'z' note_length
{ $$
= $2; printf
("zero note length: %lf\n", $2); }
135 'x' { printf
("Empty arp\n"); }
136 |
'x' arp_list
{ printf
("Yes arp\n"); }
140 arp_note
{ printf
("arp_note [reset]\n"); }
141 | arp_list
',' arp_note
{ printf
("arp_note [no reset]\n"); }
145 note_length
{ printf
("arp length: %lf\n", $1); }
146 | arp_note
'~' number
{ printf
("arp vol: %lf\n", $3); }
147 | arp_note
'+' INTEGER
{ printf
("arp transpose: +%d\n", $3); }
148 | arp_note
'-' INTEGER
{ printf
("arp transpose: -%d\n", $3); }
149 | arp_note
'@' INTEGER
{ printf
("arp track: %d\n", $3); }
153 SS_WAV SS_STR
{ printf
("SS_WAV: %s\n", $2); }
154 | SS_PAT SS_STR
{ printf
("SS_PAT: %s\n", $2); }
155 | SS_SUSTAIN SS_FRAMES
{ printf
("SS_SUSTAIN: %d\n", $2); }
156 | SS_EFF_DELAY INTEGER SS_FRAMES
{ printf
("delay chan: %d frames: %d\n", $2, $3); }
157 | SS_EFF_ECHO INTEGER SS_FRAMES number
{ printf
("echo chan: %d frames: %d gain: %lf\n", $2, $3, $4); }
158 | SS_EFF_FADER INTEGER SS_FRAMES number number
{ printf
("fader chan: %d frames: %d %lf .. %lf\n", $2, $3, $4, $5); }
163 void yyerror(char * s
)
165 printf
("yyerror: %s\n", s
);
169 extern
int push_code
(char * code
, int times
, int dyn
);
173 push_code
("{ fader -1 100ms 0 1 } r r4. z2", 1, 0);
174 push_code
("{ sustain 100ms }", 1, 0);
175 push_code
("T120.0 M4/4 abcde T80 (edcba)=drum1 $drum1 $drum1 ((ab)*3 (cd)*2)*10", 2, 0);
179 printf
("Exiting main...\n");