]> git.saurik.com Git - cycript.git/blobdiff - Cycript.l
More interactivity and @selector start.
[cycript.git] / Cycript.l
index 08b7cd5e97504268e3a300e1d48f0eee6187718b..eb0c692a1d310968c1d74b1a6993bad7dd089746 100644 (file)
--- 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;