Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Are parsers generated by ANTLR thread-safe? Can I parse multiple inputs concurrently?

0
Posted

Are parsers generated by ANTLR thread-safe? Can I parse multiple inputs concurrently?

0

Location: http://www.jguru.com/faq/view.jsp?EID=93725 Created: Jul 2, 2000 Modified: 2000-07-02 13:15:41.765 Author: Terence Parr (http://www.jguru.com/guru/viewbio.jsp?EID=1) Question originally posed by Alexis Campailla (http://www.jguru.com/guru/viewbio.jsp?EID=5326 The simple answer is “yes”, however, if you try to parse the same input using the same object with more than one thread the answer is “no”. Fortunately, parsing is, for the most part, an inherently serial problem so you’d never want multiple threads playing with the same input stream object. Typically this question is really asking, “can I make multiple instances of the same parser and parse multiple input streams at the same time?” Emphatically, “yes”. There are not global variables or shared static variables that would force all parsers to operate at different times. You can have multiple parsers and multiple lexers all operating on the same input stream (to handle complicated input streams like java/javadoc comments),

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123