Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Expression supertype doesn't work properly(How can it be fixed?)
Expression supertype doesn't work properly [message #1782369] Thu, 22 February 2018 12:47 Go to next message
Sebastian Koch is currently offline Sebastian KochFriend
Messages: 2
Registered: February 2018
Junior Member
(Thread can be closed.)

Hello there,

EDIT: Turns out I was a bit hasty. So the example from the website works fine. I just created a new project and filled it with

grammar org.xtext.example.mydsl1.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl1/MyDsl"
      
    Primary returns Expression:
      ID;

I get no errors with that. However, when I used "return Expression" in the grammar I already started:

grammar org.abos.mizar.mse.Common with org.eclipse.xtext.common.Terminals

import "http://www.eclipse.org/emf/2002/Ecore" as ecore

Theorem:
	'theorem' CompactStatement
;

CompactStatement:
	Proposition Justification ';'
;

Proposition:
	Sentence // TODO change
	// (LabelId ':')? Sentence
;

Sentence:
	FormulaExpr
;

Justification:
	SimpleJustification | Proof
;

SimpleJustification:
	SfwJustification
;

SfwJustification: // straightforward justification
	'by' References
;

Proof:
	'proof' Reasoning 'end'
;

//------------------------
// References
//------------------------

ArticleName:
	ID
;

LabelId:
	ID
;

References:
	Reference (',' Reference)*
;

Reference:
	LocalReference | LibraryReference
;

LocalReference:
	LabelId
;

LibraryReference:
	ArticleName ':' (INT | 'def' INT)
;

//------------------------
// Reasoning
//------------------------

Reasoning:
	ID // TODO change
;

//------------------------
// Formulas
//------------------------

FormulaExpr returns Expression:
	ID // TODO change
;

then the IDE marks "Expression" as erroneous with the hint "Cannot find meta model for type 'Expression'".

Why is that so and how can it be fixed?

...

Oh, it is so because I'm missing a "generate". Okay then. Question answered.

[Updated on: Fri, 23 February 2018 05:24]

Report message to a moderator

Re: Expression example from website doesn't work [message #1782406 is a reply to message #1782369] Thu, 22 February 2018 17:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12230
Registered: July 2009
Senior Member
hi,

i dont get your point. can you please explain?

returns Expression just defines expression as supertype


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Expression example from website doesn't work [message #1782421 is a reply to message #1782406] Fri, 23 February 2018 05:27 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 612
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Please have a look at the Simple Arithmetics example. You can install that into your Eclipse workspace with File/New/Example / Xtext Examples / Xtext Simple Arithmetics Example.
There you have a small working example for a language that uses expressions. The docs you are referring to explain the principle, they are not supposed to show a complete language.
Also Lorenzo Bettini's book on Xtext is a valuable source for this.
Re: Expression example from website doesn't work [message #1782422 is a reply to message #1782406] Fri, 23 February 2018 05:27 Go to previous messageGo to next message
Sebastian Koch is currently offline Sebastian KochFriend
Messages: 2
Registered: February 2018
Junior Member
Hm. I can see what you mean. I didn't explicitly tried the example but put what I needed into my existing grammar. I didn't use an "generate" because I was writing an intermediate grammar and couldn't see that. I apologize for my shameful first post and promise to think trice next time before posting a question here.

However, I edited my opening post so one can understand where the problem came from.
Re: Expression example from website doesn't work [message #1782424 is a reply to message #1782422] Fri, 23 February 2018 06:41 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12230
Registered: July 2009
Senior Member
yes your grammar does not use any assignments. this makes the supertype hierarchy and object/datatytpe distinction broken

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic: implementing QualifiedNameProvider
Next Topic:Unable to generate parser for a big grammar
Goto Forum:
  


Current Time: Thu Sep 20 12:42:07 GMT 2018

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

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

Back to the top