X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/db5e284073ce1f951343c5825a7e4d64d159582b..e7ed5354ae029d47ace1bc152aa5686f495e5737:/Cycript.l?ds=sidebyside diff --git a/Cycript.l b/Cycript.l index 08b7cd5..eb0c692 100644 --- a/Cycript.l +++ b/Cycript.l @@ -1,12 +1,27 @@ %{ #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" @@ -80,6 +95,8 @@ Escape \\['"\\bfnrtv]|\\0|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4} "[" 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;