token for origin information.
* lily/parser.yy (My_lily_lexer): do identifier location and
cloning from lexer.
* scm/music-functions.scm (make-multi-measure-rest): move mmrest
logic out of the parser.
* Documentation/user/refman.itely (Multi measure rests): add more
notes about mm rests.
+2002-10-11 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ * lily/my-lily-lexer.cc (prepare_for_next_token): use previous
+ token for origin information.
+
+ * lily/parser.yy (My_lily_lexer): do identifier location and
+ cloning from lexer.
+
+ * scm/music-functions.scm (make-multi-measure-rest): move mmrest
+ logic out of the parser.
+
+ * Documentation/user/refman.itely (Multi measure rests): add more
+ notes about mm rests.
+
2002-10-10 Jan Nieuwenhuizen <janneke@gnu.org>
* input/regression/bar-scripts.ly: Re-enable.
Bar numbers are printed by default at the start of the line. The
number itself is a property that can be set by modifying the
-@code{currentBarNumber} property, i.e.
+@code{currentBarNumber} property, although that is usually not
+necessary, i.e.
@example
\property Score.currentBarNumber = #217
@end example
automatically.
@lilypond[fragment,verbatim]
- \time 3/4 r2. | R2. | R2.*2
- \property Score.skipBars = ##t R2.*17 R2.*4
+ \time 4/4 r1 | R1 | R1*2
+ \property Score.skipBars = ##t R1*17 R1*4
@end lilypond
-Notice that the @code{R2.} is printed as a whole rest, centered in the
-measure.
+The @code{1} in @code{R1} is similar to the duration notation used for
+notes. Hence, for time signatures other than 4/4, you must enter other
+durations. This can be done with augmentation dots, or with
+fractions:
+
+@lilypond[fragment,verbatim]
+ \property Score.skipBars = ##t
+ \time 3/4
+ R2. | R2.*2
+ \time 13/8
+ R1*13/8
+ R1*13/8*12
+@end lilypond
+Notice that a @code{R} spanning a single measure is printed as a whole
+rest centered in the measure, regardless of the time signature.
+
+[ add note about breves.]
+
@cindex whole rests for a full measure
Currently, there is no way to automatically condense multiple rests
into a single multimeasure rest. Multi measure rests do not take part
-in rest collisions.
+in rest collisions. There is no way to put texts centered on
+multi-measure rests.
@cindex condensing rests
The DVI file (@file{test.dvi}) contains the same sheet music in a
different format. DVI files are more easily processed by the computer,
so viewing them usually is quicker. You can run @code{xdvi test.dvi} or
-@code{kdvi test.dvi} to view the DVI file. In Xdvi, the mouse buttons
+@code{kdvi test.dvi} to view the DVI file. In Xdvi, the mouse burtons
activate magnifying glasses. Unfortunately, variable symbols (such as
beams and slurs) are not displayed in the magnifying glasses.
#include <FlexLexer.h>
+#include "input.hh"
#include "dictionary.hh"
#include "lily-proto.hh"
#include "flower-proto.hh"
~My_lily_lexer ();
int yylex ();
+ Input last_input_;
+ void prepare_for_next_token ();
+ int try_special_identifiers (SCM* ,SCM);
Input here_input () const;
-
+
void add_scope (SCM);
SCM remove_scope ();
}
LY_DEFINE(ly_input_message, "ly-input-message", 2, 0, 0, (SCM sip, SCM msg),
- "Print @var{msg} as a GNU compliant error message, pointing to the
-location in @var{sip}.")
+ "Print @var{msg} as a GNU compliant error message, pointing to the\n"
+ "location in @var{sip}.\n"
+ )
{
Input *ip = unsmob_input(sip);
scm_set_smob_free (input_tag, free_smob);
scm_set_smob_print (input_tag, print_smob);
scm_set_smob_equalp (input_tag, 0);
-
-
}
SCM
#include <iostream>
#include "parse-scm.hh"
-#include "score.hh"
#include "lily-guile.hh"
#include "string.hh"
#include "string-convert.hh"
#include "parser.hh"
#include "warn.hh"
#include "main.hh"
-#include "event.hh"
#include "version.hh"
#include "lilypond-input-version.hh"
#include "translator-def.hh"
-#include "music-output-def.hh"
#include "identifier-smob.hh"
/*
int
My_lily_lexer::identifier_type(SCM sid)
{
- if (gh_string_p (sid)) {
- yylval.scm = sid;
- return STRING_IDENTIFIER;
- } else if (gh_number_p (sid)) {
- yylval.scm = sid;
- return NUMBER_IDENTIFIER;
- } else if (unsmob_translator_def (sid)) {
- yylval.scm = sid;
- return TRANSLATOR_IDENTIFIER;
- } else if (unsmob_score (sid)) {
- yylval.scm =sid;
- return SCORE_IDENTIFIER;
- } else if (Music * mus =unsmob_music (sid)) {
- yylval.scm = sid;
-
- return dynamic_cast<Event*> (mus) ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
- } else if (unsmob_duration (sid)) {
- yylval.scm = sid;
- return DURATION_IDENTIFIER;
- } else if (unsmob_music_output_def (sid)) {
- yylval.scm = sid;
- return MUSIC_OUTPUT_DEF_IDENTIFIER;
- }
- return SCM_IDENTIFIER;
+ int k = try_special_identifiers(&yylval.scm , sid);
+ return k >= 0 ? k : SCM_IDENTIFIER;
}
// to do property args
LY_DEFINE(ly_extended_make_music,
"ly-make-bare-music", 2, 0, 0, (SCM type, SCM props),
- "
-Make a music object/expression of type @var{type}, init with
-@var{props}. Warning: this interface will likely change in the near
-future.
-
-Music is the data type that music expressions are stored in. The data
-type does not yet offer many manipulations.
-
-WARNING: deprecated; use make-music-by-name.
-")
+ "Make a music object/expression of type @var{type}, init with\n"
+"@var{props}. Warning: this interface will likely change in the near\n"
+"future.\n"
+"\n"
+"Music is the data type that music expressions are stored in. The data\n"
+"type does not yet offer many manipulations.\n"
+"\n"
+"WARNING: only for internal use. Please use make-music-by-name. \n"
+)
{
SCM_ASSERT_TYPE(gh_string_p (type), type, SCM_ARG1, __FUNCTION__, "string");
// to do property args
LY_DEFINE(ly_get_mutable_properties,
"ly-get-mutable-properties", 1, 0, 0, (SCM mus),
- "
-Return an alist signifying the mutable properties of @var{mus}.
-The immutable properties are not available; they should be initialized
-by the functions make-music-by-name function.
- ")
+"Return an alist signifying the mutable properties of @var{mus}.\n"
+"The immutable properties are not available; they should be initialized\n"
+"by the functions make-music-by-name function.\n"
+)
{
Music *m = unsmob_music (mus);
SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "music");
else
{
errorlevel_ |= 1;
- Input spot (get_source_file (),here_str0 ());
+ Input spot (get_source_file (), here_str0 ());
spot.error (s);
}
}
Source_file * f= get_source_file ();
return Input (f, (char*)here_str0 ());
}
+
+void
+My_lily_lexer::prepare_for_next_token ()
+{
+ last_input_ = here_input();
+}
Input
My_lily_parser::here_input () const
{
- return lexer_->here_input ();
+ /*
+ Parsing looks ahead , so we really want the previous location of the
+ lexer, not lexer_->here_input().
+ */
+ return lexer_->last_input_;
}
-// move me?
#include "paper-def.hh"
#include "translator-def.hh"
#include "chord.hh"
#include "ly-modules.hh"
#include "music-sequence.hh"
+#include "input-smob.hh"
+#include "event.hh"
bool
regular_identifier_b (SCM id)
My_lily_lexer * lex = pars->lexer_;
lex->lexval = (void*) s;
+ lex->prepare_for_next_token();
return lex->yylex ();
}
translator_spec_body:
TRANSLATOR_IDENTIFIER {
- $$ = unsmob_translator_def ($1)->clone_scm ();
+ $$ = $1;
unsmob_translator_def ($$)-> set_spot (THIS->here_input ());
}
| TYPE STRING {
}
| SCORE_IDENTIFIER {
- $$ = new Score (*unsmob_score ($1));
+ $$ = unsmob_score ($1);
$$->set_spot (THIS->here_input ());
}
| score_body lilypond_header {
p = dynamic_cast<Paper_def*> (id->clone ());
else
p = new Paper_def;
- THIS-> lexer_->add_scope (p->scope_);
+
+ THIS->lexer_->add_scope (p->scope_);
$$ = p;
}
| PAPER '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
- Music_output_def *p = unsmob_music_output_def ($3);
- p = p->clone ();
- THIS->lexer_->add_scope (p->scope_);
- $$ = p;
+ Music_output_def * o = unsmob_music_output_def ($3);
+ $$ =o;
+
+ THIS->lexer_->add_scope (o->scope_);
}
| MIDI '{' MUSIC_OUTPUT_DEF_IDENTIFIER {
- Music_output_def *p = unsmob_music_output_def ($3);
- p = p->clone ();
+ Music_output_def * o = unsmob_music_output_def ($3);
+ $$ = o;
- THIS->lexer_->add_scope (p->scope_);
- $$ = p;
+ THIS->lexer_->add_scope (o->scope_);
}
| music_output_def_body assignment {
$$ = m;
}
| MUSIC_IDENTIFIER {
- $$ = unsmob_music ($1)->clone ();
-
- $$->set_spot (THIS->here_input());
+ $$ = unsmob_music ($1);
}
| property_def
| translator_change
verbose_event:
EVENT_IDENTIFIER {
- $$ = unsmob_music ($1)->clone ();
- $$->set_spot (THIS->here_input ());
+ $$ = unsmob_music ($1);
}
| SPANREQUEST bare_int STRING {
Music * sp = make_span_req ($3);
| DURATION_IDENTIFIER dots {
Duration *d =unsmob_duration ($1);
Duration k (d->duration_log (),d->dot_count () + $2);
- $$ = k.smobbed_copy ();
+
+ *d = k;
+ $$ = $1;
}
;
| MULTI_MEASURE_REST optional_notemode_duration {
THIS->pop_spot ();
- Music * sk = MY_MAKE_MUSIC("SkipEvent");
- sk->set_mus_property ("duration", $2);
- Music *sp1 = MY_MAKE_MUSIC("MultiMeasureRestEvent");
- Music *sp2 = MY_MAKE_MUSIC("MultiMeasureRestEvent");
- sp1-> set_mus_property ("span-direction", gh_int2scm (START))
-;
- sp2-> set_mus_property ("span-direction", gh_int2scm (STOP))
-;
- Music *rqc1 = MY_MAKE_MUSIC("EventChord");
- rqc1->set_mus_property ("elements", scm_list_n (sp1->self_scm (), SCM_UNDEFINED));
- Music *rqc2 = MY_MAKE_MUSIC("EventChord");
- rqc2->set_mus_property ("elements", scm_list_n (sk->self_scm (), SCM_UNDEFINED));;
- Music *rqc3 = MY_MAKE_MUSIC("EventChord");
- rqc3->set_mus_property ("elements", scm_list_n (sp2->self_scm (), SCM_UNDEFINED));;
-
- SCM ms = scm_list_n (rqc1->self_scm (), rqc2->self_scm (), rqc3->self_scm (), SCM_UNDEFINED);
+ static SCM proc ;
+ if (!proc)
+ proc = scm_c_eval_string ("make-multi-measure-rest");
- $$ = MY_MAKE_MUSIC("SequentialMusic");
- $$->set_mus_property ("elements", ms);
+ SCM mus = scm_call_2 (proc, $2,
+ make_input (THIS->here_input()));
+ scm_gc_protect_object (mus);
+ $$ = unsmob_music (mus);
}
| STRING optional_notemode_duration {
Input i = THIS->pop_spot ();
}
last_beam_start_ = SCM_EOL;
}
+
+
+/*
+It is a little strange, to have this function in this file, but
+otherwise, we have to import music classes into the lexer.
+
+*/
+int
+My_lily_lexer::try_special_identifiers (SCM * destination, SCM sid)
+{
+ if (gh_string_p (sid)) {
+ *destination = sid;
+ return STRING_IDENTIFIER;
+ } else if (gh_number_p (sid)) {
+ *destination = sid;
+ return NUMBER_IDENTIFIER;
+ } else if (unsmob_translator_def (sid)) {
+ *destination = unsmob_translator_def (sid)->clone_scm();
+ return TRANSLATOR_IDENTIFIER;
+ } else if (unsmob_score (sid)) {
+ Score *sc = new Score (*unsmob_score (sid));
+ *destination =sc->self_scm ();
+ return SCORE_IDENTIFIER;
+ } else if (Music * mus =unsmob_music (sid)) {
+ *destination = unsmob_music (sid)->clone ()->self_scm();
+ unsmob_music (*destination)->
+ set_mus_property ("origin", make_input (last_input_));
+ return dynamic_cast<Event*> (mus)
+ ? EVENT_IDENTIFIER : MUSIC_IDENTIFIER;
+ } else if (unsmob_duration (sid)) {
+ *destination = unsmob_duration (sid)->smobbed_copy();
+ return DURATION_IDENTIFIER;
+ } else if (unsmob_music_output_def (sid)) {
+ Music_output_def *p = unsmob_music_output_def (sid);
+ p = p->clone ();
+
+ *destination = p->self_scm();
+ return MUSIC_OUTPUT_DEF_IDENTIFIER;
+ }
+ return -1;
+}
m
))
+(define-public (make-event-chord elts)
+ (let* ((m (make-music-by-name 'EventChord)))
+ (ly-set-mus-property! m 'elements elts)
+ m
+ ))
+
+
+(define-public (make-multi-measure-rest duration location)
+ (let*
+ (
+ (start (make-music-by-name 'MultiMeasureRestEvent))
+ (stop (make-music-by-name 'MultiMeasureRestEvent))
+ (skip ( make-music-by-name 'SkipEvent))
+ (ch (make-music-by-name 'BarCheck))
+ (ch2 (make-music-by-name 'BarCheck))
+ )
+
+ (ly-set-mus-property! start 'span-direction START)
+ (ly-set-mus-property! stop 'span-direction STOP)
+ (ly-set-mus-property! skip 'duration duration)
+ (map (lambda (x) (ly-set-mus-property! x 'origin location))
+ (list start stop skip ch ch2))
+ (make-sequential-music
+ (list
+ ch
+ (make-event-chord (list start))
+ (make-event-chord (list skip))
+ (make-event-chord (list stop))
+ ch2
+ ))
+ ))
+
(define-public (set-mus-properties! m alist)
+ "Set all of ALIST as properties of M."
(if (pair? alist)
(begin
(ly-set-mus-property! m (caar alist) (cdar alist))
))
(define-public (music-separator? m)
- "Is M a separator."
+ "Is M a separator?"
(let* ((ts (ly-get-mus-property m 'types )))
(memq 'separator ts)
))
; switch-on-debugging
))
+