I'm trying to write a recursive descent parser. I need a method that converts the string to a stream, so I can use a next
method. Everywhere I read, it says that StreamTokenizer
is outdated and unnecessary, but I can't find any alternatives.
.split()
can be used but it doesn't quite give me the functionality I'm interested in - looping over the array and entering recursion will be complicated, I'll have to split and trim the array constantly. So my question is, what is the recommended alternative?
Thanks
currently, my solution is:
LinkedList<String> queue = new LinkedList<>(Arrays.asList(rule.split(" "))); //splits to spaces and gives me q
where rule
is a string.
Asked
Active
Viewed 153 times
0

Omri. B
- 375
- 1
- 13
-
Where exactly do you see that StreamTokenizer is deprecated? – rici Mar 19 '21 at 19:42
1 Answers
1
If your grammar is not really trivial, you ought to get real tools for this job like flex and yacc:

Konstantin Pribluda
- 12,329
- 1
- 30
- 35