Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Using the Xtext.xtext grammar in another DSL gives "Couldn't resolve reference to EClassifier&q
Using the Xtext.xtext grammar in another DSL gives "Couldn't resolve reference to EClassifier&q [message #1841797] Sun, 30 May 2021 09:39 Go to next message
M D is currently offline M DFriend
Messages: 33
Registered: January 2021
Member
I'm developing a DSL that uses Xtext's own grammar. Thus, it is possible to define Xtext grammar rules in the DSL to use. Xtext grammar rules are defined in the rule "Rule", which is defined as follows.

Rule:
'{'
'"name"' ':' '{'
'"column"' ':' nameColumn = INT ','
'"row"' ':' nameRow = INT ','
'"value"' ':' name = STRING_WITH_TOKENS
'}' ','
'"rule"' ':' '{'
'"column"' ':' ruleColumn = INT ','
'"row"' ':' ruleRow = INT ','
'"value"' ':' '"' rule = AbstractRule '"'
'}'
'}'
;

AbstractRule: ParserRule | TerminalRule | EnumRule;

Thus, rule = AbstractRule is what starts the use of the Xtext grammar. This means the following is not included from the original Xtext grammar:

Grammar:
'grammar' name=GrammarID ('with' usedGrammars+=[Grammar|GrammarID] (',' usedGrammars+=[Grammar|GrammarID])*)?
(definesHiddenTokens?='hidden' '(' (hiddenTokens+=[AbstractRule|RuleID] (',' hiddenTokens+=[AbstractRule|RuleID])*)? ')')?
metamodelDeclarations+=AbstractMetamodelDeclaration*
(rules+=AbstractRule)+
;

GrammarID returns ecore::EString:
ValidID ('.' ValidID)*;

Only smalls things have been changed in the original Xtext grammar such as the RuleNameAndParams using name to cross-reference to a Rule instead of a cross-refrence to a ValidID.

fragment RuleNameAndParams returns ParserRule:
name=[Rule] ('<' (parameters+=Parameter (',' parameters+=Parameter)*)? '>')?
;

import "http://www.eclipse.org/2008/Xtext" is not included in the beginning as it gives error. And terminals is not imported, but defined directly in the grammar.

Right now it works defining basic Xtext grammar rules. But creating a rule such as "Exp returns Expression: Factor (('+' {Plus.left=current} | '-' {Minus.left=current}) right=Factor)*;" gives an "Couldn't resolve reference to EClassifier 'Expression'".

I do not know if any of this can cause the error. I'm a bit lost about what causes the error.

[Updated on: Sun, 30 May 2021 09:45]

Report message to a moderator

Re: Using the Xtext.xtext grammar in another DSL gives "Couldn't resolve reference to EClassifi [message #1841798 is a reply to message #1841797] Sun, 30 May 2021 09:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i guess you need to look on how Xtext does ecore inference and have to adopt it to your usecase

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Using the Xtext.xtext grammar in another DSL gives "Couldn't resolve reference to EClassifi [message #1841800 is a reply to message #1841798] Sun, 30 May 2021 17:25 Go to previous message
M D is currently offline M DFriend
Messages: 33
Registered: January 2021
Member
Okay, thanks!
Previous Topic:Cross-referencing two different rules?
Next Topic:Lexer mixes some inputs even though it is set to non-greedy?
Goto Forum:
  


Current Time: Thu Apr 18 10:35:45 GMT 2024

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

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

Back to the top