X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/c5b15840ab1bb70218506531f9a73fe2d112b007..61c7112146ed7cc27b0a921843efdaaa7878d449:/Scanner.lpp.in diff --git a/Scanner.lpp.in b/Scanner.lpp.in index 5563b06..1399011 100644 --- a/Scanner.lpp.in +++ b/Scanner.lpp.in @@ -83,13 +83,13 @@ typedef cy::parser::token tk; nl = reinterpret_cast(memchr(nl + 1, '\n', left)); \ } while (nl != NULL); \ yylloc->step(); \ - yylloc->end.lines(lines); \ - yylloc->end.columns(left); \ + yylloc->end.Lines(lines); \ + yylloc->end.Columns(left); \ more \ } else L \ } -#define R yylloc->end.columns(yyleng); +#define R yylloc->end.Columns(yyleng); #define L yylloc->step(); R #define H(value, highlight) do { \ @@ -266,8 +266,6 @@ XMLName {XMLNameStart}{XMLNamePart}* %s Div %s DivOrTemplateTail -%s RegExp -%s RegExpOrTemplateTail @begin E4X %x XMLContent @@ -277,8 +275,6 @@ XMLName {XMLNameStart}{XMLNamePart}* %% /* RegEx {{{ */ -\/ L CYLexBufferStart(RegularExpression); CYLexBufferUnit('/'); - { \/{UnicodePart}* R CYLexBufferUnits(yytext, yyleng); CYLexBufferEnd(literal, RegEx, tk::RegularExpressionLiteral, hi::Constant); \/{UnicodePart}*{UnicodeFail} R E("invalid flags") @@ -306,7 +302,7 @@ XMLName {XMLNameStart}{XMLNamePart}* { \**\*\/ R yy_pop_state(yyscanner); M N - \**{LineTerminatorSequence} yylloc->end.lines(); yyextra->last_ = true; + \**{LineTerminatorSequence} yylloc->end.Lines(); yyextra->last_ = true; \**{CommentCharacter}|\/ R \**({UnicodeFail}|\*) R E("invalid comment"); <> R E("invalid comment") @@ -388,8 +384,8 @@ XMLName {XMLNameStart}{XMLNamePart}* "*=" L F(tk::StarEqual, hi::Operator); "~" L F(tk::Tilde, hi::Operator); -"/" L F(tk::Slash, hi::Operator); -"/=" L F(tk::SlashEqual, hi::Operator); +"/" L F(tk::Slash, hi::Operator); +"/=" L F(tk::SlashEqual, hi::Operator); ":" L F(tk::Colon, hi::Structure); "," L F(tk::Comma, hi::Structure); @@ -400,7 +396,7 @@ XMLName {XMLNameStart}{XMLNamePart}* ")" L F(tk::CloseParen, hi::Structure); "{" L yyextra->template_.push(false); F(yyextra->newline_ ? tk::OpenBrace_ : tk::OpenBrace, hi::Structure); -"}" L S(template_); F(tk::CloseBrace, hi::Structure); +
"}" L S(template_); F(tk::CloseBrace, hi::Structure); "[" L F(tk::OpenBracket, hi::Structure); "]" L F(tk::CloseBracket, hi::Structure); @@ -584,7 +580,7 @@ XMLName {XMLNameStart}{XMLNamePart}* /* }}} */ /* Template {{{ */ "`" L yyextra->tail_ = false; CYLexBufferStart(StrictAccentString); -"}" L yyextra->tail_ = true; S(template_); CYLexBufferStart(StrictAccentString); +"}" L yyextra->tail_ = true; S(template_); CYLexBufferStart(StrictAccentString); { "`" R CYLexBufferEnd(string, String, yyextra->tail_ ? tk::TemplateTail : tk::NoSubstitutionTemplate, hi::Constant); @@ -628,7 +624,7 @@ XMLName {XMLNameStart}{XMLNamePart}* CYLexBufferPoint(point); } - \\{LineTerminatorSequence} yylloc->end.lines(); + \\{LineTerminatorSequence} yylloc->end.Lines(); \\(.|{NotLineTerminator}) R CYLexBufferUnits(yytext + 1, yyleng - 1); \\(x{HexDigit}{0,1}|u({HexDigit}{0,3}|\{{HexDigit}*)|{UnicodeFail})? R E("invalid escape"); @@ -636,7 +632,7 @@ XMLName {XMLNameStart}{XMLNamePart}* } /* }}} */ -{LineTerminatorSequence} yylloc->step(); yylloc->end.lines(); yyextra->last_ = true; N +{LineTerminatorSequence} yylloc->step(); yylloc->end.Lines(); yyextra->last_ = true; N {WhiteSpace} L <> if (yyextra->auto_) { yyextra->auto_ = false; F(tk::AutoComplete, hi::Nothing); } L yyterminate(); @@ -645,6 +641,10 @@ XMLName {XMLNameStart}{XMLNamePart}* %% +#undef yyextra +#define yyextra this +#define yyscanner scanner_ + void CYDriver::ScannerInit() { cylex_init(&scanner_); cyset_extra(this, scanner_); @@ -654,13 +654,17 @@ void CYDriver::ScannerDestroy() { cylex_destroy(scanner_); } +void CYDriver::SetRegEx(bool equal) { + CYLexBufferStart(RegularExpression); + CYLexBufferUnit('/'); + if (equal) + CYLexBufferUnit('='); +} + void CYDriver::SetCondition(Condition condition) { struct yyguts_t *yyg(reinterpret_cast(scanner_)); switch (condition) { - case RegExpCondition: - BEGIN(template_.top() ? RegExpOrTemplateTail : RegExp); - break; @begin E4X case XMLContentCondition: BEGIN(XMLContent); @@ -676,9 +680,6 @@ void CYDriver::SetCondition(Condition condition) { void CYDriver::PushCondition(Condition condition) { switch (condition) { - case RegExpCondition: - yy_push_state(RegExp, scanner_); - break; @begin E4X case XMLContentCondition: yy_push_state(XMLContent, scanner_);