Posted 14 years ago
by David
Hi, I have a question about a certain design feature of my semantic parsing. Here's an example...
I have non-terminals, StatementList, Statement, CaseStatement and SwitchStatement.
A StatementList holds Statements and a CaseStatement can appear inside the body of a SwitchStatement. CaseStatement and SwitchStatement both inherit Statement, so can be stored in the StatementList.
But it is syntactically wrong for a CaseStatement to appear anywhere except inside a SwitchStatement body.
So is it better to not have StatementList parse statements of type CaseStatement or to have it parse them, and have my syntax error module post an error?
On the otherhand if I do not allow the StatementList non-terminal to read CaseStatement; I know I can use the failure code tag to throw up an error stating that it shouldn't be there, but how can I get the TextRange of it?
Hope you understood my question, thank you.
[Modified at 01/09/2011 08:46 PM]
I have non-terminals, StatementList, Statement, CaseStatement and SwitchStatement.
A StatementList holds Statements and a CaseStatement can appear inside the body of a SwitchStatement. CaseStatement and SwitchStatement both inherit Statement, so can be stored in the StatementList.
But it is syntactically wrong for a CaseStatement to appear anywhere except inside a SwitchStatement body.
So is it better to not have StatementList parse statements of type CaseStatement or to have it parse them, and have my syntax error module post an error?
On the otherhand if I do not allow the StatementList non-terminal to read CaseStatement; I know I can use the failure code tag to throw up an error stating that it shouldn't be there, but how can I get the TextRange of it?
Hope you understood my question, thank you.
[Modified at 01/09/2011 08:46 PM]