protected Token fetchNumber ( ) { Token result = Token . create ( Token . TokenType . INTEGER , input . current ( ) ) ; result . addToContent ( input . consume ( ) ) ; while ( input . current ( ) . isDigit ( ) || input . current ( ) . is ( decimalSeparator ) || ( input . current ( ) . is ( groupingSeparator ) && input . next ( ) . isDigit ( ) ) ) { if ( input . current ( ) . is ( groupingSeparator ) ) { result . addToSource ( input . consume ( ) ) ; } else if ( input . current ( ) . is ( decimalSeparator ) ) { if ( result . is ( Token . TokenType . DECIMAL ) ) { problemCollector . add ( ParseError . error ( input . current ( ) , "Unexpected decimal separators" ) ) ; } else { Token decimalToken = Token . create ( Token . TokenType . DECIMAL , result ) ; decimalToken . setContent ( result . getContents ( ) + effectiveDecimalSeparator ) ; decimalToken . setSource ( result . getSource ( ) ) ; result = decimalToken ; } result . addToSource ( input . consume ( ) ) ; } else { result . addToContent ( input . consume ( ) ) ; } } return result ; }
Reads and returns a number .