/** * Parses a string literal. * * @return A string literal. * * @throws SourceCodeException If the next token in the sequence is not a string literal. */ public StringLiteral stringLiteral() throws SourceCodeException { Token valToken = consumeToken(STRING_LITERAL); String valWithQuotes = valToken.image; StringLiteral result = new StringLiteral(valWithQuotes.substring(1, valWithQuotes.length() - 1)); // Set the position that the literal was parsed from. SourceCodePosition position = new SourceCodePositionImpl(valToken.beginLine, valToken.beginColumn, valToken.endLine, valToken.endColumn); result.setSourceCodePosition(position); return result; }
/** * Parses a string literal. * * @return A string literal. * * @throws SourceCodeException If the next token in the sequence is not a string literal. */ public Term stringLiteral() throws SourceCodeException { Token valToken = consumeToken(STRING_LITERAL); String valWithQuotes = valToken.image; StringLiteral result = new StringLiteral(valWithQuotes.substring(1, valWithQuotes.length() - 1)); // Set the position that the literal was parsed from. SourceCodePosition position = new SourceCodePositionImpl(valToken.beginLine, valToken.beginColumn, valToken.endLine, valToken.endColumn); result.setSourceCodePosition(position); return result; }