Skip to content


Subversion checkout URL

You can clone with
Download ZIP


reentrant parsing? #119

Niggler opened this Issue · 6 comments

4 participants


bison supports reentrant parser generation via:

 %define api.pure

Is there an analogue in jison?


The parser should be reentrant by default. Are you encountering issues?


If a parser rule calls a function which then tries to parse a separate expression, it doesnt seem to reset the state. I'll put together a small demo


I can't seem to reproduce it with a trivial example and have since reworked the grammar to obviate the problem. If I come across later I'll reopen the issue

@Niggler Niggler closed this

I don't see how it could be re-entrant by looking at a generated source. There is a single object (return new Parser) that has state in it (e.g. this.$) when you call .parse(). If you call parse() again while in the middle of some other parse, it would surely mess it up because there is only one object ever to store the state in. The lexer has same issues.

The constant data and methods are mixed with instance data, both the parser and lexer generated should be able to be instantiated for every parse with unique state, with constant data and methods residing in the prototype so that they only have a single representation in memory.

Here's a simplified example:



I want to implement eval() functionality for my language and therefore would like to add a function to the yy object that recursively invokes the parser. But as @petkaantonov already pointed out, all Parser instances share a single Lexer instance. Hence you always get an Error like this:

Expecting 'FOO', 'BAR', 'EOF', got '1'


Reentrant parsing should be fixed as of 9d3eae1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.