mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-16 02:22:12 +03:00
Parse indent in ++snap directly instead of feeding spaces to span-level parsers
This commit is contained in:
parent
4cb1d46618
commit
1b4fd3440c
@ -489,7 +489,14 @@
|
|||||||
::
|
::
|
||||||
:: no unterminated lines
|
:: no unterminated lines
|
||||||
?~ los ~&(%unterminated-line [~ +>(err `naz)])
|
?~ los ~&(%unterminated-line [~ +>(err `naz)])
|
||||||
?: =(`@`10 i.los)
|
?. =(`@`10 i.los)
|
||||||
|
?: (gth col q.naz)
|
||||||
|
?. (~(has in ^~((silt " -+>!"))) i.los)
|
||||||
|
~&(expected-indent+[col naz los] [~ +>(err `naz)])
|
||||||
|
$(los t.los, q.naz +(q.naz))
|
||||||
|
::
|
||||||
|
:: save byte and repeat
|
||||||
|
$(los t.los, q.naz +(q.naz), nap [i.los nap])
|
||||||
::
|
::
|
||||||
:: consume newline
|
:: consume newline
|
||||||
:_ +>(los t.los, naz [+(p.naz) 1])
|
:_ +>(los t.los, naz [+(p.naz) 1])
|
||||||
@ -500,10 +507,19 @@
|
|||||||
$(nap t.nap)
|
$(nap t.nap)
|
||||||
(flop nap)
|
(flop nap)
|
||||||
::
|
::
|
||||||
:: save byte and repeat
|
++ skip :: discard line
|
||||||
$(los t.los, q.naz +(q.naz), nap [i.los nap])
|
|- ^+ +
|
||||||
|
::
|
||||||
|
:: no unterminated lines
|
||||||
|
?~ los ~&(%unterminated-line +(err `naz))
|
||||||
|
?. =(`@`10 i.los)
|
||||||
|
::
|
||||||
|
:: eat byte and repeat
|
||||||
|
$(los t.los)
|
||||||
|
::
|
||||||
|
:: consume newline
|
||||||
|
+(los t.los, naz [+(p.naz) 1])
|
||||||
::
|
::
|
||||||
++ skip +:snap :: discard line
|
|
||||||
++ look :: inspect line
|
++ look :: inspect line
|
||||||
^- (unit trig)
|
^- (unit trig)
|
||||||
(wonk (look:parse naz los))
|
(wonk (look:parse naz los))
|
||||||
@ -521,7 +537,7 @@
|
|||||||
|= tape ^- mars
|
|= tape ^- mars
|
||||||
::
|
::
|
||||||
:: each line is text data with its newline
|
:: each line is text data with its newline
|
||||||
;/((weld (slag (add 4 (dec col)) +<) "\0a"))
|
;/((weld (slag 4 +<) "\0a"))
|
||||||
::
|
::
|
||||||
:: if block is verse
|
:: if block is verse
|
||||||
?: ?=($poem p.cur)
|
?: ?=($poem p.cur)
|
||||||
@ -535,7 +551,7 @@
|
|||||||
:: each line is a paragraph
|
:: each line is a paragraph
|
||||||
:- [%p ~]
|
:- [%p ~]
|
||||||
:_ ~
|
:_ ~
|
||||||
;/((weld (slag (dec col) +<) "\0a"))
|
;/("{+<}\0a")
|
||||||
::
|
::
|
||||||
:: yex: block recomposed, with newlines
|
:: yex: block recomposed, with newlines
|
||||||
=/ yex/tape (join '\0a' (flop q.u.lub))
|
=/ yex/tape (join '\0a' (flop q.u.lub))
|
||||||
@ -634,14 +650,14 @@
|
|||||||
=/ dif (sub col.pic col)
|
=/ dif (sub col.pic col)
|
||||||
=/ erp [p.naz col.pic]
|
=/ erp [p.naz col.pic]
|
||||||
::
|
::
|
||||||
:: nap: take first line
|
|
||||||
=^ nap +>.$ snap
|
|
||||||
::
|
|
||||||
:: execute appropriate paragraph form
|
:: execute appropriate paragraph form
|
||||||
=< line:abet:apex
|
=< line:abet:apex
|
||||||
|%
|
|%
|
||||||
::
|
::
|
||||||
++ abet :: accept line
|
++ abet :: accept line
|
||||||
|
::
|
||||||
|
:: nap: take first line
|
||||||
|
=^ nap +>.$ snap
|
||||||
..$(lub `[naz nap ~])
|
..$(lub `[naz nap ~])
|
||||||
::
|
::
|
||||||
++ apex ^+ . :: by column offset
|
++ apex ^+ . :: by column offset
|
||||||
@ -672,9 +688,6 @@
|
|||||||
:: indent by 2
|
:: indent by 2
|
||||||
=. col (add 2 col)
|
=. col (add 2 col)
|
||||||
::
|
::
|
||||||
:: erase marker
|
|
||||||
=. nap =+((dec col) (runt [- ' '] (slag - nap)))
|
|
||||||
::
|
|
||||||
(push typ)
|
(push typ)
|
||||||
::
|
::
|
||||||
++ lent :: list entry
|
++ lent :: list entry
|
||||||
|
Loading…
Reference in New Issue
Block a user