Yet another attempt at controlling the parser stack size.
FossilOrigin-Name: cb19986dc6bc483df21e082e54a14cb6d7540b1734259e6d326d676908ac0172
This commit is contained in:
+19
-1
@@ -696,6 +696,7 @@ other than that, the order of directives in Lemon is arbitrary.</p>
|
||||
<li><tt><a href='#pright'>%right</a></tt>
|
||||
<li><tt><a href='#reallc'>%realloc</a></tt>
|
||||
<li><tt><a href='#stack_overflow'>%stack_overflow</a></tt>
|
||||
<li><tt><a href='#reallc'>%stack_resizer</a></tt>
|
||||
<li><tt><a href='#stack_size'>%stack_size</a></tt>
|
||||
<li><tt><a href='#start_symbol'>%start_symbol</a></tt>
|
||||
<li><tt><a href='#syntax_error'>%syntax_error</a></tt>
|
||||
@@ -1203,7 +1204,8 @@ the wildcard token and some other token, the other token is always used.
|
||||
The wildcard token is only matched if there are no alternatives.</p>
|
||||
|
||||
<a id='reallc'></a>
|
||||
<h4>4.4.26 The <tt>%realloc</tt> and <tt>%free</tt> directives</h4>
|
||||
<h4>4.4.26 The <tt>%realloc</tt>, <tt>%free</tt>, and
|
||||
<tt>%stack_resizer</tt> directives</h4>
|
||||
|
||||
<p>The <tt>%realloc</tt> and <tt>%free</tt> directives defines function
|
||||
that allocate and free heap memory. The signatures of these functions
|
||||
@@ -1217,6 +1219,22 @@ parse stack space is exceeded. The initial parser stack size
|
||||
is specified by either <tt>%stack_size</tt> or the
|
||||
-DYYSTACKDEPTH compile-time flag.
|
||||
|
||||
<p>The <tt>%stack_resizer</tt> directive defines a function that computes
|
||||
the new size of the stack whenever it needs resizing. The function takes
|
||||
two arguments: The old stack size, and the %extra_context value. The
|
||||
function returns an integer which is the new stack size. If %stack_resizer
|
||||
is not defined, then the stack size roughly doubles with each new allocation.
|
||||
The %stack_resizer function is entirely optional. The parser works fine
|
||||
without it. The %stack_resizer function merely gives the application more
|
||||
control over the stack size, and offers an opportunity to raise warnings or
|
||||
errors if the parser stack grows too large.
|
||||
|
||||
<p>If the %stack_resizer function returns an integer that is less than or
|
||||
equal to its first parameter, then %stack_overflow is invoked and parsing
|
||||
stops.
|
||||
|
||||
<p>The %stack_resizer function only works if %extra_context is also defined.
|
||||
|
||||
<a id='errors'></a>
|
||||
<h2>5.0 Error Processing</h2>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user