]> git.saurik.com Git - cycript.git/blobdiff - Cycript.l
Further makefile reorganization, header file fixes, code movement, and general massag...
[cycript.git] / Cycript.l
index f3c2062b322bea1381524fe52a5e6ff2f066bf3d..c2142bd19fd116888c5af0623bf330ff61a04414 100644 (file)
--- a/Cycript.l
+++ b/Cycript.l
@@ -96,8 +96,30 @@ RegularExpressionStart_ {RegularExpressionBody}{RegularExpressionEnd_}
 <res>{RegularExpressionStart_} E("/")
 <rer>{RegularExpressionRest_} E("/=")
 
-\/\/[^\n]* ;
-\/\*(\n|[^\*]|\*[^/])\*\/ if (memchr(yytext, '\n', yyleng) != NULL) N // XXX: supposedly I will be screwed on very very long multi-line comments and need to replace this with a manual lexer. http://websrv.cs.fsu.edu/~engelen/courses/COP5621/Pr2.pdf ; XXX: this rule doesn't work anyway, fucking A :(
+\/\/[^\n]* L
+
+\/\*(\n|[^\*]|\*[^/])*\*\/ {
+    // XXX: supposedly I will be screwed on very very long multi-line comments and need to replace this with a manual lexer. http://websrv.cs.fsu.edu/~engelen/courses/COP5621/Pr2.pdf
+
+    if (const char *nl = reinterpret_cast<const char *>(memchr(yytext, '\n', yyleng))) {
+        unsigned lines(0);
+        size_t left;
+
+        do {
+            ++lines;
+            left = yyleng - (nl - yytext) - 1;
+            nl = reinterpret_cast<const char *>(memchr(nl + 1, '\n', left));
+        } while (nl != NULL);
+
+        yylloc->end.lines(lines);
+        yylloc->end.columns(left);
+        yylloc->step();
+
+        N
+    } else L
+}
+
+"@"    L C return tk::At;
 
 "&"    L C return tk::Ampersand;
 "&&"   L C return tk::AmpersandAmpersand;
@@ -271,7 +293,7 @@ RegularExpressionStart_ {RegularExpressionBody}{RegularExpressionEnd_}
     return tk::StringLiteral;
 }
 
-\n yylloc->end.lines(); yylloc->step(); N
+\r?\n yylloc->end.lines(); yylloc->step(); N
 
 [ \t] L
 <<EOF>> L yyterminate();