84f35c8b44
Besides code cleanup, this commit changes the sanitization logic to avoid numeric digits altogether. Previously, they had been allowed at the end of a label name, but this is susceptible to a ZZT parser bug: `#foo` matches `:foo2` because ZZT allows a prefix match if the next character is a digit.
83 lines
1.1 KiB
Plaintext
83 lines
1.1 KiB
Plaintext
---
|
|
source: src/labels/process.rs
|
|
expression: board_to_text(board)
|
|
---
|
|
'Slightly contrived example: two routines
|
|
'using the same local label ".loop"
|
|
:run_w
|
|
#walk w
|
|
:loop
|
|
#try w stop
|
|
#loop
|
|
'
|
|
:run_e
|
|
#walk e
|
|
:loop_
|
|
#try e stop
|
|
#loop_
|
|
'
|
|
:stop
|
|
#walk i
|
|
---
|
|
'Using locals before any globals are defined
|
|
:loopa
|
|
#take gems 1 break
|
|
#loopa
|
|
:break
|
|
---
|
|
'Multiple sections with the same name
|
|
#end
|
|
:touch
|
|
Trying to sell you some ammo...
|
|
#take gems 10 skip
|
|
#give ammo 10
|
|
:skip
|
|
#zap touch
|
|
#end
|
|
:touch
|
|
Trying to sell you some torches...
|
|
#take gems 15 skip_
|
|
#give torches 5
|
|
:skip_
|
|
#restore touch
|
|
---
|
|
'Multiple locals with the same name
|
|
#end
|
|
:repeat_
|
|
:z
|
|
:z
|
|
:z
|
|
#take gems 1 skipa
|
|
#give score 1
|
|
:skipa
|
|
#zap z
|
|
#z
|
|
:z
|
|
---
|
|
'Addressing labels with section.local
|
|
:touch
|
|
:foo
|
|
#end
|
|
:touch
|
|
:foo_
|
|
#end
|
|
:shot
|
|
'sends to the first one:
|
|
#foo
|
|
---
|
|
@alice
|
|
:shared
|
|
'this is the 1st section named "shared"
|
|
'but its local should correspond with @bob's 2nd "shared"
|
|
:local
|
|
#end
|
|
:shared
|
|
---
|
|
@bob
|
|
:shared
|
|
#end
|
|
:shared
|
|
'this is the 2nd section named "shared"
|
|
'but its local should correspond with @alice's 1st "shared"
|
|
:local
|