line comments progress2

This commit is contained in:
jackfoxy 2023-12-04 12:59:57 -08:00
parent fe9a3235c8
commit ada2bffbef
2 changed files with 83 additions and 58 deletions

View File

@ -8,8 +8,18 @@
:: ::
++ clip-cmnt ++ clip-cmnt
|= [p=tape q=(list @) r=(list @)] |= [p=tape q=(list @) r=(list @)]
:: |- ^- tape |- ^- tape
p ?~ q p
::~& "p: {<p>}"
::~& "q: {<q>}"
::~& "r: {<r>}"
::~& " "
?: =(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: strip line comments from tape of line
@ -17,7 +27,6 @@ p
++ line-cmnts ++ line-cmnts
|= p=tape |= p=tape
=/ a=(list @) (fand "--" p) =/ a=(list @) (fand "--" p)
::~& "a: {<a>}"
|- ^- tape |- ^- tape
?: =(0 (lent a)) p ?: =(0 (lent a)) p
=/ b=(list @) (fand "'" p) =/ b=(list @) (fand "'" p)
@ -43,7 +52,11 @@ p
?~ c ?~ c
?: =("--" (scag 2 `tape`p)) $(p ~) ?: =("--" (scag 2 `tape`p)) $(p ~)
?: &(=(a 1) =("/*" (scag 2 `tape`p))) $(p ~) ?: &(=(a 1) =("/*" (scag 2 `tape`p))) $(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) p (scag i.c `tape`p)
@ -74,6 +87,7 @@ p
|= raw-script=tape |= raw-script=tape
^- (list command:ast) ^- (list command:ast)
=/ script=tape (block-cmnts raw-script) =/ script=tape (block-cmnts raw-script)
::~& "script: {<script>}"
=/ commands `(list command:ast)`~ =/ commands `(list command:ast)`~
=/ script-length (lent script) =/ script-length (lent script)
=/ displacement 0 =/ displacement 0

View File

@ -20,80 +20,91 @@
++ s2 ~[va-hep-hep-a vfas-tar vtar-fas vhep-hep va-fas-tar-a va-tar-fas-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] ++ s3 ~[va-tar-fas-a va-hep-hep-a vfas-tar vtar-fas vhep-hep 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]
++ q1 [%query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=s1] order-by=~] ++ 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=~] ++ 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=~] ++ 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=~]
++ 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=~]
++ t1 [%transform ctes=~ set-functions=[q1 ~ ~]] ++ t1 [%transform ctes=~ set-functions=[q1 ~ ~]]
++ t2 [%transform ctes=~ set-functions=[q2 ~ ~]] ++ t2 [%transform ctes=~ set-functions=[q2 ~ ~]]
++ t3 [%transform ctes=~ set-functions=[q3 ~ ~]] ++ t3 [%transform ctes=~ set-functions=[q3 ~ ~]]
++ t1a [%transform ctes=~ set-functions=[q1a ~ ~]]
++ t2a [%transform ctes=~ set-functions=[q2a ~ ~]]
++ t3a [%transform ctes=~ set-functions=[q3a ~ ~]]
++ test-line-cmnt-00 ++ test-line-cmnt-00
%+ expect-eq %+ expect-eq
!> ~ !> ~
!> %- parse:parse(default-database 'other-db') ~ !> %- parse:parse(default-database 'other-db') ~
++ test-line-cmnt-01 ++ test-line-cmnt-01
%+ expect-eq %+ expect-eq
!> ~ !> ~
!> %- parse:parse(default-database 'other-db') %- zing ~["--line cmnt"] !> %- parse:parse(default-database 'other-db') %- zing ~["--line cmnt"]
++ test-line-cmnt-02 ++ 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 %+ expect-eq
!> ~[[%create-namespace database-name='db1' name='ns1' as-of=~]] !> ~[[%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
::++ test-line-cmnt-03 %+ expect-eq
:: %+ expect-eq !> ~[t1a t2 t3]
:: !> ~[t1 t2 t3] !> %- parse:parse(default-database 'other-db')
:: !> %- parse:parse(default-database 'other-db') %- zing
:: %- zing %- limo
:: %- limo :~ "select '\2f\2a', '*\2f' --, ' \2f\2a ', ' *\2f ', ' -- '\0a"
:: :~ "select '\2f\2a', '*\2f' --, ' \2f\2a ', ' *\2f ', ' -- '\0a" m-cmnt-1
:: m-cmnt-1 "select ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f '"
:: "select ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f '" m-cmnt-2
:: m-cmnt-2 "select ' *\2f ', ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a '"
:: "select ' *\2f ', ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a '" m-cmnt-3
:: m-cmnt-3 ==
:: == ++ test-line-cmnt-05
%+ expect-eq
::++ test-line-cmnt-04 !> ~[t1 t2a t3]
:: %+ expect-eq !> %- parse:parse(default-database 'other-db')
:: !> ~[t1 t2 t3] %- zing
:: !> %- parse:parse(default-database 'other-db') %- limo
:: %- zing :~ "select '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f ', ' -- '\0a"
:: %- limo m-cmnt-1
:: :~ "select '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f ', ' -- '\0a" "select ' -- ', '\2f\2a', '*\2f'--, ' \2f\2a ', ' *\2f '"
:: m-cmnt-1 m-cmnt-2
:: "select ' -- ', '\2f\2a', '*\2f'--, ' \2f\2a ', ' *\2f '" "select ' *\2f ', ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a '"
:: m-cmnt-2 m-cmnt-3
:: "select ' *\2f ', ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a '" ==
:: m-cmnt-3 ++ test-line-cmnt-06
:: == %+ expect-eq
!> ~[t1 t2 t3a]
::++ test-line-cmnt-05 !> %- parse:parse(default-database 'other-db')
:: %+ expect-eq %- zing
:: !> ~[t1 t2 t3] %- limo
:: !> %- parse:parse(default-database 'other-db') :~ "select '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f ', ' -- '\0a"
:: %- zing m-cmnt-1
:: %- limo "select ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f '"
:: :~ "select '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f ', ' -- '\0a" m-cmnt-2
:: m-cmnt-1 "select ' *\2f ', ' -- ', '\2f\2a', '*\2f' --, ' \2f\2a '"
:: "select ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a ', ' *\2f '" m-cmnt-3
:: m-cmnt-2 ==
:: "select ' *\2f ', ' -- ', '\2f\2a', '*\2f' --, ' \2f\2a '" ++ test-line-cmnt-07
:: m-cmnt-3 %+ expect-eq
:: == !> ~[t1a t2a t3a]
!> %- parse:parse(default-database 'other-db')
::++ test-line-cmnt-06 %- zing
:: %+ expect-eq %- limo
:: !> ~[t1 t2 t3] :~ "select '\2f\2a', '*\2f', '--', ' \2f\2a-- ', ' *\2f ', ' -- '\0a"
:: !> %- parse:parse(default-database 'other-db') "select ' -- ', '\2f\2a', '*\2f'--, ' \2f\2a ', ' *\2f '"
:: %- zing "select ' *\2f ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a '"
:: %- limo ==
:: :~ "select '\2f\2a', '*\2f', '--', ' \2f\2a-- ', ' *\2f ', ' -- '\0a"
:: "select -- ', '\2f\2a', '*\2f'--, ' \2f\2a ', ' *\2f '"
:: "select ' *\2f ' -- ', '\2f\2a', '*\2f', '--', ' \2f\2a '"
::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@