mirror of
https://github.com/jackfoxy/urQL.git
synced 2024-08-16 23:30:51 +03:00
line comments
This commit is contained in:
parent
ada2bffbef
commit
423ef331c2
@ -10,23 +10,15 @@
|
||||
|= [p=tape q=(list @) r=(list @)]
|
||||
|- ^- tape
|
||||
?~ q p
|
||||
|
||||
::~& "p: {<p>}"
|
||||
::~& "q: {<q>}"
|
||||
::~& "r: {<r>}"
|
||||
::~& " "
|
||||
|
||||
?: =(0 (mod (lent (skim r |=(a=@ (lth a i.q)))) 2)) :: prior --s in quotes
|
||||
?: =(0 (mod (lent (skim r |=(a=@ (lth a i.q)))) 2)) :: prior ::s in quotes
|
||||
(scag i.q `tape`p)
|
||||
$(q t.q)
|
||||
|
||||
|
||||
::
|
||||
:: +line-cmnts: strip line comments from tape of line
|
||||
::
|
||||
++ line-cmnts
|
||||
|= p=tape
|
||||
=/ a=(list @) (fand "--" p)
|
||||
=/ a=(list @) (fand "::" p)
|
||||
|- ^- tape
|
||||
?: =(0 (lent a)) p
|
||||
=/ b=(list @) (fand "'" p)
|
||||
@ -35,7 +27,6 @@
|
||||
(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
|
||||
::
|
||||
@ -50,14 +41,14 @@
|
||||
|- ^- tape
|
||||
?~ p b
|
||||
?~ c
|
||||
?: =("--" (scag 2 `tape`p)) $(p ~)
|
||||
?: =("::" (scag 2 `tape`p)) $(p ~)
|
||||
?: &(=(a 1) =("/*" (scag 2 `tape`p))) $(p ~)
|
||||
?: =(0 (lent (fand "--" p))) $(p ~, b (weld p b))
|
||||
?: =(0 (lent (fand "::" p))) $(p ~, b (weld p b))
|
||||
%= $
|
||||
p ~
|
||||
b (weld (line-cmnts `tape`p) b)
|
||||
==
|
||||
?: =("--" (scag 2 (slag i.c `tape`p)))
|
||||
?: =("::" (scag 2 (slag i.c `tape`p)))
|
||||
%= $
|
||||
p (scag i.c `tape`p)
|
||||
c t.c
|
||||
@ -87,7 +78,6 @@
|
||||
|= raw-script=tape
|
||||
^- (list command:ast)
|
||||
=/ script=tape (block-cmnts raw-script)
|
||||
::~& "script: {<script>}"
|
||||
=/ commands `(list command:ast)`~
|
||||
=/ script-length (lent script)
|
||||
=/ displacement 0
|
||||
|
@ -10,24 +10,26 @@
|
||||
"\0a/* linea1 \0a lineb2 \0a linec3 \0a*/"
|
||||
|
||||
++ vfas-tar [%selected-value value=[p=~.t q=10.799] alias=~]
|
||||
++ vhep-hep [%selected-value value=[p=~.t q=11.565] alias=~]
|
||||
++ vcol-col [%selected-value value=[p=~.t q=14.906] alias=~]
|
||||
++ vtar-fas [%selected-value value=[p=~.t q=12.074] alias=~]
|
||||
++ va-fas-tar-a [%selected-value value=[p=~.t q=539.635.488] alias=~]
|
||||
++ va-hep-hep-a [%selected-value value=[p=~.t q=539.831.584] alias=~]
|
||||
++ va-col-col-a [%selected-value value=[p=~.t q=540.686.880] alias=~]
|
||||
++ va-tar-fas-a [%selected-value value=[p=~.t q=539.961.888] alias=~]
|
||||
|
||||
++ s1 ~[vfas-tar vtar-fas vhep-hep va-fas-tar-a va-tar-fas-a va-hep-hep-a]
|
||||
++ s2 ~[va-hep-hep-a vfas-tar vtar-fas vhep-hep va-fas-tar-a va-tar-fas-a]
|
||||
++ s3 ~[va-tar-fas-a va-hep-hep-a vfas-tar vtar-fas vhep-hep va-fas-tar-a]
|
||||
++ s1 ~[vfas-tar vtar-fas vcol-col va-fas-tar-a va-tar-fas-a va-col-col-a]
|
||||
++ s2 ~[va-col-col-a vfas-tar vtar-fas vcol-col va-fas-tar-a va-tar-fas-a]
|
||||
++ s3 ~[va-tar-fas-a va-col-col-a vfas-tar vtar-fas vcol-col va-fas-tar-a]
|
||||
|
||||
++ s1a ~[vfas-tar vtar-fas]
|
||||
++ s2a ~[va-hep-hep-a vfas-tar vtar-fas]
|
||||
++ s3a ~[va-tar-fas-a va-hep-hep-a vfas-tar vtar-fas]
|
||||
++ s2a ~[va-col-col-a vfas-tar vtar-fas]
|
||||
++ s3a ~[va-tar-fas-a va-col-col-a vfas-tar vtar-fas]
|
||||
++ s3b ~[va-tar-fas-a]
|
||||
|
||||
++ q1 [%query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=s1] order-by=~]
|
||||
++ q2 [%query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=s2] order-by=~]
|
||||
++ q3 [%query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=s3] order-by=~]
|
||||
++ q3a [%query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=s3a] order-by=~]
|
||||
++ q3b [%query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=s3b] order-by=~]
|
||||
|
||||
++ q1a [%query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=s1a] order-by=~]
|
||||
++ q2a [%query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=s2a] order-by=~]
|
||||
@ -39,6 +41,7 @@
|
||||
++ t1a [%transform ctes=~ set-functions=[q1a ~ ~]]
|
||||
++ t2a [%transform ctes=~ set-functions=[q2a ~ ~]]
|
||||
++ t3a [%transform ctes=~ set-functions=[q3a ~ ~]]
|
||||
++ t3b [%transform ctes=~ set-functions=[q3b ~ ~]]
|
||||
|
||||
++ test-line-cmnt-00
|
||||
%+ expect-eq
|
||||
@ -47,26 +50,26 @@
|
||||
++ test-line-cmnt-01
|
||||
%+ expect-eq
|
||||
!> ~
|
||||
!> %- parse:parse(default-database 'other-db') %- zing ~["--line cmnt"]
|
||||
!> %- 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 \0a--line cmnt")
|
||||
!> (parse:parse(default-database 'db1') "create namespace ns1 \0a::line cmnt")
|
||||
++ test-line-cmnt-03
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db1' name='ns1' as-of=~]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace ns1 --line cmnt")
|
||||
!> (parse:parse(default-database 'db1') "create namespace ns1 ::line cmnt")
|
||||
++ test-line-cmnt-04
|
||||
%+ expect-eq
|
||||
!> ~[t1a 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 ', ' :: '\0a"
|
||||
m-cmnt-1
|
||||
"select ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f '"
|
||||
"select ' :: ', '\2f\2a', '*\2f', '::', ' \2f\2a ', ' *\2f '"
|
||||
m-cmnt-2
|
||||
"select ' *\2f ', ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a '"
|
||||
"select ' *\2f ', ' :: ', '\2f\2a', '*\2f', '::', ' \2f\2a '"
|
||||
m-cmnt-3
|
||||
==
|
||||
++ test-line-cmnt-05
|
||||
@ -75,11 +78,11 @@
|
||||
!> %- parse:parse(default-database 'other-db')
|
||||
%- zing
|
||||
%- limo
|
||||
:~ "select '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f ', ' -- '\0a"
|
||||
:~ "select '\2f\2a', '*\2f', '::', ' \2f\2a ', ' *\2f ', ' :: '\0a"
|
||||
m-cmnt-1
|
||||
"select ' -- ', '\2f\2a', '*\2f'--, ' \2f\2a ', ' *\2f '"
|
||||
"select ' :: ', '\2f\2a', '*\2f'::, ' \2f\2a ', ' *\2f '"
|
||||
m-cmnt-2
|
||||
"select ' *\2f ', ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a '"
|
||||
"select ' *\2f ', ' :: ', '\2f\2a', '*\2f', '::', ' \2f\2a '"
|
||||
m-cmnt-3
|
||||
==
|
||||
++ test-line-cmnt-06
|
||||
@ -88,22 +91,22 @@
|
||||
!> %- parse:parse(default-database 'other-db')
|
||||
%- zing
|
||||
%- limo
|
||||
:~ "select '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f ', ' -- '\0a"
|
||||
:~ "select '\2f\2a', '*\2f', '::', ' \2f\2a ', ' *\2f ', ' :: '\0a"
|
||||
m-cmnt-1
|
||||
"select ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f '"
|
||||
"select ' :: ', '\2f\2a', '*\2f', '::', ' \2f\2a ', ' *\2f '"
|
||||
m-cmnt-2
|
||||
"select ' *\2f ', ' -- ', '\2f\2a', '*\2f' --, ' \2f\2a '"
|
||||
"select ' *\2f ', ' :: ', '\2f\2a', '*\2f' ::, ' \2f\2a '"
|
||||
m-cmnt-3
|
||||
==
|
||||
++ test-line-cmnt-07
|
||||
%+ expect-eq
|
||||
!> ~[t1a t2a t3a]
|
||||
!> ~[t1 t2a t3b]
|
||||
!> %- 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 '"
|
||||
:~ "select '\2f\2a', '*\2f', '::', ' \2f\2a ', ' *\2f ', ' :: '\0a"
|
||||
"select ' :: ', '\2f\2a', '*\2f'::, ' \2f\2a ', ' *\2f '\0a"
|
||||
"select ' *\2f ' :: ', '\2f\2a', '*\2f', '::', ' \2f\2a '"
|
||||
==
|
||||
|
||||
|
||||
|
@ -2465,15 +2465,15 @@
|
||||
==
|
||||
::
|
||||
++ vfas-tar [%selected-value value=[p=~.t q=10.799] alias=~]
|
||||
++ vhep-hep [%selected-value value=[p=~.t q=11.565] alias=~]
|
||||
++ vcol-col [%selected-value value=[p=~.t q=14.906] alias=~]
|
||||
++ vtar-fas [%selected-value value=[p=~.t q=12.074] alias=~]
|
||||
++ va-fas-tar-a [%selected-value value=[p=~.t q=539.635.488] alias=~]
|
||||
++ va-hep-hep-a [%selected-value value=[p=~.t q=539.831.584] alias=~]
|
||||
++ va-col-col-a [%selected-value value=[p=~.t q=540.686.880] alias=~]
|
||||
++ va-tar-fas-a [%selected-value value=[p=~.t q=539.961.888] alias=~]
|
||||
::
|
||||
++ s1 ~[vfas-tar vtar-fas vhep-hep va-fas-tar-a va-tar-fas-a va-hep-hep-a]
|
||||
++ s2 ~[va-hep-hep-a vfas-tar vtar-fas vhep-hep va-fas-tar-a va-tar-fas-a]
|
||||
++ s3 ~[va-tar-fas-a va-hep-hep-a vfas-tar vtar-fas vhep-hep va-fas-tar-a]
|
||||
++ s1 ~[vfas-tar vtar-fas vcol-col va-fas-tar-a va-tar-fas-a va-col-col-a]
|
||||
++ s2 ~[va-col-col-a vfas-tar vtar-fas vcol-col va-fas-tar-a va-tar-fas-a]
|
||||
++ s3 ~[va-tar-fas-a va-col-col-a vfas-tar vtar-fas vcol-col va-fas-tar-a]
|
||||
::
|
||||
++ q1 [%query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=s1] order-by=~]
|
||||
++ q2 [%query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=s2] order-by=~]
|
||||
@ -2488,11 +2488,94 @@
|
||||
!> ~[t1 t2 t3]
|
||||
!> %- parse:parse(default-database 'other-db')
|
||||
%- zing
|
||||
%- limo :~ "select '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f ', ' -- '\0a"
|
||||
%- limo :~ "select '\2f\2a', '*\2f', '::', ' \2f\2a ', ' *\2f ', ' :: '\0a"
|
||||
m-cmnt-1
|
||||
"select ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f '"
|
||||
"select ' :: ', '\2f\2a', '*\2f', '::', ' \2f\2a ', ' *\2f '\0a"
|
||||
m-cmnt-2
|
||||
"select ' *\2f ', ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a '"
|
||||
"select ' *\2f ', ' :: ', '\2f\2a', '*\2f', '::', ' \2f\2a '"
|
||||
m-cmnt-3
|
||||
==
|
||||
::
|
||||
:: line comment
|
||||
::
|
||||
++ s1a ~[vfas-tar vtar-fas]
|
||||
++ s2a ~[va-col-col-a vfas-tar vtar-fas]
|
||||
++ s3a ~[va-tar-fas-a va-col-col-a vfas-tar vtar-fas]
|
||||
++ s3b ~[va-tar-fas-a]
|
||||
::
|
||||
++ q1a [%query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=s1a] order-by=~]
|
||||
++ q2a [%query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=s2a] order-by=~]
|
||||
++ q3a [%query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=s3a] order-by=~]
|
||||
++ q3b [%query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=s3b] order-by=~]
|
||||
::
|
||||
++ t1a [%transform ctes=~ set-functions=[q1a ~ ~]]
|
||||
++ t2a [%transform ctes=~ set-functions=[q2a ~ ~]]
|
||||
++ t3a [%transform ctes=~ set-functions=[q3a ~ ~]]
|
||||
++ t3b [%transform ctes=~ set-functions=[q3b ~ ~]]
|
||||
::
|
||||
++ test-line-cmnt-00
|
||||
%+ expect-eq
|
||||
!> ~
|
||||
!> %- 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 \0a::line cmnt")
|
||||
++ test-line-cmnt-03
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db1' name='ns1' as-of=~]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace ns1 ::line cmnt")
|
||||
++ test-line-cmnt-04
|
||||
%+ expect-eq
|
||||
!> ~[t1a 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 t2a 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 t3a]
|
||||
!> %- 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-07
|
||||
%+ expect-eq
|
||||
!> ~[t1 t2a t3b]
|
||||
!> %- parse:parse(default-database 'other-db')
|
||||
%- zing
|
||||
%- limo
|
||||
:~ "select '\2f\2a', '*\2f', '::', ' \2f\2a ', ' *\2f ', ' :: '\0a"
|
||||
"select ' :: ', '\2f\2a', '*\2f'::, ' \2f\2a ', ' *\2f '\0a"
|
||||
"select ' *\2f ' :: ', '\2f\2a', '*\2f', '::', ' \2f\2a '"
|
||||
==
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user