Special-case identifier lexer token
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / repo / ArgumentContextUtils.java
index 3999161280df1bd98746a64f31fedb3bc692ab7c..3c28e1b21fcacb3aa05e66c013f97c5b2125d91a 100644 (file)
@@ -114,6 +114,12 @@ abstract class ArgumentContextUtils {
     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();