Skip to content

Commit

Permalink
allow renaming to _ and idents beginning with it - they're just as (i…
Browse files Browse the repository at this point in the history
…f not even less) likely to be introduced and break future carts as regular identifiers
  • Loading branch information
thisismypassport committed Oct 5, 2023
1 parent 557b6a2 commit 2e484e5
Show file tree
Hide file tree
Showing 11 changed files with 299 additions and 299 deletions.
2 changes: 1 addition & 1 deletion pico_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def collect_idents_pre(node):

def get_next_ident_char(ch, first):
nextch = ident_char_order_map.get(ch) if ch else ident_chars[0]
while first and nextch and (nextch.isdigit() or nextch == '_'): # note: we avoid leading underscores too
while first and nextch and nextch.isdigit():
nextch = ident_char_order_map.get(nextch)
if nextch:
return nextch, True
Expand Down
2 changes: 1 addition & 1 deletion test_compare/output.p8
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ local e={1},{1,2,3,4}local e,l=1~=2,1,1.2345,4660,4660.33777,-1,-1.2345,-4660.33
local e=({})[1],(function()end)()local l,n,o,e,f=sin(1,2),cos((cos())),(cos((cos()))),{d=ord,r=pal}local e=ord"123",pal{1,2},e:d("ord"),e:r({1,2}),sin(1)local i={ord"1",[2]=3,o=4,(ord"1")}e+=1l,n=sin(1,2),cos((cos()))o,f=(cos((cos())))function u()return 1,2,ord"1",(ord"1")end if 1==2then elseif 1==2then else end while 1==2do end repeat until 1==1for e in(all{})do end print("test"..@16 .."str")if(true)?"sh1"
if true then?"sh2"
end if(true)if false then else print"sh3"end
if true then if false then else print"sh4"end end q="renaming bug"function a()local e,l,n,o,f,i,c,a,d,r,t,h,s,u,x,k,y,v,p,b,w,g,m,E,N,D,j return q end?a()
if true then if false then else print"sh4"end end j="renaming bug"function a()local e,l,n,o,f,i,c,a,d,r,t,h,s,u,x,k,y,v,p,b,w,g,_,m,E,N,D return j end?a()
c=0c=1function new_name(new_name,e)return new_name.new_member,e.new_member end function new_name(new_name2,e,l)local e,l return new_name2.new_member end x=?"END!"
2 changes: 1 addition & 1 deletion test_compare/output_minrename-ih.p8
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ local e={1},{1,2,3,4}local e,n=1~=2,1,1.2345,4660,4660.33777,-1,-1.2345,-4660.33
local e=({})[1],(function()end)()local n,o,f,e,i=sin(1,2),cos((cos())),(cos((cos()))),{ord=ord,pal=pal}local e=ord"123",pal{1,2},e:ord("ord"),e:pal({1,2}),sin(1)local c={ord"1",[2]=3,x=4,(ord"1")}e+=1n,o=sin(1,2),cos((cos()))f,i=(cos((cos())))function xxx()return 1,2,ord"1",(ord"1")end if 1==2then elseif 1==2then else end while 1==2do end repeat until 1==1for e in(all{})do end print("test"..@16 .."str")if(true)?"sh1"
if true then?"sh2"
end if(true)if false then else print"sh3"end
if true then if false then else print"sh4"end end l="renaming bug"function fff()local e,n,o,f,i,c,a,d,r,t,h,s,u,x,k,y,v,p,b,w,g,m,E,N,D,j,q return l end?fff()
if true then if false then else print"sh4"end end l="renaming bug"function fff()local e,n,o,f,i,c,a,d,r,t,h,s,u,x,k,y,v,p,b,w,g,_,m,E,N,D,j return l end?fff()
x=0 x=1function old_name(e,l)return e.old_member,l.old_member end function old_name(e,l,n)local l,n return e.old_member end done=?"END!"
2 changes: 1 addition & 1 deletion test_compare/output_minrename-ob.p8
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ local e={assert=assert,add=add}do local _ENV=e assert(add({},1)==1)end do local
?((~(((((((tonum(((3or 4)and 5)~=2)|1)~2)&3)>>1)..1)-(1+3))*3))^2)^1
local e=({})[1],(function()end)()local n,o,f,e,i=sin(1,2),cos((cos())),(cos((cos()))),{ord=ord,pal=pal}local e=ord"123",pal{1,2},e:ord("ord"),e:pal({1,2}),sin(1)local c={ord"1",[2]=3,x=4,(ord"1")}e+=1n,o=sin(1,2),cos((cos()))f,i=(cos((cos())))function xxx()return 1,2,ord"1",(ord"1")end if 1==2then elseif 1==2then else end while 1==2do end repeat until 1==1for e in(all{})do end print("test"..@16 .."str")if true then?"sh1"
end if true then?"sh2"
end if true then if false then else print"sh3"end end if true then if false then else print"sh4"end end l="renaming bug"function fff()local e,n,o,f,i,c,a,d,r,t,h,s,u,x,k,y,v,p,b,w,g,m,j,q,z,e1,ee return l end?fff()
end if true then if false then else print"sh3"end end if true then if false then else print"sh4"end end l="renaming bug"function fff()local e,n,o,f,i,c,a,d,r,t,h,s,u,x,k,y,v,p,b,w,g,_,m,j,q,z,e1 return l end?fff()
x=0 x=1function old_name(e,l)return e.old_member,l.old_member end function old_name(e,l,n)local l,n return e.old_member end done=?"END!"
2 changes: 1 addition & 1 deletion test_compare/output_minrename-oc.p8
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ repeat until 1==1for e in(all{})do end print("test"..@16 .."str")if(true)?"sh1"
if true then?"sh2"
end if(true)if false then else print"sh3"end
if true then if(false);else print"sh4"
end l="renaming bug"function fff()local e,n,o,f,i,c,a,d,r,t,h,s,u,x,k,y,v,p,♥,b,w,g,ら,m,E,N,D return l end?fff()
end l="renaming bug"function fff()local e,n,o,f,i,c,a,d,r,t,h,s,u,x,k,y,v,p,♥,b,w,g,_,ら,m,E,N return l end?fff()
x=0 x=1function old_name(e,l)return e.old_member,l.old_member end function old_name(e,l,n)local l,n return e.old_member end done=?"END!"
2 changes: 1 addition & 1 deletion test_compare/output_minrename.p8
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ local e={1},{1,2,3,4}local e,n=1~=2,1,1.2345,4660,4660.33777,-1,-1.2345,-4660.33
local e=({})[1],(function()end)()local n,o,f,e,i=sin(1,2),cos((cos())),(cos((cos()))),{ord=ord,pal=pal}local e=ord"123",pal{1,2},e:ord("ord"),e:pal({1,2}),sin(1)local c={ord"1",[2]=3,x=4,(ord"1")}e+=1n,o=sin(1,2),cos((cos()))f,i=(cos((cos())))function xxx()return 1,2,ord"1",(ord"1")end if 1==2then elseif 1==2then else end while 1==2do end repeat until 1==1for e in(all{})do end print("test"..@16 .."str")if(true)?"sh1"
if true then?"sh2"
end if(true)if false then else print"sh3"end
if true then if false then else print"sh4"end end l="renaming bug"function fff()local e,n,o,f,i,c,a,d,r,t,h,s,u,x,k,y,v,p,b,w,g,m,E,N,D,j,q return l end?fff()
if true then if false then else print"sh4"end end l="renaming bug"function fff()local e,n,o,f,i,c,a,d,r,t,h,s,u,x,k,y,v,p,b,w,g,_,m,E,N,D,j return l end?fff()
x=0 x=1function new_name(new_name,e)return new_name.new_member,e.new_member end function new_name(new_name2,e,l)local e,l return new_name2.new_member end done=?"END!"
6 changes: 3 additions & 3 deletions test_compare/output_semiob.p8
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ end
if(true) if false then else print"sh3" end
if true then if false then else print"sh4" end end

q="renaming bug"
j="renaming bug"
function a()
local e,l,n,o,f,i,c,a,d,r,t,h,s,u,x,k,y,v,p,b,w,g,m,E,N,D,j
return q
local e,l,n,o,f,i,c,a,d,r,t,h,s,u,x,k,y,v,p,b,w,g,_,m,E,N,D
return j
end
?a()
c=0c=1
Expand Down
2 changes: 1 addition & 1 deletion test_compare/repl-ob.p8

Large diffs are not rendered by default.

Loading

0 comments on commit 2e484e5

Please sign in to comment.