home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.ee.lbl.gov
/
2014.05.ftp.ee.lbl.gov.tar
/
ftp.ee.lbl.gov
/
bmd-1.0beta.tar.Z
/
bmd-1.0beta.tar
/
bmd-1.0beta
/
app
/
omtd
/
parse.y
< prev
next >
Wrap
Text File
|
1991-03-14
|
4KB
|
176 lines
/*
* Copyright (c) 1990 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Lawrence Berkeley Laboratory,
* Berkeley, CA. The name of the University may not be used to
* endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/*
* Built-in keywords.
*/
%token TK_QUIT TK_RUN TK_STOP TK_PRINT TK_MERGE TK_TEMPO TK_DUMP TK_ECHO
%token TK_CHANNEL TK_CLICK TK_DELETE TK_COPY TK_MUTE TK_UNMUTE TK_QUANTIZE
%token TK_SAVE TK_LOAD TK_TRACKS TK_NEW TK_INSERT TK_VOLUME TK_TRANS
%token TK_SET TK_SETTING TK_OFF TK_CLEAR TK_MOVE
%token TK_ID TK_INT TK_REAL TK_STRING
%token TK_EOF
%{
#include <sys/types.h>
#include "setting.h"
#include "track.h"
#define YYDEBUG
char *prompt = "(mtd) ";
%}
%union {
int i;
char *s;
float f;
struct track *trk;
struct {
int s, e;
} w;
};
%type <trk> ntrack track
%type <i> TK_INT channel opt_repeat opt_time time
%type <s> TK_ID
%type <w> win opt_win
%%
input: prompt line newline
| input line newline
;
line: /* null */
| command
| error
;
newline: '\n' prompt
;
prompt: /* null */ { fputs(prompt, stdout); fflush(stdout); }
;
command: c.run
| c.quit
| c.merge
| c.channel
| c.tracks
| c.new
| c.copy
| c.echo
| c.click
| c.save
| c.load
| c.quantize
| c.tempo
| c.clear
| c.mute
| c.delete
| c.dump
;
c.dump: TK_DUMP track { dump_command($2); }
;
c.run: TK_RUN { run_command(0, (void *)0); }
| TK_RUN time { run_command($2, (void *)0); }
| TK_RUN track { run_command(0, $2); }
| TK_RUN track time { run_command($3, $2); }
;
c.quit: TK_QUIT { exit(0); }
;
c.merge: TK_MERGE ntrack { merge_command($2); }
;
c.channel:
TK_CHANNEL ntrack channel
{ channel_command($2, $3); }
;
c.tracks: TK_TRACKS { tracks_command(); }
;
c.new: TK_NEW { new_command(); }
;
c.copy: TK_COPY opt_repeat track opt_win ntrack opt_time
{
if ($3)
copy_command($3, $4.s, $4.e, $5, $6, $2);
}
c.echo: TK_ECHO { echo_command(-1); }
| TK_ECHO TK_INT { echo_command($2); }
;
c.click: TK_CLICK TK_OFF { click_off(); }
| TK_CLICK { click_on(-1, -1); }
| TK_CLICK TK_INT { click_on($2, -1); }
| TK_CLICK TK_INT TK_INT { click_on($2, $3); }
;
c.save: TK_SAVE TK_ID { save_command($2); }
;
c.load: TK_LOAD TK_ID { load_command($2); }
;
c.quantize:
TK_QUANTIZE track TK_INT '/' TK_INT
{
if ($2)
quantize_command($2, $3, $5);
}
;
c.tempo: TK_TEMPO TK_INT { tempo_command($2); }
;
c.clear: TK_CLEAR track opt_win { clear_command($2, $3.s, $3.e); }
;
c.move: TK_MOVE time time { move_command($2, $3); }
| TK_MOVE time { move_command($2, 0); }
;
c.delete: TK_DELETE track { clear_command($2, 0, ~0);
delete_command($2); }
;
c.mute: TK_UNMUTE track { mute_command($2, 0); }
| TK_MUTE track { mute_command($2, 1); }
;
opt_repeat:
/* null */ { $$ = 1; }
| TK_INT
| ':' TK_INT { $$ = $2; }
;
opt_time: /* null */ { $$ = 0; }
| time
;
opt_win: /* null */ { $$.s = 0; $$.e = ~0; }
| time { $$.s = $1; $$.e = ~0; }
| win
;
win: time ',' time { $$.s = $1; $$.e = $3; }
;
track: TK_ID { $$ = find_track($1); }
;
ntrack: TK_ID { $$ = lookup_track($1, s.echo_channel); }
;
channel: TK_INT
;
time: TK_INT { $$ = ttt($1, 0, 0); }
| TK_INT ':' TK_INT { $$ = ttt($1, $3, 0); }
| TK_INT ':' TK_INT ':' TK_INT { $$ = ttt($1, $3, $5); }
;
%%
yyerror(s)
char *s;
{
printf("syntax error\n");
}
ttt(bar, beat, tick)
int bar, beat, tick;
{
return tick + s.ticks_per_beat * (beat + bar * s.beats_per_bar);
}