lex - Is there a way to get current number of tokens parsed in stack in yacc -


I'm running in parser stack overflow in yacc. I'm not sure how the current parser stack size determines how to present the current parser stack size is one way, so that the number of tokens should reach the depth of the maximum stack, an error can be reported? Is there a variable in yacc that holds this information?

There is no standard way of obtaining a parser stack size, although it is clearly available internally Because the parser is capable of producing a stack overflow error (without exception, or otherwise implementing undefined behavior). You do not need to check it yourself; You just have to print the error message provided for yyerror ; If the stack overflows, the error message will mention that fact.

There are a few ways that you can end up with the version of UCC which can not resize the size of the stack. One, public domain Berkeley Yak, often called byacc , is used; The version I'm kicking (from 1993) sets the default stack size to 500.

Another possibility is that using GNU Bison , compiling results with the C ++ compiler; By default, this will non-transfer the stack because Bison does not know whether the semantic value union is emulative or not (this restriction can not be banned in new versions of Bison). From, the initial bison stack size is 200.

A common way to blow stacks is to use the correct recycling for long lists. A particularly bad one is on the following types:

  Program: / * blank * / | Statement program;   

which would cause the parser stack overflow if the "program" is too long. This is usually enough to change only the left recursive:

  Program: / * blank * / | Program statement;    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -