// the flaky definitions of RFC6020, which allow for insane quoting as well as
// exclusion of comments. We also need to allow for stitching back tokens like
// PLUS/COLON, which may end up being valid identifiers. Finally we need to allow
-// IDENTIFIER to be concatenated back to a string
-argument : unquotedString | quotedString (SEP* PLUS SEP* quotedString)*;
+// IDENTIFIER to be concatenated back to a string -- but it is common enough
+// so we want to specialize it.
+argument : IDENTIFIER | unquotedString | quotedString (SEP* PLUS SEP* quotedString)*;
quotedString :
DQUOT_START DQUOT_STRING? DQUOT_END
final @NonNull String stringFromStringContext(final ArgumentContext context, final StatementSourceReference ref) {
// Get first child, which we fully expect to exist and be a lexer token
final ParseTree firstChild = context.getChild(0);
+ if (firstChild instanceof TerminalNode) {
+ // Simplest of cases -- it is a simple IDENTIFIER, hence we do not need to validate anything else and can
+ // just grab the string and run with it.
+ return firstChild.getText();
+ }
+
if (firstChild instanceof UnquotedStringContext) {
// Simple case, just grab the text, as ANTLR has done all the heavy lifting
final String str = firstChild.getText();