#include "Highlight.hpp"
+#include "IdentifierStart.h"
+#include "IdentifierContinue.h"
+
#define YY_EXTRA_TYPE CYDriver *
#define F(value, highlight) do { \
} else _assert(false);
}
-static void U(char *&local, const char *text, yy_size_t &i) {
+static unsigned U(char *&local, const char *text, yy_size_t &i) {
unsigned point;
char next(text[++i]);
}
U(local, point);
+ return point;
}
#define CYLexBufferPoint(point) do { \
}
/* }}} */
/* Comment {{{ */
-#![^\n]* L M
-\/\/[^\n]* L M
+ /* XXX: maybe fold LineTerminatorSequence into these definitions */
+#!{NoneTerminatorCharacter}* L M
+\/\/{NoneTerminatorCharacter}* L M
+(#!|\/\/){NoneTerminatorCharacter}*{UnicodeError} L E("invalid character");
\/\* L yy_push_state(MultiLine, yyscanner);
"set" L /*III*/ F(tk::_set_, hi::Meta);
"short" L /*FII*/ F(tk::_short_, hi::Type);
"static" L /*FS?*/ F(tk::_static_, hi::Meta);
-"super" L /*FFK*/ F(yyextra->super_.top() ? tk::_super__ : tk::_super_, hi::Constant);
+"super" L /*FFK*/ F(tk::_super_, hi::Constant);
"switch" L /*KKK*/ F(tk::_switch_, hi::Control);
"synchronized" L /*FII*/ F(tk::_synchronized_, hi::Meta);
+"target" L /*III*/ F(tk::_target_, hi::Identifier);
"this" L /*KKK*/ F(tk::_this_, hi::Constant);
"throw" L /*KKK*/ F(tk::_throw_, hi::Control);
"throws" L /*FII*/ F(tk::_throws_, hi::Meta);
char next(yytext[i]);
if (next != '\\')
*local++ = next;
- else
- U(local, yytext, ++i);
+ else {
+ bool (*is)(unsigned) = (i == 0 ? &IsIdentifierStart : &IsIdentifierContinue);
+ unsigned point(U(local, yytext, ++i));
+ if (!is(point))
+ E("invalid character");
+ }
}
*local = '\0';