flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > [fasmg] "preprocesses" double quotes to single quotes |
Author |
|
Tomasz Grysztar 06 May 2019, 08:23
A tokenized line that fasm[g] operates on loses many properties of the original and it is generally not possible to recover the exact source text from it. For instance, if a source uses a C-like quote escaping scheme, you're going to lose it no matter what.
But when you need to work with the original sequence of characters, there are some tricks that make it possible, like in this example I prepared recently when talking about a similar problem with jacobly: Code: RAW_SOURCE = '' macro READ_RAW_SOURCE path if RAW_SOURCE <> path RAW_SOURCE = path virtual at 0 file path pos = 0 linepos = 0 linenum = 1 while pos <= $ if pos < $ load c:byte from pos else c = 10 end if if c = 13 | c = 10 repeat 1, n:linenum load RAW_SOURCE.n : pos-linepos from linepos end repeat linenum = linenum + 1 if pos+1 < $ load d:byte from pos+1 if (c = 13 & d = 10) | (c = 10 & d = 13) pos = pos + 1 end if end if linepos = pos + 1 end if pos = pos + 1 end while end virtual end if end macro macro ?! line& match =go =wild: foo, line READ_RAW_SOURCE __FILE__ repeat 1, n:__LINE__ display RAW_SOURCE.n,13,10 end repeat else display `line,13,10 end match end macro db ? ; comment go wild: this line's going to be read raw from the source; in entirety go wild: "\"" |
|||
06 May 2019, 08:23 |
|
Mike Gonta 06 May 2019, 20:40
Perfect.
I was wondering why the match doesn't work in this example. Code: macro ?! line& READ_RAW_SOURCE __FILE__ repeat 1, n:__LINE__ source = RAW_SOURCE.n end repeat match =go? foo , source display source,13,10 else ; display source,13,10 end match end macro db ? ; comment go wild: this line's going to be read raw from the source; in entirety go wild: "\"" |
|||
06 May 2019, 20:40 |
|
Tomasz Grysztar 07 May 2019, 07:37
Mike Gonta wrote: I was wondering why the match doesn't work in this example. Code: if source and 0FFFFh = 'go' | source and 0FFFFh = 'Go' | source and 0FFFFh = 'GO' | source and 0FFFFh = 'gO' display source,13,10 end if Code: repeat 1, n:__LINE__ eval 'define source ',RAW_SOURCE.n end repeat match =go? foo , source display `foo,13,10 end match Therefore: in your example use "line" when you need to MATCH, use "source" when you need to work with original, raw text. |
|||
07 May 2019, 07:37 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.