From b912a7350989c1d1af5b447eb388aa38b358b183 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 27 Aug 2008 15:59:07 -0500 Subject: [PATCH] fix parser for special groups --- unfinished/regexp2/parser/parser.factor | 32 +++++++++++++------------ 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/unfinished/regexp2/parser/parser.factor b/unfinished/regexp2/parser/parser.factor index bd291f3cf7..206db3883d 100644 --- a/unfinished/regexp2/parser/parser.factor +++ b/unfinished/regexp2/parser/parser.factor @@ -151,6 +151,8 @@ ERROR: bad-special-group string ; DEFER: nested-parse-regexp : (parse-special-group) ( -- ) read1 { + { [ dup CHAR: # = ] + [ drop nested-parse-regexp pop-stack drop ] } { [ dup CHAR: : = ] [ drop nested-parse-regexp pop-stack make-non-capturing-group ] } { [ dup CHAR: = = ] @@ -385,25 +387,25 @@ DEFER: handle-left-bracket : nested-parse-regexp ( -- ) beginning-of-group push-stack (parse-regexp) ; -: ((parse-regexp)) ( token -- ) +: ((parse-regexp)) ( token -- ? ) { - { CHAR: . [ handle-dot ] } - { CHAR: ( [ handle-left-parenthesis ] } - { CHAR: ) [ handle-right-parenthesis ] } - { CHAR: | [ handle-pipe ] } - { CHAR: ? [ handle-question ] } - { CHAR: * [ handle-star ] } - { CHAR: + [ handle-plus ] } - { CHAR: { [ handle-left-brace ] } - { CHAR: [ [ handle-left-bracket ] } - { CHAR: ^ [ handle-front-anchor ] } - { CHAR: $ [ handle-back-anchor ] } - { CHAR: \ [ handle-escape ] } - [ push-stack ] + { CHAR: . [ handle-dot t ] } + { CHAR: ( [ handle-left-parenthesis t ] } + { CHAR: ) [ handle-right-parenthesis f ] } + { CHAR: | [ handle-pipe t ] } + { CHAR: ? [ handle-question t ] } + { CHAR: * [ handle-star t ] } + { CHAR: + [ handle-plus t ] } + { CHAR: { [ handle-left-brace t ] } + { CHAR: [ [ handle-left-bracket t ] } + { CHAR: ^ [ handle-front-anchor t ] } + { CHAR: $ [ handle-back-anchor t ] } + { CHAR: \ [ handle-escape t ] } + [ push-stack t ] } case ; : (parse-regexp) ( -- ) - read1 [ ((parse-regexp)) (parse-regexp) ] when* ; + read1 [ ((parse-regexp)) [ (parse-regexp) ] when ] when* ; : parse-regexp ( regexp -- ) dup current-regexp [