0

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.

Omri. B
  • 375
  • 1
  • 13

1 Answers1

1

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

Yacc equivalent for Java

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