%{
#include "Cycript.tab.hh"
typedef cy::parser::token tk;
+
#define YY_EXTRA_TYPE CYDriver *
+#define YYLTYPE cy::location
#define T yylval->newline_ = yyextra->state_ == CYNewLine;
#define C T yyextra->state_ = CYClear;
#define R T yyextra->state_ = CYRestricted;
-#define N { bool restricted(yyextra->state_ == CYRestricted); if (restricted) { yyextra->state_ = CYClear; return tk::NewLine; } else yyextra->state_ = CYNewLine; }
+#define N if (yyextra->state_ != CYNewLine) { bool restricted(yyextra->state_ == CYRestricted); if (restricted) { yyextra->state_ = CYClear; return tk::NewLine; } else yyextra->state_ = CYNewLine; }
+
+#define YY_INPUT(data, value, size) { \
+ if (yyextra->size_ == 0) \
+ value = YY_NULL; \
+ else { \
+ size_t copy(std::min(size, yyextra->size_)); \
+ memcpy(data, yyextra->data_, copy); \
+ yyextra->data_ += copy; \
+ yyextra->size_ -= copy; \
+ value = copy; \
+ } \
+}
+
%}
%option prefix="cy"
"[" C return tk::OpenBracket;
"]" C return tk::CloseBracket;
+"@selector" C return tk::AtSelector;
+
"break" R yylval->word_ = new CYWord("break"); return tk::Break;
"case" C yylval->word_ = new CYWord("case"); return tk::Case;
"catch" C yylval->word_ = new CYWord("catch"); return tk::Catch;