]> git.saurik.com Git - cycript.git/commitdiff
Use syntax-directed lexing to remove LexSetRegExp.
authorJay Freeman (saurik) <saurik@saurik.com>
Thu, 17 Dec 2015 10:06:15 +0000 (02:06 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 17 Dec 2015 10:06:15 +0000 (02:06 -0800)
Parser.ypp.in
Scanner.lpp.in

index 5b0c18bbd5a8c14e46b4a8a2bd91bcf5f3cce64e..923a01b7f64f62216dca46e94a12bd4fb9680ec4 100644 (file)
@@ -447,7 +447,7 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %token <identifier_> Identifier_
 %token <number_> NumericLiteral
 %token <string_> StringLiteral
-%token <literal_> RegularExpressionLiteral
+%token <literal_> RegularExpressionLiteral_
 
 %token <string_> NoSubstitutionTemplate
 %token <string_> TemplateHead
@@ -570,6 +570,8 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %type <property_> PropertyDefinitionList
 %type <property_> PropertyDefinitionListOpt
 %type <declaration_> PropertySetParameterList
+%type <literal_> RegularExpressionLiteral
+%type <bool_> RegularExpressionSlash
 %type <expression_> RelationalExpression
 %type <statement_> ReturnStatement
 %type <rubyProc_> RubyProcExpression
@@ -714,7 +716,7 @@ LexOf
     ;
 
 LexSetRegExp
-    : { CYLEX(); if (yyla.type == yytranslate_(token::Slash)) { yyla.clear(); driver.SetRegEx(false); } else if (yyla.type == yytranslate_(token::SlashEqual)) { yyla.clear(); driver.SetRegEx(true); } } LexOf
+    : LexOf
     ;
 
 LexNewLine
@@ -826,6 +828,16 @@ BooleanLiteral
     | "false" { $$ = CYNew CYFalse(); }
     ;
 /* }}} */
+/* 11.8.5 Regular Expression Literals {{{ */
+RegularExpressionSlash
+    : "/" { $$ = false; }
+    | "/=" { $$ = true; }
+    ;
+
+RegularExpressionLiteral
+    : RegularExpressionSlash { CYMPT(@$); driver.SetRegEx($1); } RegularExpressionLiteral_ { $$ = $3; }
+    ;
+/* }}} */
 
 /* 11.9 Automatic Semicolon Insertion {{{ */
 StrictSemi
index 399feb828e273a44cdb3d45f360a29e4ed4cfa62..c2aa6e4dc22a5e7e3857413e4189bc8023ed7499 100644 (file)
@@ -279,7 +279,7 @@ XMLName {XMLNameStart}{XMLNamePart}*
 
     /* RegEx {{{ */
 <RegularExpression>{
-    \/{UnicodePart}* R CYLexBufferUnits(yytext, yyleng); CYLexBufferEnd(literal, RegEx, tk::RegularExpressionLiteral, hi::Constant);
+    \/{UnicodePart}* R CYLexBufferUnits(yytext, yyleng); CYLexBufferEnd(literal, RegEx, tk::RegularExpressionLiteral_, hi::Constant);
     \/{UnicodePart}*{UnicodeError} R E("invalid character");
 
     {RegExCharacter}+ R CYLexBufferUnits(yytext, yyleng);