From 66fb559f7b79a23d2821d9c0723dbf4b87abb3fb Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 20 Oct 2009 00:39:09 +0000 Subject: [PATCH] Finished implementing multi-line comments. --- Cycript.l | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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; -- 2.49.0