A suggestion:
1. Extend the class
2. override parseNumbers() to keep track of the call, and then call
super.parseNumbers
3. override nextToken() such that
call super.nextToken()
if parseNumbers was called and if you have sval then
check if it is actually exponential, and change nval and sval if
needed.
--- James Hurt <jhurt@xxxxxxxxxxxxxxxx> wrote:
> Damnation. Why don't I believe what I read about Java classes?
>
> The description for StreamTokenizer includes:
>
> <quote>
> parseNumbers
>
> public void parseNumbers()
>
> Specifies that numbers should be parsed by this tokenizer. The
> syntax table of this tokenizer is modified so that each of the
> twelve
> characters:
>
> 0 1 2 3 4 5 6 7 8 9 . -
>
>
> has the "numeric" attribute.
>
> When the parser encounters a word token that has the format of
> a
> double precision floating-point number, it treats the token as a
> number
> rather than a word, by setting the the ttype field to the value
> TT_NUMBER and putting the numeric value of the token into the nval
> field.
> </quote>
>
> Translation: Numbers in exponential format (e.g. 2.9e-17) are not
> correctly parsed. The exponential component is missed.
>
> What is the easiest way to modify StreamTokenizer so it will
> recognize
> numbers in scientific notation?
> --
> James Hurt
> Vice President Research & Development
> Internet & Computer Institute
> Phone: 513-271-4249
>
>
>
> ---------
> You may unsubscribe from this mailing list
> by sending a blank email addressed to:
> users-unsubscribe@xxxxxxxxxx
>
> --
> Find additional help by sending a blank email
> addressed to:
> users-help@xxxxxxxxxx
>
>
__________________________________
Do you Yahoo!?
The all-new My Yahoo! - Get yours free!
http://my.yahoo.com
|