| Duplicate Element Problem [message #766766] |
Fri, 16 December 2011 06:38  |
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06558 seconds