StreamTokenizer: turn parseNumbers off?

J

JVarsoke

Okay, this seems really silly, so I must be missing it. For the
StreamTokenizer class how do I turn off parserNumbers()? The function
does not accept a boolean. Apparently it's a one way switch and the
default is "on".

The only way I can see around it is to call resetSyntax(). But then I
need to re-set all the words, whitespace and ordinary characters.
Does anyone have a list of what the default for these is?

would this do it?

StreamTokenizer st = new StreamTokenizer(stream);
st.resetSyntax();
st.wordChars('\u0000', '\uFFFF');
st.whitespaceChars(' ', ' ');
st.whitespaceChars('\t', '\t');
st.ordinaryChar(delim1);
st.ordinaryChar(delim2); //etc
st.eolIsSignificant(true);

would the above be equal to the mythical:
st = new StreamTokenizer(stream);
st.parseNumbers(false);
st.ordinaryChar(delim1);
st.ordinaryChar(delim2);
st.eolIsSignificant(true);

?

Seems odd you can't just set parseNumbers(false);

thanks for the help,

-j
 
D

Dale King

JVarsoke said:
Okay, this seems really silly, so I must be missing it. For the
StreamTokenizer class how do I turn off parserNumbers()? The function
does not accept a boolean. Apparently it's a one way switch and the
default is "on".

The only way I can see around it is to call resetSyntax(). But then I
need to re-set all the words, whitespace and ordinary characters.
Does anyone have a list of what the default for these is?

From the source code here is the default configuration:

wordChars('a', 'z');
wordChars('A', 'Z');
wordChars(128 + 32, 255);
whitespaceChars(0, ' ');
commentChar('/');
quoteChar('"');
quoteChar('\'');
parseNumbers();
Seems odd you can't just set parseNumbers(false);

All you have to change are the numbers 0 through 9, '-' and '.'. Simply set
these two ordinary characters and then set them to what you want them to be.
parseNumbers sets the "numeric" attribute for these characters. Setting them
as ordinary characters will remove this attribute.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top