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