new accessors ftw
parent
9695df7fbd
commit
34b2db96ef
|
@ -65,8 +65,8 @@ SYMBOL: rule-sets
|
||||||
over [ dupd update ] [ nip clone ] if ;
|
over [ dupd update ] [ nip clone ] if ;
|
||||||
|
|
||||||
: import-keywords ( parent child -- )
|
: import-keywords ( parent child -- )
|
||||||
over >r [ rule-set-keywords ] bi@ ?update
|
over >r [ keywords>> ] bi@ ?update
|
||||||
r> set-rule-set-keywords ;
|
r> (>>keywords) ;
|
||||||
|
|
||||||
: import-rules ( parent child -- )
|
: import-rules ( parent child -- )
|
||||||
swap [ add-rule ] curry each-rule ;
|
swap [ add-rule ] curry each-rule ;
|
||||||
|
|
|
@ -77,7 +77,7 @@ TAGS>
|
||||||
! Top-level entry points
|
! Top-level entry points
|
||||||
: parse-mode-tag ( tag -- rule-sets )
|
: parse-mode-tag ( tag -- rule-sets )
|
||||||
dup "RULES" tags-named [
|
dup "RULES" tags-named [
|
||||||
parse-rules-tag dup rule-set-name swap
|
parse-rules-tag dup name>> swap
|
||||||
] H{ } map>assoc
|
] H{ } map>assoc
|
||||||
swap "PROPS" tag-named [
|
swap "PROPS" tag-named [
|
||||||
parse-props-tag over values
|
parse-props-tag over values
|
||||||
|
|
|
@ -72,7 +72,7 @@ M: regexp text-matches?
|
||||||
>r >string r> match-head ;
|
>r >string r> match-head ;
|
||||||
|
|
||||||
: rule-start-matches? ( rule -- match-count/f )
|
: rule-start-matches? ( rule -- match-count/f )
|
||||||
dup rule-start tuck swap can-match-here? [
|
dup start>> tuck swap can-match-here? [
|
||||||
rest-of-line swap text>> text-matches?
|
rest-of-line swap text>> text-matches?
|
||||||
] [
|
] [
|
||||||
drop f
|
drop f
|
||||||
|
@ -114,7 +114,7 @@ GENERIC: handle-rule-end ( match-count rule -- )
|
||||||
] ?if ;
|
] ?if ;
|
||||||
|
|
||||||
: check-escape-rule ( rule -- ? )
|
: check-escape-rule ( rule -- ? )
|
||||||
rule-no-escape? [ f ] [
|
no-escape?>> [ f ] [
|
||||||
find-escape-rule dup [
|
find-escape-rule dup [
|
||||||
dup rule-start-matches? dup [
|
dup rule-start-matches? dup [
|
||||||
swap handle-rule-start
|
swap handle-rule-start
|
||||||
|
@ -139,7 +139,7 @@ GENERIC: handle-rule-end ( match-count rule -- )
|
||||||
|
|
||||||
: rule-match-token* ( rule -- id )
|
: rule-match-token* ( rule -- id )
|
||||||
dup match-token>> {
|
dup match-token>> {
|
||||||
{ f [ dup rule-body-token ] }
|
{ f [ dup body-token>> ] }
|
||||||
{ t [ current-rule-set default>> ] }
|
{ t [ current-rule-set default>> ] }
|
||||||
[ ]
|
[ ]
|
||||||
} case nip ;
|
} case nip ;
|
||||||
|
@ -216,7 +216,7 @@ M: mark-previous-rule handle-rule-start
|
||||||
: handle-no-word-break ( -- )
|
: handle-no-word-break ( -- )
|
||||||
context get parent>> [
|
context get parent>> [
|
||||||
in-rule>> [
|
in-rule>> [
|
||||||
dup rule-no-word-break? [
|
dup no-word-break?>> [
|
||||||
rule-match-token* prev-token,
|
rule-match-token* prev-token,
|
||||||
pop-context
|
pop-context
|
||||||
] [ drop ] if
|
] [ drop ] if
|
||||||
|
|
|
@ -15,7 +15,7 @@ SYMBOLS: line last-offset position context
|
||||||
context get in-rule-set>> ;
|
context get in-rule-set>> ;
|
||||||
|
|
||||||
: current-keywords ( -- keyword-map )
|
: current-keywords ( -- keyword-map )
|
||||||
current-rule-set rule-set-keywords ;
|
current-rule-set keywords>> ;
|
||||||
|
|
||||||
: token, ( from to id -- )
|
: token, ( from to id -- )
|
||||||
2over = [ 3drop ] [ >r line get subseq r> <token> , ] if ;
|
2over = [ 3drop ] [ >r line get subseq r> <token> , ] if ;
|
||||||
|
|
|
@ -74,14 +74,14 @@ TUPLE: span-rule < rule ;
|
||||||
TUPLE: eol-span-rule < rule ;
|
TUPLE: eol-span-rule < rule ;
|
||||||
|
|
||||||
: init-span ( rule -- )
|
: init-span ( rule -- )
|
||||||
dup rule-delegate [ drop ] [
|
dup delegate>> [ drop ] [
|
||||||
dup rule-body-token standard-rule-set
|
dup body-token>> standard-rule-set
|
||||||
swap set-rule-delegate
|
swap (>>delegate)
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: init-eol-span ( rule -- )
|
: init-eol-span ( rule -- )
|
||||||
dup init-span
|
dup init-span
|
||||||
t swap set-rule-no-line-break? ;
|
t >>no-line-break? drop ;
|
||||||
|
|
||||||
TUPLE: mark-following-rule < rule ;
|
TUPLE: mark-following-rule < rule ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue