ID and Fully Qualified name problem [message #1836042] |
Fri, 18 December 2020 17:43  |
|
Dear All
A DSL has a construction like
Library org.houseofbadger.lib.common.lib P1="PPP" WITH NAME bla-bla
I created the following rule in grammar
library_import_definition:
"Library" QualifiedName parameter_expression* alias_name*;
QualifiedName:
(ID ('.' ID)*);
But I observer the following error
mismatched input 'mismatched input 'lib.lib1.lib2' expecting RULE_ID' expecting RULE_ID
In case I put the following code
Library lib.lib1.lib2
Library lib.lib1.lib3
Library lib.lib1.lib4
Could you please help me to resolve this issue?
|
|
|
|
Re: ID and Fully Qualified name problem [message #1836103 is a reply to message #1836057] |
Mon, 21 December 2020 09:25   |
|
Hello
Seems to me I found the root cause of this issue. You are right the reason is another incorrect definition in my grammar
I need to defined element of path to file in my grammar. Because import of the library can reference directly to the file
I used the following :
terminal PATH_ELEMENT: '^'? ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
ResourcePath:
(('./')|( '../') *)(PATH_ELEMENT'/' | PATH_ELEMENT)* FileName
;
FileName:
PATH_ELEMENT'.'PATH_ELEMENT
;
When I try to generate Xtext artifacts i observed the following error message
error(208): ../org.houseofbadger.rfl/src-gen/org/houseofbadger/parser/antlr/internal/InternalRFL.g:888:1: The following token definitions can never be matched because prior tokens match the same input: RULE_ID,RULE_INT
error(208): ../org.houseofbadger.rfl.ide/src-gen/org/houseofbadger/ide/contentassist/antlr/internal/InternalRFL.g:2032:1: The following token definitions can never be matched because prior tokens match the same input: RULE_ID,RULE_INT
To be honest it is clear because there is a conflict between number definition (RULE_INT) and my PATH_ELEMENT definition
So my question is how to correctly to define element of path
I need to have the describing something like :
Library ../../com/resources/storage.txt
Library ./lib-ext.lib
Thank you in advance
|
|
|
|
Re: ID and Fully Qualified name problem [message #1836211 is a reply to message #1836104] |
Thu, 24 December 2020 11:01  |
|
I used the following way may be is not optimal but work
ResourcePath:
(('./')|( '../') *)(PATH_ELEMENT)* FileName
;
PATH_ELEMENT returns ecore::EString :
((INT) (ID('/')*)) | (ID('/')*) ;
FileName:
(((INT)(ID)) | (ID) | (INT))'.'(((INT)(ID))|(ID) | (INT))
;
|
|
|
Powered by
FUDForum. Page generated in 0.02735 seconds