3 extern void mngerror(char const *);
5 extern mngFlexLexer *mnglexer;
6 int mnglex(void) { return mnglexer->yylex(); }
17 class MNGExpression *expr;
18 class MNGExpressionContainer *container;
19 class MNGVariableNode *variable;
20 class MNGVariableDecNode *variabledec;
21 class MNGTrackDecNode *trackdec;
22 class MNGEffectDecNode *effectdec;
23 class MNGAssignmentNode *assignment;
24 class MNGStageNode *stage;
25 class MNGLayer *layer;
26 std::list<class MNGAssignmentNode *> *assignmentarray;
27 std::list<class MNGNode *> *array;
28 std::list<class MNGStageNode *> *stagearray;
43 %token MNG_AleotoricLayer
58 %token <number> MNG_number
59 %token <string> MNG_name
62 %type <container> pan effectvolume layervolume tempodelay delay fadein fadeout beatlength beatsynch updaterate
63 %type <node> stagesetting aleotoriclayerdec looplayerdec tracksetting wave effect interval updateblock voiceblock aleotoriclayercommand looplayercommand voicecommand condition
64 %type <expr> expression add subtract multiply divide sinewave cosinewave random
65 %type <variable> variable
66 %type <array> stagesettinglist track aleotoriclayer looplayer voicecommands
67 %type <assignment> assignment
68 %type <assignmentarray> assignmentlist
69 %type <variabledec> variabledec
70 %type <effectdec> effectdec
71 %type <trackdec> trackdec
73 %type <stagearray> stagelist
77 statementlist: statement { }
78 | statementlist statement { }
81 statement: effectdec { g_mngfile->add($1); }
82 | trackdec { g_mngfile->add($1); }
83 | variabledec { g_mngfile->add($1); }
87 variabledec: MNG_Variable '(' MNG_name ',' expression ')' { $$ = new MNGVariableDecNode($3, $5); }
90 effectdec: MNG_Effect '(' MNG_name ')' '{' stagelist '}' { $$ = new MNGEffectDecNode($3); ((MNGEffectDecNode *)$$)->children = $6; }
93 stagelist: stage { $$ = new std::list<MNGStageNode *>; if ($1) $$->push_back($1); }
94 | stagelist stage { $$ = $1; if ($2) $$->push_back($2); }
97 stage: MNG_Stage '{' stagesettinglist '}' { $$ = new MNGStageNode(); ((MNGStageNode *)$$)->children = $3; }
98 | MNG_comment { $$ = 0; }
101 stagesettinglist: stagesetting { $$ = new std::list<MNGNode *>; if ($1) $$->push_back($1); }
102 | stagesettinglist stagesetting { $$ = $1; if ($2) $$->push_back($2); }
105 stagesetting: pan { $$ = $1; }
106 | effectvolume { $$ = $1; }
108 | tempodelay { $$ = $1; }
109 | MNG_comment { $$ = 0; }
112 pan: MNG_Pan '(' expression ')' { $$ = new MNGPanNode($3); }
115 effectvolume: MNG_Volume '(' expression ')' { $$ = new MNGEffectVolumeNode($3); }
118 layervolume: MNG_Volume '(' expression ')' { $$ = new MNGLayerVolumeNode($3); }
121 delay: MNG_Delay '(' expression ')' { $$ = new MNGDelayNode($3); }
124 tempodelay: MNG_TempoDelay '(' expression ')' { $$ = new MNGTempoDelayNode($3); }
127 random: MNG_Random '(' expression ',' expression ')' { $$ = new MNGRandomNode($3, $5); }
130 trackdec: MNG_Track '(' MNG_name ')' '{' track '}' { $$ = new MNGTrackDecNode($3); ((MNGTrackDecNode *)$$)->children = $6; }
133 track: tracksetting { $$ = new std::list<MNGNode *>; if ($1) $$->push_back($1); }
134 | track tracksetting { $$ = $1; if ($2) $$->push_back($2); }
137 tracksetting: aleotoriclayerdec { $$ = $1; }
138 | looplayerdec { $$ = $1; }
139 | fadein { $$ = $1; }
140 | fadeout { $$ = $1; }
141 | beatlength { $$ = $1; }
142 | layervolume { $$ = $1; }
143 | MNG_comment { $$ = 0; }
146 fadein: MNG_FadeIn '(' expression ')' { $$ = new MNGFadeInNode($3); }
149 fadeout: MNG_FadeOut '(' expression ')' { $$ = new MNGFadeOutNode($3); }
152 beatlength: MNG_BeatLength '(' expression ')' { $$ = new MNGBeatLengthNode($3); }
155 aleotoriclayerdec: MNG_AleotoricLayer '(' MNG_name ')' '{' aleotoriclayer '}' { $$ = new MNGAleotoricLayerNode($3); ((MNGAleotoricLayerNode *)$$)->children = $6; }
158 looplayerdec: MNG_LoopLayer '(' MNG_name ')' '{' looplayer '}' { $$ = new MNGLoopLayerNode($3); ((MNGLoopLayerNode *)$$)->children = $6; }
161 aleotoriclayer: aleotoriclayercommand { $$ = new std::list<MNGNode *>; if ($1) $$->push_back($1); }
162 | aleotoriclayer aleotoriclayercommand { $$ = $1; if ($2) $$->push_back($2); }
165 looplayer: looplayercommand { $$ = new std::list<MNGNode *>; if ($1) $$->push_back($1); }
166 | looplayer looplayercommand { $$ = $1; if ($2) $$->push_back($2); }
169 aleotoriclayercommand: effect { $$ = $1; }
170 | MNG_comment { $$ = 0; }
171 | layervolume { $$ = $1; }
172 | variabledec { $$ = $1; }
173 | updateblock { $$ = $1; }
174 | voiceblock { $$ = $1; }
175 | beatsynch { $$ = $1; }
176 | updaterate { $$ = $1; }
177 | interval { $$ = $1; }
180 looplayercommand: MNG_comment { $$ = 0; }
181 | layervolume { $$ = $1; }
182 | variabledec { $$ = $1; }
183 | updateblock { $$ = $1; }
184 | beatsynch { $$ = $1; }
186 | interval { $$ = $1; }
187 | updaterate { $$ = $1; }
190 effect: MNG_Effect '(' MNG_name ')' { $$ = new MNGEffectNode($3); }
193 updateblock: MNG_Update '{' assignmentlist '}' { $$ = new MNGUpdateNode(); ((MNGUpdateNode *)$$)->children = $3; }
196 assignmentlist: assignment { $$ = new std::list<MNGAssignmentNode *>; if ($1) $$->push_back($1); }
197 | assignmentlist assignment { $$ = $1; if ($2) $$->push_back($2); }
200 assignment: variable '=' expression { $$ = new MNGAssignmentNode($1, $3); }
201 | MNG_comment { $$ = 0; }
204 variable: MNG_name { $$ = new MNGVariableNode($1); }
205 | MNG_Interval { $$ = new MNGVariableNode(INTERVAL); }
206 | MNG_Volume { $$ = new MNGVariableNode(VOLUME); }
207 | MNG_Pan { $$ = new MNGVariableNode(PAN); }
210 expression: add { $$ = $1; }
211 | subtract { $$ = $1; }
212 | multiply { $$ = $1; }
213 | divide { $$ = $1; }
214 | sinewave { $$ = $1; }
215 | cosinewave { $$ = $1; }
216 | random { $$ = $1; }
217 | variable { $$ = $1; }
218 | MNG_number { $$ = new MNGConstantNode($1); }
221 add: MNG_Add '(' expression ',' expression ')' { $$ = new MNGAddNode($3, $5); }
224 subtract: MNG_Subtract '(' expression ',' expression ')' { $$ = new MNGSubtractNode($3, $5); }
227 multiply: MNG_Multiply '(' expression ',' expression ')' { $$ = new MNGMultiplyNode($3, $5); }
230 divide: MNG_Divide '(' expression ',' expression ')' { $$ = new MNGDivideNode($3, $5); }
233 sinewave: MNG_SineWave '(' expression ',' expression ')' { $$ = new MNGSineWaveNode($3, $5); }
236 cosinewave: MNG_CosineWave '(' expression ',' expression ')' { $$ = new MNGCosineWaveNode($3, $5); }
239 voiceblock: MNG_Voice '{' voicecommands '}' { $$ = new MNGVoiceNode(); ((MNGVoiceNode *)$$)->children = $3; }
242 voicecommands: voicecommand { $$ = new std::list<MNGNode *>; $$->push_back($1); }
243 | voicecommands voicecommand { $$ = $1; $$->push_back($2); }
246 voicecommand: wave { $$ = $1; }
247 | interval { $$ = $1; }
248 | effect { $$ = $1; }
249 | condition { $$ = $1; }
250 | updateblock { $$ = $1; }
253 interval: MNG_Interval '(' expression ')' { $$ = new MNGIntervalNode($3); }
256 condition: MNG_Condition '(' variable ',' MNG_number ',' MNG_number ')' { $$ = new MNGConditionNode($3, $5, $7); }
259 beatsynch: MNG_BeatSynch '(' expression ')' { $$ = new MNGUpdateRateNode($3); }
262 updaterate: MNG_UpdateRate '(' expression ')' { $$ = new MNGUpdateRateNode($3); }
265 wave: MNG_Wave '(' MNG_name ')' { $$ = new MNGWaveNode($3); }