From: Jay Freeman (saurik) Date: Tue, 20 Oct 2009 00:39:09 +0000 (+0000) Subject: Finished implementing multi-line comments. X-Git-Tag: v0.9.432~310 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/66fb559f7b79a23d2821d9c0723dbf4b87abb3fb?ds=sidebyside Finished implementing multi-line comments. --- diff --git a/Cycript.l b/Cycript.l index f3c2062..115e1de 100644 --- a/Cycript.l +++ b/Cycript.l @@ -96,8 +96,26 @@ RegularExpressionStart_ {RegularExpressionBody}{RegularExpressionEnd_} {RegularExpressionStart_} E("/") {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(memchr(yytext, '\n', yyleng))) { + unsigned lines(0); + size_t left; + + do { + ++lines; + left = yyleng - (nl - yytext) - 1; + nl = reinterpret_cast(memchr(nl + 1, '\n', left)); + } while (nl != NULL); + + yylloc->end.lines(lines); + yylloc->end.columns(left); + yylloc->step(); + } else L +} "&" L C return tk::Ampersand; "&&" L C return tk::AmpersandAmpersand;