mirror of
https://github.com/jackfoxy/urQL.git
synced 2024-08-16 15:20:48 +03:00
line comments progress
This commit is contained in:
parent
d006ae0c0e
commit
fe9a3235c8
@ -4,12 +4,36 @@
|
||||
:: (parse:parse(default-database '<db>') "<script>")
|
||||
|_ default-database=@tas
|
||||
::
|
||||
:: +strip-cmnts: strip block comments from tape
|
||||
:: +clip-cmnt: clip commented end of line
|
||||
::
|
||||
++ clip-cmnt
|
||||
|= [p=tape q=(list @) r=(list @)]
|
||||
:: |- ^- tape
|
||||
p
|
||||
|
||||
::
|
||||
:: +line-cmnts: strip line comments from tape of line
|
||||
::
|
||||
++ line-cmnts
|
||||
|= p=tape
|
||||
=/ a=(list @) (fand "--" p)
|
||||
::~& "a: {<a>}"
|
||||
|- ^- tape
|
||||
?: =(0 (lent a)) p
|
||||
=/ b=(list @) (fand "'" p)
|
||||
?: =(0 (lent b))
|
||||
?: =(0 -.a) ~
|
||||
(scag -.a p)
|
||||
=/ c=(set @) (silt (turn (fand "\\'" p) |=(a=@ +(a))))
|
||||
(clip-cmnt p a (sort ~(tap in (~(dif in (silt b)) c)) lth))
|
||||
|
||||
::
|
||||
:: +block-cmnts: strip block comments from tape
|
||||
::
|
||||
:: Crash
|
||||
:: comment block mismatch line <n>
|
||||
::
|
||||
++ strip-cmnts
|
||||
++ block-cmnts
|
||||
|= p=tape
|
||||
=/ a=@ 0
|
||||
=/ b=tape ~
|
||||
@ -17,13 +41,19 @@
|
||||
|- ^- tape
|
||||
?~ p b
|
||||
?~ c
|
||||
?: =("--" (scag 2 `tape`p)) $(p ~)
|
||||
?: &(=(a 1) =("/*" (scag 2 `tape`p))) $(p ~)
|
||||
$(p ~, b (weld p b))
|
||||
?: =("--" (scag 2 (slag i.c `tape`p)))
|
||||
%= $
|
||||
p (scag i.c `tape`p)
|
||||
c t.c
|
||||
==
|
||||
?: =("*/" (scag 2 (slag (add 1 i.c) `tape`p)))
|
||||
%= $
|
||||
p (scag i.c `tape`p)
|
||||
a (add a 1)
|
||||
b ?.(=(a 0) b (weld (slag (add 3 i.c) `tape`p) b))
|
||||
b ?.(=(a 0) b (weld (line-cmnts (slag (add 3 i.c) `tape`p)) b))
|
||||
c t.c
|
||||
==
|
||||
?: =("/*" (scag 2 (slag (add 1 i.c) `tape`p)))
|
||||
@ -35,7 +65,7 @@
|
||||
?. =(a 0) $(p (scag i.c `tape`p), c t.c)
|
||||
%= $
|
||||
p (scag i.c `tape`p)
|
||||
b (weld (slag (add 1 i.c) `tape`p) b)
|
||||
b (weld (line-cmnts (slag (add 1 i.c) `tape`p)) b)
|
||||
c t.c
|
||||
==
|
||||
::
|
||||
@ -43,7 +73,7 @@
|
||||
++ parse
|
||||
|= raw-script=tape
|
||||
^- (list command:ast)
|
||||
=/ script=tape (strip-cmnts raw-script)
|
||||
=/ script=tape (block-cmnts raw-script)
|
||||
=/ commands `(list command:ast)`~
|
||||
=/ script-length (lent script)
|
||||
=/ displacement 0
|
||||
|
@ -9,16 +9,6 @@
|
||||
++ m-cmnt-3
|
||||
"\0a/* linea1 \0a lineb2 \0a linec3 \0a*/"
|
||||
|
||||
++ test-block-cmnt-00
|
||||
%+ expect-eq
|
||||
!> ~
|
||||
!> %- parse:parse(default-database 'other-db') ~
|
||||
|
||||
++ test-block-cmnt-01
|
||||
%+ expect-eq
|
||||
!> ~
|
||||
!> %- parse:parse(default-database 'other-db') %- zing ~[m-cmnt-1]
|
||||
|
||||
++ vfas-tar [%selected-value value=[p=~.t q=10.799] alias=~]
|
||||
++ vhep-hep [%selected-value value=[p=~.t q=11.565] alias=~]
|
||||
++ vtar-fas [%selected-value value=[p=~.t q=12.074] alias=~]
|
||||
@ -38,18 +28,72 @@
|
||||
++ t2 [%transform ctes=~ set-functions=[q2 ~ ~]]
|
||||
++ t3 [%transform ctes=~ set-functions=[q3 ~ ~]]
|
||||
|
||||
++ test-block-cmnt-005
|
||||
++ test-line-cmnt-00
|
||||
%+ expect-eq
|
||||
!> ~[t1 t2 t3]
|
||||
!> %- parse:parse(default-database 'other-db')
|
||||
%- zing
|
||||
%- limo :~ "select '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f ', ' -- '\0a"
|
||||
m-cmnt-1
|
||||
"select ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f '"
|
||||
m-cmnt-2
|
||||
"select ' *\2f ', ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a '"
|
||||
m-cmnt-3
|
||||
==
|
||||
!> ~
|
||||
!> %- parse:parse(default-database 'other-db') ~
|
||||
|
||||
++ test-line-cmnt-01
|
||||
%+ expect-eq
|
||||
!> ~
|
||||
!> %- parse:parse(default-database 'other-db') %- zing ~["--line cmnt"]
|
||||
|
||||
++ test-line-cmnt-02
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db1' name='ns1' as-of=~]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace ns1 --line cmnt")
|
||||
|
||||
::++ test-line-cmnt-03
|
||||
:: %+ expect-eq
|
||||
:: !> ~[t1 t2 t3]
|
||||
:: !> %- parse:parse(default-database 'other-db')
|
||||
:: %- zing
|
||||
:: %- limo
|
||||
:: :~ "select '\2f\2a', '*\2f' --, ' \2f\2a ', ' *\2f ', ' -- '\0a"
|
||||
:: m-cmnt-1
|
||||
:: "select ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f '"
|
||||
:: m-cmnt-2
|
||||
:: "select ' *\2f ', ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a '"
|
||||
:: m-cmnt-3
|
||||
:: ==
|
||||
|
||||
::++ test-line-cmnt-04
|
||||
:: %+ expect-eq
|
||||
:: !> ~[t1 t2 t3]
|
||||
:: !> %- parse:parse(default-database 'other-db')
|
||||
:: %- zing
|
||||
:: %- limo
|
||||
:: :~ "select '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f ', ' -- '\0a"
|
||||
:: m-cmnt-1
|
||||
:: "select ' -- ', '\2f\2a', '*\2f'--, ' \2f\2a ', ' *\2f '"
|
||||
:: m-cmnt-2
|
||||
:: "select ' *\2f ', ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a '"
|
||||
:: m-cmnt-3
|
||||
:: ==
|
||||
|
||||
::++ test-line-cmnt-05
|
||||
:: %+ expect-eq
|
||||
:: !> ~[t1 t2 t3]
|
||||
:: !> %- parse:parse(default-database 'other-db')
|
||||
:: %- zing
|
||||
:: %- limo
|
||||
:: :~ "select '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f ', ' -- '\0a"
|
||||
:: m-cmnt-1
|
||||
:: "select ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f '"
|
||||
:: m-cmnt-2
|
||||
:: "select ' *\2f ', ' -- ', '\2f\2a', '*\2f' --, ' \2f\2a '"
|
||||
:: m-cmnt-3
|
||||
:: ==
|
||||
|
||||
::++ test-line-cmnt-06
|
||||
:: %+ expect-eq
|
||||
:: !> ~[t1 t2 t3]
|
||||
:: !> %- parse:parse(default-database 'other-db')
|
||||
:: %- zing
|
||||
:: %- limo
|
||||
:: :~ "select '\2f\2a', '*\2f', '--', ' \2f\2a-- ', ' *\2f ', ' -- '\0a"
|
||||
:: "select -- ', '\2f\2a', '*\2f'--, ' \2f\2a ', ' *\2f '"
|
||||
:: "select ' *\2f ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a '"
|
||||
|
||||
|
||||
::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
Loading…
Reference in New Issue
Block a user