ANY_CHAR (.|\n)
WORD {A}([-_]{A}|{A})*
COMMAND \\{WORD}
-
+/* SPECIAL category is for every letter that needs to get passed to
+ * the parser rather than being redefinable by the user */
+SPECIAL [-+*/=<>{}!?_^'',.:]
+SHORTHAND (.|\\.)
UNSIGNED {N}+
E_UNSIGNED \\{N}+
FRACTION {N}+\/{N}+
INT -?{UNSIGNED}
REAL ({INT}\.{N}*)|(-?\.{N}+)
+STRICTREAL {UNSIGNED}\.{UNSIGNED}
WHITE [ \n\t\f\r]
HORIZONTALWHITE [ \t]
BLACK [^ \n\t\f\r]
yylval = SCM_UNSPECIFIED;
return FIGURE_OPEN;
}
+ \\\+ {
+ yylval = SCM_UNSPECIFIED;
+ return E_PLUS;
+ }
+ \\! {
+ yylval = SCM_UNSPECIFIED;
+ return E_EXCLAMATION;
+ }
+ \\\\ {
+ yylval = SCM_UNSPECIFIED;
+ return E_BACKSLASH;
+ }
+ [][] {
+ yylval = SCM_UNSPECIFIED;
+ return YYText ()[0];
+ }
}
<notes,figures>{
yylval = scan_fraction (YYText ());
return FRACTION;
}
- {UNSIGNED}/\/ | // backup rule
- {UNSIGNED} {
+ {STRICTREAL} {
+ yylval = scm_c_read_string (YYText ());
+ return REAL;
+ }
+ {UNSIGNED}/[/.] | // backup rule
+ {UNSIGNED} {
yylval = scm_c_read_string (YYText ());
return UNSIGNED;
}
yylval = scan_fraction (YYText ());
return FRACTION;
}
- {UNSIGNED}/\/ | // backup rule
+ {STRICTREAL} {
+ yylval = scm_c_read_string (YYText ());
+ return REAL;
+ }
+ {UNSIGNED}/[/.] | // backup rule
{UNSIGNED} {
yylval = scm_c_read_string (YYText ());
return UNSIGNED;
{COMMAND} {
return scan_escaped_word (YYText_utf8 () + 1);
}
- /* Characters needed to express durations, assignments, barchecks */
- [*.=|] {
+ \\.|\| {
+ // UTF-8 already covered by COMMAND
+ return scan_shorthand (YYText ());
+ }
+ /* Characters needed to express durations, assignments */
+ [*.=] {
yylval = SCM_UNSPECIFIED;
return YYText ()[0];
}
return STRING;
}
/* This should really just cover {} */
- . {
+ [{}] {
yylval = SCM_UNSPECIFIED;
- return YYText ()[0]; // above catches all multibytes.
+ return YYText ()[0];
}
}
<chords>{
yylval = SCM_UNSPECIFIED;
return CHORD_CARET;
}
- . {
- yylval = SCM_UNSPECIFIED;
- return YYText ()[0]; // WORD catches all multibyte.
- }
}
yylval = ly_string2scm (s);
return STRING;
}
- . {
+ [{}] {
yylval = SCM_UNSPECIFIED;
- return YYText ()[0]; // Above is catchall for multibyte
+ return YYText ()[0];
}
}
}
-[{}] {
- yylval = SCM_UNSPECIFIED;
- return YYText ()[0];
-}
-
--/\. | // backup rule
-[*:=] {
+-/\. { // backup rule
yylval = SCM_UNSPECIFIED;
return YYText ()[0];
}
-<INITIAL,notes,figures>. {
+<INITIAL,chords,lyrics,figures,notes>{SPECIAL} {
yylval = SCM_UNSPECIFIED;
return YYText ()[0];
}
-<INITIAL,lyrics,notes,figures>\\. {
- yylval = SCM_UNSPECIFIED;
- char c = YYText ()[1];
-
- switch (c) {
- case '>':
- return E_ANGLE_CLOSE;
- case '<':
- return E_ANGLE_OPEN;
- case '!':
- return E_EXCLAMATION;
- case '(':
- return E_OPEN;
- case ')':
- return E_CLOSE;
- case '[':
- return E_BRACKET_OPEN;
- case '+':
- return E_PLUS;
- case ']':
- return E_BRACKET_CLOSE;
- case '~':
- return E_TILDE;
- case '\\':
- return E_BACKSLASH;
-
- default:
- return E_CHAR;
- }
+<INITIAL,chords,lyrics,figures,notes>{SHORTHAND} {
+ return scan_shorthand (YYText_utf8 ()); // should not be utf-8
}
<*>.[\200-\277]* {
return STRING;
}
+int
+Lily_lexer::scan_shorthand (string str)
+{
+ SCM sid = lookup_identifier (str);
+ if (Music *m = unsmob_music (sid))
+ {
+ m->set_spot (override_input (last_input_));
+ }
+
+ if (sid != SCM_UNDEFINED)
+ return scan_scm_id (sid);
+
+ string msg (_f ("undefined character or shorthand: %s", str));
+ LexerError (msg.c_str ());
+
+ yylval = ly_string2scm (str);
+
+ return STRING;
+}
+
int
Lily_lexer::scan_scm_id (SCM sid)
{