source file of the LilyPond music typesetter
- (c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1996--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
Jan Nieuwenhuizen <janneke@gnu.org>
*/
*/
-#include <stdio.h>
-#include <ctype.h>
-#include <errno.h>
+
+#include <cstdio>
+#include <cctype>
+#include <cerrno>
/* Flex >= 2.5.29 fix; FlexLexer.h's multiple include bracing breaks
when building the actual lexer. */
#define LEXER_CC
#include <iostream>
-
using namespace std;
#include "music-function.hh"
%x markup
%x notes
%x quote
-%x renameinput
+%x sourcefilename
%x version
A [a-zA-Z]
ESCAPED [nt\\'"]
EXTENDER __
HYPHEN --
+BOM_UTF8 \357\273\277
%%
// windows-suck-suck-suck
}
+<INITIAL,chords,lyrics,figures,notes>{BOM_UTF8} {
+ if (this->lexloc->line_number () != 1 || this->lexloc->column_number () != 0)
+ {
+ LexerError (_ ("stray UTF-8 BOM encountered").c_str ());
+ exit (1);
+ }
+ if (be_verbose_global)
+ message (_ ("Skipping UTF-8 BOM"));
+}
+
<INITIAL,chords,figures,incl,lyrics,markup,notes>{
"%{" {
yy_push_state (longcomment);
<INITIAL,chords,lyrics,notes,figures>\\version{WHITE}* {
yy_push_state (version);
}
-<INITIAL,chords,lyrics,notes,figures>\\renameinput{WHITE}* {
- yy_push_state (renameinput);
+<INITIAL,chords,lyrics,notes,figures>\\sourcefilename{WHITE}* {
+ yy_push_state (sourcefilename);
}
<version>\"[^"]*\" { /* got the version number */
String s (YYText () + 1);
scm_module_define (top_scope, ly_symbol2scm ("version-seen?"), SCM_BOOL_T);
}
-<renameinput>\"[^"]*\" {
+<sourcefilename>\"[^"]*\" {
String s (YYText () + 1);
s = s.left_string (s.index_last ('\"'));
- yy_pop_state();
- this->here_input().source_file_->name_ = s;
- progress_indication (_f ("Renaming input to: `%s'", s.to_str0 ()));
+ yy_pop_state ();
+ this->here_input().get_source_file ()->name_ = s;
+ message (_f ("Renaming input to: `%s'", s.to_str0 ()));
progress_indication ("\n");
scm_module_define (scm_car (scopes_),
ly_symbol2scm ("input-file-name"),
}
<version>. {
- LexerError (_ ("No quoted string found after \\version").to_str0 ());
+ LexerError (_ ("quoted string expected after \\version").c_str ());
yy_pop_state ();
}
-<renameinput>. {
- LexerError (_ ("No quoted string found after \\renameinput").to_str0 ());
+<sourcefilename>>. {
+ LexerError (_ ("quoted string expected after \\sourcefilename").c_str ());
yy_pop_state ();
}
<longcomment>{
yy_pop_state ();
}
<<EOF>> {
- LexerError (_ ("EOF found inside a comment").to_str0 ());
+ LexerError (_ ("EOF found inside a comment").c_str ());
is_main_input_ = false;
if (! close_input ())
yyterminate (); // can't move this, since it actually rets a YY_NULL
}
}
<incl>\"[^"]* { // backup rule
- error (_ ("Missing end quote"));
+ error (_ ("end quote missing"));
exit (1);
}
<chords,notes,figures>{RESTNAME} {
- const char *s = YYText ();
+ char const *s = YYText ();
yylval.scm = scm_makfrom0str (s);
return RESTNAME;
}
int n = 0;
Input hi = here_input();
hi.step_forward ();
- SCM sval = ly_parse_scm (hi.start_, &n, hi,
+ SCM sval = ly_parse_scm (hi.start (), &n, hi,
be_safe_global && is_main_input_);
if (sval == SCM_UNDEFINED)
else if (tag == ly_symbol2scm ("scheme0-scheme1-scheme2"))
return MARKUP_HEAD_SCM0_SCM1_SCM2;
else {
- programming_error ("No parser tag defined for this signature. Abort");
+ programming_error ("no parser tag defined for this markup signature");
ly_display_scm (s);
assert(false);
}
Real r;
int cnv = sscanf (YYText (), "%lf", &r);
assert (cnv == 1);
+ (void) cnv;
- yylval.scm = scm_make_real (r);
+ yylval.scm = scm_from_double (r);
return REAL;
}
switch (c) {
case '>':
- return E_BIGGER;
+ return E_ANGLE_CLOSE;
case '<':
- return E_SMALLER;
+ return E_ANGLE_OPEN;
case '!':
return E_EXCLAMATION;
case '(':
case ')':
return E_CLOSE;
case '[':
- return E_LEFTSQUARE;
+ return E_BRACKET_OPEN;
+ case '+':
+ return E_PLUS;
case ']':
- return E_RIGHTSQUARE;
+ return E_BRACKET_CLOSE;
case '~':
return E_TILDE;
case '\\':
int n = String_convert::dec2int (left);
int d = String_convert::dec2int (right);
- return scm_cons (scm_int2num (n), scm_int2num (d));
+ return scm_cons (scm_from_int (n), scm_from_int (d));
}
-// Breaks for flex 2.5.31
-#if 0
-/* avoid silly flex induced gcc warnings */
-static void yy_push_state (int) {;}
-static void yy_pop_state () {;}
-static int yy_top_state () { return 0; }
-
-static void
-avoid_silly_flex_induced_gcc_warnings ()
-{
- (void)yy_start_stack_ptr;
- (void)yy_start_stack_depth;
- (void)yy_start_stack;
- yy_push_state (0);
- yy_pop_state ();
- yy_top_state ();
- avoid_silly_flex_induced_gcc_warnings ();
-}
-#endif
-
SCM
lookup_markup_command (String s)
{
{
return MUSIC_FUNCTION_SCM_SCM_MUSIC;
}
+ else if (type == ly_symbol2scm ("scm-scm-scm"))
+ {
+ return MUSIC_FUNCTION_SCM_SCM_SCM;
+ }
else if (type == ly_symbol2scm ("markup"))
{
return MUSIC_FUNCTION_MARKUP;
else
{
/* TODO: print location */
- error ("Can not find signature for music function.");
+ error (_ ("can't find signature for music function"));
}
return MUSIC_FUNCTION_SCM;
}
+
+/* Shut up lexer warnings. */
+#if YY_STACK_USED
+
+static void
+yy_push_state (int)
+{
+}
+
+static void
+yy_pop_state ()
+{
+}
+
+static int
+yy_top_state ()
+{
+ return 0;
+}
+
+static void
+silence_lexer_warnings ()
+{
+ (void) yy_start_stack_ptr;
+ (void) yy_start_stack_depth;
+ (void) yy_start_stack;
+ (void) yy_push_state;
+ (void) yy_pop_state;
+ (void) yy_top_state;
+ (void) silence_lexer_warnings;
+}
+#endif