Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362685 - UI Parser Hangs up
Summary: UI Parser Hangs up
Status: NEW
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-02 11:00 EDT by Christian Dietrich CLA
Modified: 2012-01-30 05:25 EST (History)
3 users (show)

See Also:
sebastian.zarnekow: juno+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Dietrich CLA 2011-11-02 11:00:32 EDT
Build Identifier: 2.0.0 2.1.0

Having following (largely simplified) grammar

Model:
    elements+=Element+
    ;
    
Element:
    Entity | Test
;

Entity:
    "entity" name=ID
;


Test:
    "test" name=ID "("
    ans=NavStatement
    ")"  
;

NavStatement returns Statement
    :   '(' NavStatement ')'
    |   {IFElseStatement} 'if' cond=Expr 'then' if=NavStatement (=> 'else' else=NavStatement)?
    |   {URLNavigation} 'url' url=Expr
    |   {BackStatement} 'back'
    |   {RefStatement} '#' uebergang=[Entity|ID]
    ;
    
    enum Expr:
        YES | NO        
    ;


and following dummy example model:

entity Uebergang_1

test x (
							if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
							else if YES then #Uebergang_1
						)
							
							

the editor hangs up on invocation of content assist at the end of the file

Reproducible: Always
Comment 1 Benjamin Schwertfeger CLA 2011-11-30 18:25:31 EST
The handling of syntactic predicates leads to duplicate parsing. In the generated Parser is a method like this:
rule__NavStatement__Group_1__5__Impl()
...
if ( (LA5_0==19) ) {
                if ( (synpred6_InternalMyDsl()) ) {
                    alt5=1;
                }
            }
            switch (alt5) {
                case 1 : ...
                    rule__NavStatement__Group_1_5__0();

Where synpred6_InternalMyDsl also calls the rule rule__NavStatement__Group_1_5__0. Because the result is not cached you get a O^2 runtime for each recursive/hierarchical usage of syntactic predicates.

Workaround:
If possible remove the syntactic predicate and ignore the warning while generating.
Comment 2 Sebastian Zarnekow CLA 2011-11-30 18:32:14 EST
Please try to enable memoization for the ui parser.
Comment 3 Benjamin Schwertfeger CLA 2011-11-30 18:43:50 EST
(In reply to comment #2)
> Please try to enable memoization for the ui parser.

For the given example it works like a charm. Thanks for the hint.