protected Token fetchString ( ) { char separator = input . current ( ) . getValue ( ) ; char escapeChar = stringDelimiters . get ( input . current ( ) . getValue ( ) ) ; Token result = Token . create ( Token . TokenType . STRING , input . current ( ) ) ; result . addToTrigger ( input . consume ( ) ) ; while ( ! input . current ( ) . isNewLine ( ) && ! input . current ( ) . is ( separator ) && ! input . current ( ) . isEndOfInput ( ) ) { if ( escapeChar != ' ' && input . current ( ) . is ( escapeChar ) ) { result . addToSource ( input . consume ( ) ) ; if ( ! handleStringEscape ( separator , escapeChar , result ) ) { problemCollector . add ( ParseError . error ( input . next ( ) , String . format ( "Cannot use '%s' as escaped character" , input . next ( ) . getStringValue ( ) ) ) ) ; } } else { result . addToContent ( input . consume ( ) ) ; } } if ( input . current ( ) . is ( separator ) ) { result . addToSource ( input . consume ( ) ) ; } else { problemCollector . add ( ParseError . error ( input . current ( ) , "Premature end of string constant" ) ) ; } return result ; }
Reads and returns a string constant .