Search the web
Sign In
New User? Sign Up
GOLDParser · GOLD Parsing System
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Stack Overflow Problem, deep tree   Message List  
Reply | Forward Message #3429 of 3473 |
we have a grammar as follow:

<Main Program> ::= 'begin:' <Statements>

<Statements> ::= <Statement> <Statements>
| <Statement>

<Statement> ::= <Function Calls> ';'
| <Assignments> ';'
| <IfThen>
| <SelectCase>
| <For>
| <While>
| ';'

When user want to run the script, we create the REDUCTION object first, then
using this final object, we iterate items in it. The code is:

Private Function ExecuteScript(reduksi as Reduction) as Object
For i = 0 To reduksi.TokenCount - 1
RulePerformed = False
Select Case reduksi.Tokens(i).Kind
Case SymbolTypeNonterminal
Select Case reduksi.ParentRule.TableIndex
Case
Rule_Otherfunction_Calculateovertimesalary_Lparan_Comma_Comma_Rparan
tempval_v(1) =
ExecuteScript(reduksi.Tokens(2).Data) ' <=== This is the PROBLEM,
recursive function !
.
.
.
case ...
.
.
.
End Select
End Select
Next
End Function

The problem is, as the script grow larger and larger, the parse tree will be
deeper. The deeper the parse tree,
the deeper our recursive function will be, and STACK OVERFLOW occured.

Example: hundred of simple statement like this:
a := 1:b := 2;c := 3....
will cause the parse tree deeper and deeper.

Now, my question, is there any way to write a grammar to overcome this
problem?
Parse tree for statement "a:=1" should be in the same level as "b:=2" etc...
Currently, statement "b:=2" is put as a child node under "a:=1" (recall our
grammar design),
so when the script grow larger, the tree become so deep to be handled.

Please advise.

Thank You.


[Non-text portions of this message have been removed]




Sat Apr 4, 2009 4:21 am

konglomerat_...
Offline Offline
Send Email Send Email

Forward
Message #3429 of 3473 |
Expand Messages Author Sort by Date

we have a grammar as follow: <Main Program> ::= 'begin:' <Statements> <Statements> ::= <Statement> <Statements> ... <Statement> ::= <Function Calls> ';' ...
Others
konglomerat_...
Offline Send Email
Apr 5, 2009
9:24 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help