SkyTemple / ExplorerScript

ExplorerScript and SSBScript: Script languages for decompiled SSB (Pokémon Mystery Dungeon Explorers of Sky)
MIT License
16 stars 6 forks source link

String concatenation in const-evaluation expressions #57

Open theCapypara opened 2 months ago

theCapypara commented 2 months ago

Summary

Allows strings to be concatenated in const-evaluation expressions

Dependencies

This needs the following features to be implemented first:

Motivation

This allows for meta programming with strings.

Examples

const XYZ = "Hello " + CONST + ", how are you";

Language Changes

Parser and Lexer Changes

Depends on how arithmetic expressions in const-evaluation expressions have been implemented.

Behaviour

Adds a new expression with the same syntax as arithmetic integer expressions. If the first part of the expression is a string (or a constant coercing to a string) then this new expression applies. The result of the expression is a string where all strings in it are combined into one. The combining operator is "+". Any integers or decimals as part of the expression are converted into their string representations. Constants and variables are evaluated before concatenations. As always any part of the expression can be a sub-expression.

Compiler Implementation

Compiler Interface Changes

None

Decompiler Changes

None

How to teach

Add to manual on meta programming

Alternatives

/

Backwards compatibility

None