Page 2 of 2
Re: BASIC and strings
Posted: Mon Sep 09, 2013 11:26 am
by jedie
Anyone knows if dragon replace "tokens" in comments in memory and on tape?
e.g.:
would be changed to:
btw. REM and ' are themself tokens... Maybe the line would be stored as:
Re: BASIC and strings
Posted: Mon Sep 09, 2013 12:37 pm
by Sarah
No. The text is treated as text.
Re: BASIC and strings
Posted: Sun Aug 17, 2014 4:19 pm
by jedie
Now i can test it in DragonPy... I used this listing and used the function to extract the BASIC Listing...
I used this example code line:
And extract it, i see this debug output:
Code: Select all
BASIC program dump:
$1e $16
$00
$0a $3a $83 $20 $50 $52 $49 $4e $54 $20 $22 $50 $52 $49 $4e $54 $22
$00
$00
$00
progam start $1e01
next_address: $1e16
line_number: 10
length: 21
tokens: $3a,$83,$20,$50,$52,$49,$4e,$54,$20,$22,$50,$52,$49,$4e,$54,$22,$00
progam start $1e16
next_address: $0000
So, yes: No tokens in comment lines... A translation:
Code: Select all
0x0a -> 10
0x3a -> ":"
0x83 -> "'"
0x20 -> ' '
0x50 -> 'P'
0x52 -> 'R'
0x49 -> 'I'
0x4e -> 'N'
0x54 -> 'T'
0x20 -> ' '
0x22 -> '"'
0x50 -> 'P'
0x52 -> 'R'
0x49 -> 'I'
0x4e -> 'N'
0x54 -> 'T'
0x22 -> '"'
The interesting thing here is, that there is a
: inserted before the comment!
e.g.: You write this:
and the internal representations is this:
Re: BASIC and strings
Posted: Mon Aug 18, 2014 6:44 pm
by JeeK
jedie wrote:Now i can test it in DragonPy... I used this listing and used the function to extract the BASIC Listing...
[..]
So, yes: No tokens in comment lines... A translation:
Code: Select all
0x0a -> 10
0x3a -> ":"
0x83 -> "'"
0x20 -> ' '
0x50 -> 'P'
0x52 -> 'R'
0x49 -> 'I'
0x4e -> 'N'
0x54 -> 'T'
0x20 -> ' '
0x22 -> '"'
0x50 -> 'P'
0x52 -> 'R'
0x49 -> 'I'
0x4e -> 'N'
0x54 -> 'T'
0x22 -> '"'
The interesting thing here is, that there is a
: inserted before the comment!
e.g.: You write this:
and the internal representations is this:
This is to satisfy how the interpreter is working. Since the commentary single quote can start right after a basic statement, the interpreter has to be told that the comment starts. The comment is also a "statement" and a statement can only start at a line beginning or after the statement separator ":". The BASIC tokenizer silently inserts the ":" and LIST does the suppress.
Same for ELSE.
Re: BASIC and strings
Posted: Mon Aug 18, 2014 8:08 pm
by jedie
That makes sense. And yes, i see the same with "ELSE"...
Are ' and ELSE the only "exceptions" ?
Maybe i add simple replace rules:
Re: BASIC and strings
Posted: Wed Aug 20, 2014 6:24 am
by JeeK
jedie wrote:That makes sense. And yes, i see the same with "ELSE"...
Are ' and ELSE the only "exceptions" ?
Maybe i add simple replace rules:
I think so, but I actually didn't analyze the LIST routine in ROM where such thing could be observed. Even with my de-tokenizer script I saw no other "constructions" like this (for a limited collection of programs I wrote). But this observation is probably neither complete nor will prove this fact ...
Re: BASIC and strings
Posted: Wed Aug 20, 2014 4:56 pm
by jedie
With
https://github.com/jedie/DragonPy/commi ... c2990eb096 i do the ' <-> :' and ELSE <-> :ELSE replacement internally in my Emulator<->BASIC-Editor
Seems to work fine