%{ // -*-Fundamental-*-
/*
- parser.y -- lily parser
+ parser.y -- YACC parser for mudela
source file of the GNU LilyPond music typesetter
#include "input-translator.hh"
#include "score.hh"
#include "music-list.hh"
+#include "header.hh"
+#include "duration-convert.hh"
#ifndef NDEBUG
#define YYDEBUG 1
Music *music;
Music_list *musiclist;
Score *score;
+ Header *header;
Interval *interval;
Lookup*lookup;
Melodic_req * melreq;
%token CONSISTS
%token ACCEPTS
%token CM_T
-%token DURATIONCOMMAND
+%token DURATION
%token ABSDYNAMIC
%token END
%token GROUPING
%token GROUP
%token REQUESTTRANSLATOR
%token HSHIFT
+%token HEADER
%token IN_T
%token ID
%token LYRIC
%token MM_T
%token MULTI
%token NOTENAMES
-%token OCTAVECOMMAND
+%token OCTAVE
%token OUTPUT
%token PAPER
%token PARTIAL
%type <i> dots
%token <i> INT
%token <melreq> NOTENAME_ID
+%token <id> DURATION_IDENTIFIER
%token <id> IDENTIFIER
%token <id> MELODIC_REQUEST_IDENTIFIER
%token <id> MUSIC_IDENTIFIER
%token <id> REQUEST_IDENTIFIER
%token <real> REAL
%token <string> DURATION RESTNAME
-%token <string> STRING
+%token <string> STRING
+%token <string> FIELDNAME RECORDLINE
%token <i> POST_QUOTES
%token <i> PRE_QUOTES
+%type <header> mudela_header mudela_header_body
%type <box> box
%type <c> open_request_parens close_request_parens
%type <c> open_plet_parens close_plet_parens
%type <i> int
%type <i> script_dir
%type <id> identifier_init
-%type <duration> explicit_duration notemode_duration entered_notemode_duration
+%type <duration> explicit_steno_duration notemode_duration
+%type <duration> entered_notemode_duration explicit_duration
%type <interval> dinterval
%type <intvec> intastint_list
%type <lookup> symtables symtables_body
%type <paper> paper_block paper_body
%type <real> dim real
%type <real> unit
-%type <request> post_request pre_request command_req verbose_command_req abbrev_command_req
+%type <request> post_request pre_request command_req verbose_command_req
+%type <request> abbrev_command_req
%type <request> script_req dynamic_req
%type <score> score_block score_body
%type <script> script_definition script_body mudela_script gen_script_def
%type <symtable> symtable symtable_body
%type <itrans> input_translator_spec input_translator_spec_body
%type <tempo> tempo_request
+%type <string> header_record
%left PRIORITY
%%
mudela: /* empty */
+ | mudela mudela_header {
+ delete THIS->default_header_p_ ;
+ THIS->default_header_p_ = $2;
+ }
| mudela score_block {
add_score($2);
}
delete $2;
}
;
+
+mudela_header_body:
+ {
+ $$ = new Header;
+ }
+ | mudela_header_body FIELDNAME header_record {
+ (*$$)[*$2] = *$3;
+ delete $2;
+ delete $3;
+ }
+ ;
+
+mudela_header:
+ HEADER {
+ THIS->lexer_p_->push_header_state();
+ }
+
+ '{' mudela_header_body '}' {
+ $$ = $4;
+ THIS->lexer_p_->pop_state();
+ }
+ ;
+
+
+header_record:
+ {
+ $$ = new String;
+ }
+ | header_record RECORDLINE {
+ *$$ += *$2;
+ delete $2;
+ }
+ ;
+
/*
DECLARATIONS
*/
| input_translator_spec {
$$ = new Input_translator_id ( $1, INPUT_TRANS_IDENTIFIER);
}
+ | explicit_duration {
+ $$ = new Duration_id( $1, DURATION_IDENTIFIER);
+ }
;
SCORE
*/
score_block:
- SCORE { THIS->remember_spot(); }
+ SCORE { THIS->remember_spot();
+ THIS->error_level_i_ =0;
+ }
/*cont*/ '{' score_body '}' {
$$ = $4;
$$->set_spot(THIS->pop_spot());
/* handle error levels. */
$$->errorlevel_i_ = THIS->error_level_i_;
THIS->error_level_i_ = 0;
+ if (!$$->header_p_ && THIS->default_header_p_)
+ $$->header_p_ = new Header(*THIS->default_header_p_);
}
;
| SCORE_IDENTIFIER {
$$ = $1->score();
}
+ | score_body mudela_header {
+ $$->header_p_ = $2;
+ }
| score_body Music {
$$->music_p_ = $2;
}
/* empty */ {
$$ = THIS->default_paper(); // paper / video / engrave
}
+ | PAPER_IDENTIFIER {
+ $$ = $1->paperdef();
+ }
| paper_body OUTPUT STRING ';' { $$->outfile_str_ = *$3;
delete $3;
}
}
;
+explicit_duration:
+ DURATION '{' int int '}' {
+ $$ = new Duration;
+ $$-> durlog_i_ = $3;
+ $$-> dots_i_ = $4;
+ }
+ ;
+
dynamic_req:
ABSDYNAMIC '{' int '}' {
Absolute_dynamic_req *ad_p = new Absolute_dynamic_req;
PLET INT '/' INT {
THIS->default_duration_.set_plet($2,$4);
}
- | DURATIONCOMMAND STRING {
+ | DURATION STRING {
THIS->set_duration_mode(*$2);
delete $2;
}
- | DURATIONCOMMAND entered_notemode_duration {
+ | DURATION entered_notemode_duration {
THIS->set_default_duration($2);
delete $2;
}
- | OCTAVECOMMAND {
+ | OCTAVE {
/*
This is weird, but default_octave_i_
is used in steno_note_req too
{
$$ = new Moment(0,1);
}
- | duration_length explicit_duration {
+ | duration_length explicit_steno_duration {
*$$ += $2->length();
}
;
$$ = new Duration(THIS->default_duration_);
$$->dots_i_ = $1;
}
- | explicit_duration {
+ | explicit_steno_duration {
THIS->set_last_duration($1);
$$ = $1;
}
}
;
-explicit_duration:
+explicit_steno_duration:
int {
$$ = new Duration;
if ( !Duration::duration_type_b($1) )
THIS->parser_error("Not a duration");
else {
- $$->type_i_ = $1;
+ $$->durlog_i_ = Duration_convert::i2_type($1);
}
}
- | explicit_duration '.' {
+ | DURATION_IDENTIFIER {
+ $$ = $1->duration();
+ }
+ | explicit_steno_duration '.' {
$$->dots_i_ ++;
}
- | explicit_duration '*' int {
+ | explicit_steno_duration '*' int {
$$->plet_.iso_i_ *= $3;
}
- | explicit_duration '/' int {
+ | explicit_steno_duration '/' int {
$$->plet_.type_i_ *= $3;
}
;