Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ID and Fully Qualified name problem(How correct created FQN)
ID and Fully Qualified name problem [message #1836042] Fri, 18 December 2020 17:43 Go to next message
Alex Gor is currently offline Alex GorFriend
Messages: 157
Registered: November 2014
Location: Russia
Senior Member
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 #1836057 is a reply to message #1836042] Sat, 19 December 2020 06:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13976
Registered: July 2009
Senior Member
Hi,

the information you provided is not complete enough to answer this question.
i assume there is something else in your grammar that causes the problem.
i propose you should debug the lexer (next token) to see that is actually lexed.

please provide a complete BUT minimal hello world grammar and unit test that show the problem


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: ID and Fully Qualified name problem [message #1836103 is a reply to message #1836057] Mon, 21 December 2020 09:25 Go to previous messageGo to next message
Alex Gor is currently offline Alex GorFriend
Messages: 157
Registered: November 2014
Location: Russia
Senior Member
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 #1836104 is a reply to message #1836103] Mon, 21 December 2020 10:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13976
Registered: July 2009
Senior Member
you should have a look at the concept of Data Type rules and/or IValueConverters

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: ID and Fully Qualified name problem [message #1836211 is a reply to message #1836104] Thu, 24 December 2020 11:01 Go to previous message
Alex Gor is currently offline Alex GorFriend
Messages: 157
Registered: November 2014
Location: Russia
Senior Member
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))
;
Previous Topic:What'S EStructucalFeature and how to convert enum grammar defintions to it?
Next Topic:Keyword with whitespace
Goto Forum:
  


Current Time: Mon Jun 14 17:42:54 GMT 2021

Powered by FUDForum. Page generated in 0.02273 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top