boot2

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

031-string-via-macro.M1pp (535B)


      1 # String emission through macro substitution: STRING tokens passed as
      2 # a macro argument decode to bytes when the body's `s` is rescanned at
      3 # the call site.
      4 
      5 %macro EMIT(s)
      6 s
      7 %endm
      8 
      9 %macro PREFIXED(s)
     10 AA
     11 s
     12 BB
     13 %endm
     14 
     15 # Literal string passed through a macro arg.
     16 %EMIT("hi")
     17 
     18 # Surrounded by literal hex inside the body, to confirm hex2pp's
     19 # byte-stream coalescing works across the rescan boundary.
     20 %PREFIXED("ok")
     21 
     22 # Each escape exercised again, but via macro substitution.
     23 %EMIT("a\nb")
     24 
     25 # Empty string substituted in.
     26 %EMIT("")
     27 END