This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 107217 - Provide better grammar recognition
Summary: Provide better grammar recognition
Status: NEW
Alias: None
Product: obsolete
Classification: Unclassified
Component: languages (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: issues@obsolete
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-19 14:32 UTC by Denis Anisimov
Modified: 2007-07-09 15:58 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Denis Anisimov 2007-06-19 14:32:08 UTC
I use languages engine for getting AST tree.

I have declaration :
EchoStatement = ("echo" | "print") EchoArguments ";";
EchoArguments = [ Expression ( "," Expression )* ] | ( "(" [ Expression ( "," Expression )* ] ")" )  ;

Expression node has usual "expression" structure ( its definition too long , I think there is no need in this ).

The problem is in possibility for valid expression value , f.e.:
expression could be "( 1 + 2 )".

So it seems for string 'echo ( 1+2 );'
engine cannot determine in this case expression "1+2" as most appropriate result 
because EchoArguments could also have "(" , ")".  
( So engine has two choices : incorrect EchoArguments "(" , expression="1" , "+",
expression="2", ")" and correct EchoArguments = expression = "( 1+2 )" ).

As result I get on stderr ( or stdout , I'm not sure exactly ) :
Too many choices! EchoArguments : <php_operator,'('> <php_whitespace,' '>:<php_operator,'('> <php_whitespace,' '> <php_n
umber,'1'> <php_operator,'+'> <php_number,'2'> <php_whitespace,' '> <php_operator,')'> <php_separator,';'> <php_whitespa
ce,'\n    '> .

Engine should prefer and choose CORRECT constructions against many cases with incorrect result constructions.
Comment 1 Jan Jancura 2007-07-09 15:58:44 UTC
As far as I understand it, your grammar is LR or LALR, but current version of Schliemann engine supports LL grammars
only. Its sometimes hard to revrite LR grammar to LL one, and I have no idea how to do it in your case.