Skip to content

[Feature request] Multi-line string literals #589

@Rangi42

Description

@Rangi42

Python has """triple""" '''quotes''', bash has << HEREDOC, and ES6 has `template literals`. Any multi-line string literal syntax would be useful, particularly for metaprogramming.

When a macro defines another macro, the inner macro definition is just skipped over until it reaches an ENDM token; this prevents the outer macro from controlling just how the inner one is defined. For that, it needs to use an EQUS. For example:

make_rep: MACRO
REP EQUS "\n\1: MACRO\nREPT \2\n\tdb \\1\nENDR\nENDM"
  REP
  PURGE REP
ENDM

  make_rep double, 2
  make_rep triple, 3
  double $20  ; db $20, $20
  triple $42  ; db $42, $42, $42

Something like this would be more legible:

make_rep: MACRO
REP EQUS """
\1: MACRO
REPT \2
	db \\1
ENDR
ENDM"""
  REP
  PURGE REP
ENDM

Even if the inner macro has to be built up from some STRCATs, the pieces would benefit from multi-line formatting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementTypically new features; lesser priority than bugsrgbasmThis affects RGBASM

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions