revert change to lookahead, parse negative lookahead correctly
parent
abe2eb462f
commit
ae8254c0fd
|
@ -42,7 +42,7 @@ IN: regexp2.dfa
|
|||
dupd pop dup pick find-transitions rot
|
||||
[
|
||||
[ [ find-closure ] 2keep nip dupd add-todo-state ] 3keep
|
||||
>r swapd f transition boa r> dfa-table>> add-transition
|
||||
>r swapd transition boa r> dfa-table>> add-transition
|
||||
] curry with each
|
||||
new-transitions
|
||||
] if-empty ;
|
||||
|
|
|
@ -30,10 +30,10 @@ GENERIC: nfa-node ( node -- )
|
|||
stack [ regexp stack>> ]
|
||||
table [ regexp nfa-table>> ] |
|
||||
negated? [
|
||||
s0 f obj f class boa table add-transition
|
||||
s0 f obj class boa table add-transition
|
||||
s0 s1 <default-transition> table add-transition
|
||||
] [
|
||||
s0 s1 obj f class boa table add-transition
|
||||
s0 s1 obj class boa table add-transition
|
||||
] if
|
||||
s0 s1 2array stack push
|
||||
t s1 table final-states>> set-at ] ;
|
||||
|
|
|
@ -155,7 +155,7 @@ DEFER: nested-parse-regexp
|
|||
[ drop nested-parse-regexp pop-stack make-non-capturing-group ] }
|
||||
{ [ dup CHAR: = = ]
|
||||
[ drop nested-parse-regexp pop-stack make-positive-lookahead ] }
|
||||
{ [ dup CHAR: = = ]
|
||||
{ [ dup CHAR: ! = ]
|
||||
[ drop nested-parse-regexp pop-stack make-negative-lookahead ] }
|
||||
{ [ dup CHAR: > = ]
|
||||
[ drop nested-parse-regexp pop-stack make-independent-group ] }
|
||||
|
|
|
@ -14,7 +14,7 @@ IN: regexp2.transition-tables
|
|||
: ?insert-at ( value key hash/f -- hash )
|
||||
[ H{ } clone ] unless* [ insert-at ] keep ;
|
||||
|
||||
TUPLE: transition from to obj lookahead ;
|
||||
TUPLE: transition from to obj ;
|
||||
TUPLE: literal-transition < transition ;
|
||||
TUPLE: class-transition < transition ;
|
||||
TUPLE: default-transition < transition ;
|
||||
|
@ -23,11 +23,11 @@ TUPLE: literal obj ;
|
|||
TUPLE: class obj ;
|
||||
TUPLE: default ;
|
||||
: <literal-transition> ( from to obj -- transition )
|
||||
f literal-transition boa ;
|
||||
literal-transition boa ;
|
||||
: <class-transition> ( from to obj -- transition )
|
||||
f class-transition boa ;
|
||||
class-transition boa ;
|
||||
: <default-transition> ( from to -- transition )
|
||||
t f default-transition boa ;
|
||||
t default-transition boa ;
|
||||
|
||||
TUPLE: transition-table transitions
|
||||
literals classes defaults
|
||||
|
|
Loading…
Reference in New Issue