support for _ and ... as literals

This commit is contained in:
ESL 2024-10-21 15:17:56 -04:00
parent 8d8721892e
commit e38354cbff
2 changed files with 61 additions and 58 deletions

View file

@ -783,20 +783,22 @@
; nb: 'real' ... is a builtin, at this time possibly registered in rnr
(define ellipsis-den ; we may need to be first to alloc ... binding!
(name-lookup *root-name-registry* '... (lambda (n) '...)))
; now we need just peek x in maro env to compare with the above
; now we need just peek x in macro env to compare with the above
(define (ellipsis? x)
(and (id? x) (not (pat-literal? x))
(if ellipsis (eq? x ellipsis) ; custom one is given
(and (id? x) (eq? (mac-env x 'peek) ellipsis-den))))
(and (id? x) (eq? (mac-env x 'peek) ellipsis-den)))))
; ditto for underscore
(define underscore-den ; we may need to be first to alloc _ binding!
(name-lookup *root-name-registry* '_ (lambda (n) '_)))
(define (underscore? x)
(and (id? x) (eq? (mac-env x 'peek) underscore-den)))
(and (id? x) (not (pat-literal? x))
(eq? (mac-env x 'peek) underscore-den)))
; slow version of the above for escape keywords
(define (id-escape=? x s)
(and (id? x)
(and (id? x) (not (pat-literal? x))
(eq? (mac-env x 'peek)
(name-lookup *root-name-registry* s (lambda (n) (list 'ref s))))))
@ -2758,7 +2760,7 @@
[help "-h" "--help" #f "Display this help"]
))
(define *skint-version* "0.6.3")
(define *skint-version* "0.6.4")
(define (implementation-version) *skint-version*)
(define (implementation-name) "SKINT")

105
t.c
View file

@ -487,57 +487,58 @@ char *t_code[] = {
"%4,,,,,,,,,,,,#0#1#2#3#4#5#6#7#8#9#(i10)#(i11).(i14),&1{%1:0,.1A0]1}.!"
"0.0,&1{%1${.2,:0^[01}~]1}.!1.4,&1{%1.0p?{.0a,:0^[11}f]1}.!2${&0{%1'(y3"
":...)]1},'(y3:...),@(y20:*root-name-registry*),@(y11:name-lookup)[03}."
"!3.(i12),.4,.(i15),&3{%1:0?{:0,.1q]1}${.2,@(y3:id?)[01}?{:1^,${'(y4:pe"
"ek),.4,:2[02}q]1}f]1}.!4${&0{%1'(y1:_)]1},'(y1:_),@(y20:*root-name-reg"
"istry*),@(y11:name-lookup)[03}.!5.(i12),.6,&2{%1${.2,@(y3:id?)[01}?{:0"
"^,${'(y4:peek),.4,:1[02}q]1}f]1}.!6.(i12),&1{%2${.2,@(y3:id?)[01}?{${."
"3,&1{%1:0,'(y3:ref),l2]1},.4,@(y20:*root-name-registry*),@(y11:name-lo"
"okup)[03},${'(y4:peek),.4,:0[02}q]2}f]2}.!7.4,.3,&2{%3n,.2,.2,,#0:0,.1"
",:1,.9,&4{%3${.2,@(y3:id?)[01}?{.1?{${.2,:0[01}}{f}?{.2,.1c]3}.2]3}.0V"
"0?{.2,.2,.2X0,:2^[33}.0Y2?{.2,.2,.2z,:2^[33}${.2,@(y7:list3+?)[01}?{${"
".2a,:1^[01}}{f}?{.2,.2,.2dd,:2^[33}.0p?{${.2d,:3^[01}?{${.4,.4,.4dd,:2"
"^[03},t,.2a,:2^[33}${.4,.4,.4d,:2^[03},.2,.2a,:2^[33}.2]3}.!0.0^_1[33}"
".!8.4,&1{%2'0,.1,,#0.0,.4,.6,:0,&4{%2.0p~?{.1]2}:1?{${.2a,:0^[01}}{f}?"
"{:2,'(s41:misplaced ellipsis in syntax-case pattern),@(y7:x-error)[22}"
"'1,.2I+,.1d,:3^[22}.!0.0^_1[22}.!9.7,.5,.4,.(i12),.5,.(i13),.6,.(i19),"
".(i14),&9{%3k3,.0,,#0.1,&1{%0f,:0[01}.!0f,n,.6,.6,,#0:8,:7,:6,:5,:4,:3"
",.6,.(i12),:2,:1,.(i20),:0,&(i12){%4,#0:4,.4,&2{%1.0?{:0]1}:1^[10}.!0."
"4~?{${.3,:0^[01}}{f}?{.3]5}${.3,@(y3:id?)[01}?{${.3,:3^[01}?{${.4,@(y3"
":id?)[01}?{${:2,.4,:1,.7,@(y9:free-id=?)[04}}{f},.1^[51}.3,.3,.3cc]5}."
"1V0?{.2V0,.0?{.0}{${:4^[00}}_1.4,.4,.4X0,.4X0,:5^[54}.1Y2?{.2Y2,.0?{.0"
"}{${:4^[00}}_1.4,.4,.4z,.4z,:5^[54}.1p~?{.2,.2e,.1^[51}.4~?{${.3a,:(i1"
"0)^[01}?{${.3,@(y6:list2?)[01}}{f}}{f}?{t,.4,.4,.4da,:5^[54}.4~?{${.3a"
",:(i10)^[01}?{${.3,@(y6:list3?)[01}?{${:(i11)^,.4da,@(y20:pattern-esca"
"pe->test)[02}}{f}}{f}}{f},.0?{.0,${.6,.3[01}?{.6,.6,.6,.6dda,:5^[74}:4"
"^[70}.5~?{${.4a,:(i10)^[01}}{f}?{.2,'(s27:unrecognized pattern escape)"
",@(y7:x-error)[62}.5~?{${.4d,:9^[01}}{f}?{${t,.5dd,:8^[02},${f,.7,:8^["
"02},.1,.1I-,.0<0?{${:4^[00}}{.0,.7A6},${.3,.(i10),@(y9:list-head)[02},"
"${:7^,t,.(i11)a,:6^[03},,#0:5,.(i10),.(i14),&3{%1${:0,n,.4,:1a,:2^[04}"
",@(y3:cdr),@(y5:%25map1)[12}.!0${.(i14),.(i14),.7,.(i14)dd,:5^[04},${$"
"{.7,.6^,@(y5:%25map1)[02},.5c,@(y4:list)c,@(y4:%25map),@(y13:apply-to-"
"list)[02}L6](i13)}.3p?{.5,${.8,.8,.8d,.8d,:5^[04},.5a,.5a,:5^[64}:4^[6"
"0}.!0.0^_1[64}.!(i10).(i12),.2,.(i10),.(i10),.8,.7,&6{%4,,,#0#1#2,#0${"
"${.(i10),&1{%1:0,.1A3~]1},t,.(i11),:3^[03},:5,.4,&2{%1${:0,&1{%0:0^]0}"
",:1,.4,@(y14:new-literal-id)[03},.1c]1},@(y5:%25map1)[02}.!0.0^_1.!0${"
":4^,f,.7,:3^[03}.!1.1,:3,&2{%1:1,&1{%1:0^,.1A0]1},t,.2,:0^[13}.!2f,.6,"
".6,,#0.9,.5,.2,.9,:0,:1,:2,&7{%3.2,.1,,#0:0,:1,:2,:3,:4,.9,.6,:5,:6,&9"
"{%2${.2,@(y3:id?)[01}?{:3,.1A3,.0?{.0}{:0,.2A3,.0?{.0}{:1^,.3A3}_1}_1d"
"]2}.0V0?{${.3,.3X0,:2^[02}X1]2}.0Y2?{${.3,.3z,:2^[02}b]2}.0p~?{.0]2}.1"
"~?{${.2a,:7^[01}?{${.2,@(y7:list3+?)[01}?{${:8^,.3da,@(y21:template-es"
"cape->conv)[02}}{f}}{f}}{f},.0?{.0,${.5,.5dd,:2^[02},.1[41}.2~?{${.3a,"
":7^[01}?{${.3,@(y6:list2?)[01}}{f}}{f}?{t,.2da,:2^[32}.2~?{${.3a,:7^[0"
"1}}{f}?{.1,'(s28:unrecognized template escape),@(y7:x-error)[32}.2~?{$"
"{.3d,:6^[01}}{f}?{${.3a,:5^[01},,,#0#1:3,&1{%1:0,.1A3d]1}.!0.2,.5,:4,&"
"3{%!1.1,${.3,:2,@(y4:cons),@(y5:%25map2)[03},:1a,:0^[23}.!1.2u?{${.7,."
"7dd,:2^[02},${.8,.8a,:2^[02}c]6}.5,.2,&2{%!0.0,:1c,:0^,@(y13:apply-to-"
"list)[12},${.5,.4^,@(y5:%25map1)[02},${.9,.9dd,:2^[02},${.3,.5c,@(y4:%"
"25map),@(y13:apply-to-list)[02}L6]8}${.4,.4d,:2^[02},${.5,.5a,:2^[02}c"
"]3}.!0.0^_1[32}.!0.0^_1[73}.!(i11).(i15),.(i11),.(i13),&3{%2:2,,#0.0,:"
"0,.5,:1,.6,&5{%1.0u?{${:0,'(s14:invalid syntax),@(y7:x-error)[02}}.0d,"
".1a,${.2,@(y6:list2?)[01}~?{${.2,'(s19:invalid syntax rule),@(y7:x-err"
"or)[02}}.0ap?{${.2aa,@(y3:id?)[01}?{:0p}{f}}{f},.0?{.1ad}{.1a},.1?{:0d"
"}{:0},.3da,${:2,.4,.6,:1^[03},.0?{.0,:2,.1,.4,.7,:3^[94}.6,:4^[81}.!0."
"0^_1[21}](i16)",
"!3.0,.(i13),.5,.(i16),&4{%1${.2,@(y3:id?)[01}?{${.2,:3^[01}~?{:0?{:0,."
"1q]1}${.2,@(y3:id?)[01}?{:1^,${'(y4:peek),.4,:2[02}q]1}f]1}f]1}f]1}.!4"
"${&0{%1'(y1:_)]1},'(y1:_),@(y20:*root-name-registry*),@(y11:name-looku"
"p)[03}.!5.0,.6,.(i14),&3{%1${.2,@(y3:id?)[01}?{${.2,:2^[01}~?{:1^,${'("
"y4:peek),.4,:0[02}q]1}f]1}f]1}.!6.0,.(i13),&2{%2${.2,@(y3:id?)[01}?{${"
".2,:1^[01}~?{${.3,&1{%1:0,'(y3:ref),l2]1},.4,@(y20:*root-name-registry"
"*),@(y11:name-lookup)[03},${'(y4:peek),.4,:0[02}q]2}f]2}f]2}.!7.4,.3,&"
"2{%3n,.2,.2,,#0:0,.1,:1,.9,&4{%3${.2,@(y3:id?)[01}?{.1?{${.2,:0[01}}{f"
"}?{.2,.1c]3}.2]3}.0V0?{.2,.2,.2X0,:2^[33}.0Y2?{.2,.2,.2z,:2^[33}${.2,@"
"(y7:list3+?)[01}?{${.2a,:1^[01}}{f}?{.2,.2,.2dd,:2^[33}.0p?{${.2d,:3^["
"01}?{${.4,.4,.4dd,:2^[03},t,.2a,:2^[33}${.4,.4,.4d,:2^[03},.2,.2a,:2^["
"33}.2]3}.!0.0^_1[33}.!8.4,&1{%2'0,.1,,#0.0,.4,.6,:0,&4{%2.0p~?{.1]2}:1"
"?{${.2a,:0^[01}}{f}?{:2,'(s41:misplaced ellipsis in syntax-case patter"
"n),@(y7:x-error)[22}'1,.2I+,.1d,:3^[22}.!0.0^_1[22}.!9.7,.5,.4,.(i12),"
".5,.(i13),.6,.(i19),.(i14),&9{%3k3,.0,,#0.1,&1{%0f,:0[01}.!0f,n,.6,.6,"
",#0:8,:7,:6,:5,:4,:3,.6,.(i12),:2,:1,.(i20),:0,&(i12){%4,#0:4,.4,&2{%1"
".0?{:0]1}:1^[10}.!0.4~?{${.3,:0^[01}}{f}?{.3]5}${.3,@(y3:id?)[01}?{${."
"3,:3^[01}?{${.4,@(y3:id?)[01}?{${:2,.4,:1,.7,@(y9:free-id=?)[04}}{f},."
"1^[51}.3,.3,.3cc]5}.1V0?{.2V0,.0?{.0}{${:4^[00}}_1.4,.4,.4X0,.4X0,:5^["
"54}.1Y2?{.2Y2,.0?{.0}{${:4^[00}}_1.4,.4,.4z,.4z,:5^[54}.1p~?{.2,.2e,.1"
"^[51}.4~?{${.3a,:(i10)^[01}?{${.3,@(y6:list2?)[01}}{f}}{f}?{t,.4,.4,.4"
"da,:5^[54}.4~?{${.3a,:(i10)^[01}?{${.3,@(y6:list3?)[01}?{${:(i11)^,.4d"
"a,@(y20:pattern-escape->test)[02}}{f}}{f}}{f},.0?{.0,${.6,.3[01}?{.6,."
"6,.6,.6dda,:5^[74}:4^[70}.5~?{${.4a,:(i10)^[01}}{f}?{.2,'(s27:unrecogn"
"ized pattern escape),@(y7:x-error)[62}.5~?{${.4d,:9^[01}}{f}?{${t,.5dd"
",:8^[02},${f,.7,:8^[02},.1,.1I-,.0<0?{${:4^[00}}{.0,.7A6},${.3,.(i10),"
"@(y9:list-head)[02},${:7^,t,.(i11)a,:6^[03},,#0:5,.(i10),.(i14),&3{%1$"
"{:0,n,.4,:1a,:2^[04},@(y3:cdr),@(y5:%25map1)[12}.!0${.(i14),.(i14),.7,"
".(i14)dd,:5^[04},${${.7,.6^,@(y5:%25map1)[02},.5c,@(y4:list)c,@(y4:%25"
"map),@(y13:apply-to-list)[02}L6](i13)}.3p?{.5,${.8,.8,.8d,.8d,:5^[04},"
".5a,.5a,:5^[64}:4^[60}.!0.0^_1[64}.!(i10).(i12),.2,.(i10),.(i10),.8,.7"
",&6{%4,,,#0#1#2,#0${${.(i10),&1{%1:0,.1A3~]1},t,.(i11),:3^[03},:5,.4,&"
"2{%1${:0,&1{%0:0^]0},:1,.4,@(y14:new-literal-id)[03},.1c]1},@(y5:%25ma"
"p1)[02}.!0.0^_1.!0${:4^,f,.7,:3^[03}.!1.1,:3,&2{%1:1,&1{%1:0^,.1A0]1},"
"t,.2,:0^[13}.!2f,.6,.6,,#0.9,.5,.2,.9,:0,:1,:2,&7{%3.2,.1,,#0:0,:1,:2,"
":3,:4,.9,.6,:5,:6,&9{%2${.2,@(y3:id?)[01}?{:3,.1A3,.0?{.0}{:0,.2A3,.0?"
"{.0}{:1^,.3A3}_1}_1d]2}.0V0?{${.3,.3X0,:2^[02}X1]2}.0Y2?{${.3,.3z,:2^["
"02}b]2}.0p~?{.0]2}.1~?{${.2a,:7^[01}?{${.2,@(y7:list3+?)[01}?{${:8^,.3"
"da,@(y21:template-escape->conv)[02}}{f}}{f}}{f},.0?{.0,${.5,.5dd,:2^[0"
"2},.1[41}.2~?{${.3a,:7^[01}?{${.3,@(y6:list2?)[01}}{f}}{f}?{t,.2da,:2^"
"[32}.2~?{${.3a,:7^[01}}{f}?{.1,'(s28:unrecognized template escape),@(y"
"7:x-error)[32}.2~?{${.3d,:6^[01}}{f}?{${.3a,:5^[01},,,#0#1:3,&1{%1:0,."
"1A3d]1}.!0.2,.5,:4,&3{%!1.1,${.3,:2,@(y4:cons),@(y5:%25map2)[03},:1a,:"
"0^[23}.!1.2u?{${.7,.7dd,:2^[02},${.8,.8a,:2^[02}c]6}.5,.2,&2{%!0.0,:1c"
",:0^,@(y13:apply-to-list)[12},${.5,.4^,@(y5:%25map1)[02},${.9,.9dd,:2^"
"[02},${.3,.5c,@(y4:%25map),@(y13:apply-to-list)[02}L6]8}${.4,.4d,:2^[0"
"2},${.5,.5a,:2^[02}c]3}.!0.0^_1[32}.!0.0^_1[73}.!(i11).(i15),.(i11),.("
"i13),&3{%2:2,,#0.0,:0,.5,:1,.6,&5{%1.0u?{${:0,'(s14:invalid syntax),@("
"y7:x-error)[02}}.0d,.1a,${.2,@(y6:list2?)[01}~?{${.2,'(s19:invalid syn"
"tax rule),@(y7:x-error)[02}}.0ap?{${.2aa,@(y3:id?)[01}?{:0p}{f}}{f},.0"
"?{.1ad}{.1a},.1?{:0d}{:0},.3da,${:2,.4,.6,:1^[03},.0?{.0,:2,.1,.4,.7,:"
"3^[94}.6,:4^[81}.!0.0^_1[21}](i16)",
"P", "make-include-transformer",
"%1,,,,#0#1#2#3&0{%2${.2,@(y6:list2?)[01}?{.0daS0}{f}~?{${.2,'(s14:inva"
@ -1736,7 +1737,7 @@ char *t_code[] = {
"kint-options*)",
"C", 0,
"'(s5:0.6.3)@!(y15:*skint-version*)",
"'(s5:0.6.4)@!(y15:*skint-version*)",
"P", "implementation-version",
"%0@(y15:*skint-version*)]0",