[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdev-ruby] parser: Fixed an issue with regexps
From:       Miquel_Sabaté <mikisabate () gmail ! com>
Date:       2013-02-28 21:11:40
Message-ID: 20130228211140.18E6AA60C6 () git ! kde ! org
[Download RAW message or body]

Git commit f794a458c90922f96d4acb365d3d359406f8bb30 by Miquel Sabaté.
Committed on 28/02/2013 at 20:51.
Pushed by mssola into branch 'master'.

Fixed an issue with regexps

M  +3    -7    parser/parser.y
M  +1    -0    parser/tools/tests/regexp.rb
M  +1    -0    parser/tools/tests/regexp.txt

http://commits.kde.org/kdev-ruby/f794a458c90922f96d4acb365d3d359406f8bb30

diff --git a/parser/parser.y b/parser/parser.y
index be2009c..e353d15 100644
--- a/parser/parser.y
+++ b/parser/parser.y
@@ -222,13 +222,13 @@ static void copy_wc_range_ext(struct node *res, struct node *h, struct node *t);
 %token <n> tRETRY tIN tDO tDO_COND tDO_BLOCK tRETURN tYIELD tKWAND tKWOR tKWNOT
 %token <n> tALIAS tDEFINED upBEGIN upEND tTRUE tFALSE tNIL tENCODING tDSTAR
 %token <n> tFILE tLINE tSELF tSUPER GLOBAL BASE CONST tDO_LAMBDA tCHAR
-%token <n> tREGEXP IVAR CVAR NUMERIC FLOAT tNTH_REF tBACKTICK tpEND tSYMBEG
+%token <n> IVAR CVAR NUMERIC FLOAT tNTH_REF tBACKTICK tpEND tSYMBEG
 %token <n> tAMPER tAREF tASET tASSOC tCOLON2 tCOLON3 tLAMBDA tLAMBEG tLBRACE
 %token <n> tLBRACKET tLPAREN tLPAREN_ARG tSTAR tCOMMENT ARRAY tKEY SYMBOL
 %token tSTRING_BEG tSTRING_CONTENT tSTRING_DBEG tSTRING_DEND tSTRING_END tSTRING_DVAR
 
 /* Types */
-%type <n> singleton strings string regexp literal numeric cpath rescue_arg
+%type <n> singleton strings string literal numeric cpath rescue_arg
 %type <n> top_compstmt top_stmt bodystmt compstmt stmts stmt expr arg primary
 %type <n> command command_call method_call if_tail opt_else case_body cases
 %type <n> opt_rescue exc_list exc_var opt_ensure args call_args opt_call_args
@@ -829,7 +829,6 @@ mrhs: args ',' arg          { $$ = update_list($1, $3); }
 
 primary: literal
     | strings
-    | regexp
     | variable
     | backref
     | tBEGIN bodystmt tEND
@@ -1427,9 +1426,6 @@ string_dvar: backref
     | CVAR      { $$ = ALLOC_N(token_object, NULL, NULL); $$->flags = 5; POP_STACK; }
 ;
 
-regexp: tREGEXP { $$ = ALLOC_N(token_regexp, NULL, NULL); }
-;
-
 symbol: tSYMBEG sym
     {
         $$ = ALLOC_N(token_symbol, NULL, NULL);
@@ -2367,7 +2363,7 @@ static int parse_string(struct parser_t *parser)
         return -1;
     }
 
-    if (lex_strterm.can_embed && c == '#') {
+    if (lex_strterm.can_embed && c == '#' && *(parser->lex_prev) != '\\') {
         nextc();
         switch (*parser->lex_p) {
             case '$': case '@':
diff --git a/parser/tools/tests/regexp.rb b/parser/tools/tests/regexp.rb
index a8c7698..d4c54a5 100644
--- a/parser/tools/tests/regexp.rb
+++ b/parser/tools/tests/regexp.rb
@@ -23,3 +23,4 @@ end
 return /IIS\/(\d+)/
 
 a = /asd/iu
+a = /\A#\#$/
diff --git a/parser/tools/tests/regexp.txt b/parser/tools/tests/regexp.txt
index e812ba1..bcf11ca 100644
--- a/parser/tools/tests/regexp.txt
+++ b/parser/tools/tests/regexp.txt
@@ -25,5 +25,6 @@ Condition: 51(ajax_method)[13,3:13,14] 29[13,3:13,36] 61[13,18:13,36]
 61[21,0:21,7] 
 61[23,7:23,19] 72[23,0:23,19] 
 51(a)[25,0:25,1] 22[25,0:25,11] 61[25,4:25,11] 
+51(a)[26,0:26,1] 22[26,0:26,12] 61[26,4:26,12] 
 
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic