1

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.

1
  • Where exactly do you see that StreamTokenizer is deprecated? Commented Mar 19, 2021 at 19:42

1 Answer 1

2

If your grammar is not really trivial, you ought to get real tools for this job like flex and yacc:

Yacc equivalent for Java

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.