boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

029-string-escapes.M1pp (660B)


      1 # String escape decoding at emission.
      2 #  - In the lexer, `\X` inside a STRING is one unit (so `\"` and `\\`
      3 #    do NOT terminate the literal), but the byte value is left for the
      4 #    emitter to decode.
      5 #  - At output, `\\` becomes `5C`, `\"` becomes `22`, etc. — the same
      6 #    table used to live behind `%bytes(...)` and now applies to every
      7 #    bare string token.
      8 #  - Both quote styles ("..." and '...') participate.
      9 
     10 "plain"
     11 "with \"quoted\" inside"
     12 "trailing backslash pair: \\"
     13 "mixed \\ and \" together"
     14 'single \"quoted\" inside'
     15 'single \\ pair'
     16 
     17 %macro emit(s)
     18 s
     19 %endm
     20 
     21 %emit("arg with \"escaped\" quotes")
     22 %emit("arg with \\ backslash pair")
     23 END