Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Duplicate Element Problem
Duplicate Element Problem [message #766766] Fri, 16 December 2011 06:38 Go to next message
Jose Antonio is currently offline Jose Antonio
Messages: 2
Registered: December 2011
Junior Member
Hello!

I am kind of new in the new version of Xtext/Xbase.
I have to create a grammar parser for sothing like this:

grammar com.personal.config.ExpressionEval hidden(WS, SL_COMMENT)

Cfg :
    {Cfg}
    modules += Module*
;

Element:
    Module | Assign 
;

Module :
    name = Name '{' elems+=Element* '}' 
;

Assign : 
    name=Name assigned=AssignValue  
;

AssignValue :
    Value |
    INT |
    STRING |
    ListAssignValue
;

ListAssignValue :
    '(' Value (',' Value )* ')'
;

Name:
    '#'Value |
    Value
;

terminal Value : ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9')*;
terminal SL_COMMENT     : '!' !('\n'|'\r')* ('\r'? '\n')?;
terminal WS         : (' '|'\t'|'\r'|'\n')+;


that grammar is supossed to be capable of parse the next text

CONFIG
{
    newModule
    {
        name           NewInSite
        read           FALSE
    }
    mapping {
    	name maping1
    }
    
    mapping {
    	name maping2
    }
}


The problem is that it gives the error 'Duplicated Element'. I understand that it comes because it uses like ID the attribute name. But in the cfg files can appear Modules with the name duplicated. Also there it is not possible to know before parser what possible modules are needed.

Somebody can help with a workaround for the ID problem?
Is there a way to generate a hidden sequential ID?
Or, is there a way to generate a ID from the hash of the different attributes?
I am stuck so I am open to any suggestion.

Any help concerning this issue is highly appreciated. Thanks!
Jose
Re: Duplicate Element Problem [message #766770 is a reply to message #766766] Fri, 16 December 2011 06:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4399
Registered: July 2009
Senior Member
Hi, if you Don not care about uniqueness simply deactivate the
validator in the workflow. If you want to customize it have a look at
namesareuniquevalidationhelper regards Christian
Re: Duplicate Element Problem [message #767967 is a reply to message #766770] Mon, 19 December 2011 04:49 Go to previous message
Jose Antonio is currently offline Jose Antonio
Messages: 2
Registered: December 2011
Junior Member
Thank you Christian.
Deactivating the validator it just worked like a charm.
Regards.
Jose
Previous Topic:Unittest and importURI
Next Topic:Distinguish imported namespaces by file type
Goto Forum:
  


Current Time: Mon May 20 13:18:14 EDT 2013

Powered by FUDForum. Page generated in 0.06558 seconds