#include "context-def.hh"
#include "duration.hh"
-#include "identifier-smob.hh"
#include "international.hh"
#include "interval.hh"
#include "lily-guile.hh"
ANY_CHAR (.|\n)
PUNCT [?!:'`]
ACCENT \\[`'"^]
+SPECIAL_CHAR [&@]
NATIONAL [\001-\006\021-\027\031\036]
-TEX {AA}|-|{PUNCT}|{ACCENT}|{NATIONAL}
+TEX {AA}|-|{PUNCT}|{ACCENT}|{NATIONAL}|{SPECIAL_CHAR}
DASHED_WORD {A}({AN}|-)*
DASHED_KEY_WORD \\{DASHED_WORD}
be_safe_global && is_main_input_, parser_);
if (sval == SCM_UNDEFINED)
- {
- sval = SCM_UNSPECIFIED;
error_level_ = 1;
- }
for (int i = 0; i < n; i++)
{
}
char_count_stack_.back () += n;
- if (unpack_identifier (sval) != SCM_UNDEFINED)
- {
- yylval.scm = unpack_identifier(sval);
- return identifier_type (yylval.scm);
- }
-
for (size_t i = 0; i < pending_string_includes_.size (); i++)
new_input ("<included string>", pending_string_includes_[i],
parser_->sources_);
yylval.scm = sval;
return SCM_TOKEN;
}
+
+<INITIAL,chords,figures,lyrics,markup,notes>\$ { //immediate scm
+ int n = 0;
+ Input hi = here_input();
+ hi.step_forward ();
+ SCM sval = ly_parse_scm (hi.start (), &n, hi,
+ be_safe_global && is_main_input_, parser_);
+ sval = eval_scm (sval);
+
+ for (int i = 0; i < n; i++)
+ {
+ yyinput ();
+ }
+ char_count_stack_.back () += n;
+
+ return scan_scm_id (sval);
+}
+
<INITIAL,notes,lyrics>{
\<\< {
return DOUBLE_ANGLE_OPEN;
}
{UNSIGNED}/\/ | // backup rule
{UNSIGNED} {
- yylval.i = String_convert::dec2int (string (YYText ()));
+ yylval.scm = scm_c_read_string (YYText ());
return UNSIGNED;
}
{E_UNSIGNED} {
return FRACTION;
}
{UNSIGNED}/\/[^0-9] { // backup rule
- yylval.i = String_convert::dec2int (string (YYText ()));
+ yylval.scm = scm_c_read_string (YYText ());
return UNSIGNED;
}
{UNSIGNED}/\/ | // backup rule
{UNSIGNED} {
- yylval.i = String_convert::dec2int (string (YYText ()));
+ yylval.scm = scm_c_read_string (YYText ());
return UNSIGNED;
}
{NOTECOMMAND} {
return FRACTION;
}
{UNSIGNED}/\/[^0-9] { // backup rule
- yylval.i = String_convert::dec2int (string (YYText ()));
+ yylval.scm = scm_c_read_string (YYText ());
return UNSIGNED;
}
{UNSIGNED}/\/ | // backup rule
{UNSIGNED} {
- yylval.i = String_convert::dec2int (string (YYText ()));
+ yylval.scm = scm_c_read_string (YYText ());
return UNSIGNED;
}
- {
else if (predicate == ly_lily_module_constant ("markup?"))
push_extra_token(EXPECT_MARKUP);
else
- push_extra_token(EXPECT_SCM);
+ push_extra_token(EXPECT_SCM, predicate);
}
return token_type;
}
[{}] {
return YYText ()[0];
}
- [^#{}\"\\ \t\n\r\f]+ {
+ [^$#{}\"\\ \t\n\r\f]+ {
string s (YYText ());
char c = s[s.length () - 1];
-{UNSIGNED} | // backup rule
{REAL} {
- Real r;
- int cnv = sscanf (YYText (), "%lf", &r);
- assert (cnv == 1);
- (void) cnv;
-
- yylval.scm = scm_from_double (r);
+ yylval.scm = scm_c_read_string (YYText ());
return REAL;
}
-\. { // backup rule
}
{UNSIGNED} {
- yylval.i = String_convert::dec2int (string (YYText ()));
+ yylval.scm = scm_c_read_string (YYText ());
return UNSIGNED;
}
return i;
SCM sid = lookup_identifier (str);
+ if (sid != SCM_UNDEFINED)
+ return scan_scm_id (sid);
+
+ string msg (_f ("unknown escaped string: `\\%s'", str));
+ LexerError (msg.c_str ());
+
+ yylval.scm = ly_string2scm (str);
+
+ return STRING;
+}
+
+int
+Lily_lexer::scan_scm_id (SCM sid)
+{
if (is_music_function (sid))
{
int funtype = SCM_FUNCTION;
push_extra_token (EXPECT_NO_MORE_ARGS);
for (s = scm_cdr (s); scm_is_pair (s); s = scm_cdr (s))
{
+ SCM optional = SCM_UNDEFINED;
cs = scm_car (s);
+
+ if (scm_is_pair (cs))
+ {
+ optional = SCM_CDR (cs);
+ cs = SCM_CAR (cs);
+ }
- if (cs == ly_music_p_proc)
- push_extra_token (EXPECT_MUSIC);
- else if (cs == Pitch_type_p_proc)
+ if (cs == Pitch_type_p_proc)
push_extra_token (EXPECT_PITCH);
else if (cs == Duration_type_p_proc)
push_extra_token (EXPECT_DURATION);
- else if (cs == ly_lily_module_constant ("markup?"))
- push_extra_token (EXPECT_MARKUP);
else if (ly_is_procedure (cs))
- push_extra_token (EXPECT_SCM);
- else programming_error ("Function parameter without type-checking predicate");
+ push_extra_token (EXPECT_SCM, cs);
+ else
+ {
+ programming_error ("Function parameter without type-checking predicate");
+ continue;
+ }
+ if (!scm_is_eq (optional, SCM_UNDEFINED))
+ push_extra_token (EXPECT_OPTIONAL, optional);
}
return funtype;
}
-
- if (sid != SCM_UNDEFINED)
- {
- yylval.scm = sid;
- return identifier_type (sid);
- }
-
- string msg (_f ("unknown escaped string: `\\%s'", str));
- LexerError (msg.c_str ());
-
- yylval.scm = ly_string2scm (str);
-
- return STRING;
+ yylval.scm = sid;
+ return identifier_type (sid);
}
int
return get_state () == figures;
}
+SCM
+Lily_lexer::eval_scm (SCM readerdata)
+{
+ SCM sval = SCM_UNDEFINED;
+
+ if (!SCM_UNBNDP (readerdata))
+ {
+ sval = ly_eval_scm (scm_car (readerdata),
+ *unsmob_input (scm_cdr (readerdata)),
+ be_safe_global && is_main_input_,
+ parser_);
+ }
+
+ if (SCM_UNBNDP (sval))
+ {
+ error_level_ = 1;
+ return SCM_UNSPECIFIED;
+ }
+ return sval;
+}
+
+
+
/*
urg, belong to string (_convert)
and should be generalised