-
If I need to support multiple instances of a parser in the same page I am wondering the best way to proceed. In particular the CstVisitor API implies a single global parser instance. In order to define the visitor subclass I must have a parser instance:
But the parser instance also holds the parse state, so I can't have two parsers active at the same time within the same Javascript context (a web page in my case). It seems that a closure may work, but I really want to be able to import the visitor from a separate file than the parser itself in order to organize what will be extensive code. Am I missing a better approach? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @k1w1, does some of your parse state persist over multiple parses? If not, you should be fine to just reuse the same parser for multiple parse calls. Since Chevrotain doesn't support async parsing, you cannot accidentally start the parser while the parsing is still in process. Consequently, two simultaneous parsing processes in the same JS context are impossible. |
Beta Was this translation helpful? Give feedback.
Hey @k1w1,
does some of your parse state persist over multiple parses? If not, you should be fine to just reuse the same parser for multiple parse calls. Since Chevrotain doesn't support async parsing, you cannot accidentally start the parser while the parsing is still in process. Consequently, two simultaneous parsing processes in the same JS context are impossible.