Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concatenate adjacent string literals, like C #690

Closed
wants to merge 1 commit into from

Conversation

Rangi42
Copy link
Contributor

@Rangi42 Rangi42 commented Jan 4, 2021

STRCAT does exist already, but there are times when you want to concatenate literal strings, not just any string expressions, and this is a simple and terse way to do that.

Note that the multi-line string in the test case breaks the counted line number for error messages; this is addressed in a bugfix commit in #685.

@ISSOtm
Copy link
Member

ISSOtm commented Jan 4, 2021

What's the benefit compared to STRCAT?

@Rangi42
Copy link
Contributor Author

Rangi42 commented Jan 4, 2021

Honestly not a huge benefit given that STRCAT exists and works with any string expression, not just literals. This might be convenient if someone is generating code, either with macros or an asm preprocessor. It was just simple to implement, and a feature shared with C, so I felt like trying it out.

@Rangi42
Copy link
Contributor Author

Rangi42 commented Jan 4, 2021

Actually, one feature is that it lets you intersperse comments in a long string without needing STRCAT. Just split it into multiple adjacent literals. (Although that's probably not useful in practice either; asm code isn't full of long complicated regex strings that need internally documenting.)

@ISSOtm
Copy link
Member

ISSOtm commented Jan 5, 2021

I'm wary of over-complicating RGBASM, especially due to yyparse being the function the most time is spent in. (Once again, we really need #653...)

Hence, if there's not a strong motivation to add this, I'd prefer erring on the side of caution, at least for now. If a use case emerges later, we can revive this PR.

@ISSOtm ISSOtm closed this Jan 5, 2021
@Rangi42
Copy link
Contributor Author

Rangi42 commented Jan 20, 2021

I'm wary of over-complicating RGBASM, especially due to yyparse being the function the most time is spent in. (Once again, we really need #653...)

Hence, if there's not a strong motivation to add this, I'd prefer erring on the side of caution, at least for now. If a use case emerges later, we can revive this PR.

A mild use case I just came across: vertically aligning text even with charmaps.

A snippet from Pokémon Prism:

	ctxt "Mt. Boulder Range"
	next "<UP>  Dock Underpass"
	next "<UP><LEFT> Rainbow Tower"
	next "<UP><RIGHT> Mt. Boulder"
	next "<DOWN>  Merson City"
	done

The same snippet, with names aligned:

	ctxt "Mt. Boulder Range"
	next "<UP> "       " Dock Underpass"
	next "<UP><LEFT>"  " Rainbow Tower"
	next "<UP><RIGHT>" " Mt. Boulder"
	next "<DOWN> "     " Merson City"
	done

Or:

	ctxt "Mt. Boulder Range"
	next "<UP>"   " "       " Dock Underpass"
	next "<UP>"   "<LEFT>"  " Rainbow Tower"
	next "<UP>"   "<RIGHT>" " Mt. Boulder"
	next "<DOWN>" " "       " Merson City"
	done

@Rangi42
Copy link
Contributor Author

Rangi42 commented Feb 21, 2021

This feature was previously discussed in #237, and left out in part because it didn't work for one-character strings. (This implementation came after the lexer and parser were revised and would not have that issue.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants