degory / ghul

compiler for the ghūl programming language
https://ghul.dev
GNU Affero General Public License v3.0
4 stars 0 forks source link

Adjacent string literal concatenation #1072

Open degory opened 9 months ago

degory commented 9 months ago

Automatically concatenate adjacent string literals together into a single string at compile time.

For example

"hello "  "world"

Should be treated as if it were "hello world"

We can potentially do this directly in the tokenizer. It's probably acceptable for the source file location to be set to the union of the two (or more) string extents - e.g. we don't need to be able to report errors against the individual string segments, or leave a gap in the red underlining where there are gaps between the adjacent concatenated strings.

We also could insert newlines into the concatenated string where joined strings are on separate source lines. I'm not convinced this is a good idea though, and on balance would prefer to have some separate syntax for multi-line string literals.