Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Help resolve this error(Help resolve this error)
Help resolve this error [message #1408038] Thu, 14 August 2014 05:01 Go to next message
Aruna Kalagnanam is currently offline Aruna KalagnanamFriend
Messages: 3
Registered: August 2014
Junior Member
Hello

I am new to XText and I have the following grammar file that does cross referencing to Jvm types

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

import JavaVMTypes link as jvmTypes

generate myDsl MyDslLink

Domainmodel:
(elements += AbstractElement)*
;

AbstractElement:
PackageDeclaration | Import | Node
;

PackageDeclaration:
'package' name = QualifiedName '{'
(elements += AbstractElement)*
'}'
;

QualifiedName:
ID ('.'ID)*
;

Import:
'import' importedNamespace = QualifiedNameWithWildcard
;

QualifiedNameWithWildcard:
QualifiedName ('.*')?
;

Node:
('abstract' | 'root')? 'node' name = ID (':' supertype=[Node])? '{'
(children += Child | attributes += Attribute)*
'}'
;

Child:
'child' (type = Type) name = ID
;

Attribute:
'attribute' (type = Type) name = ID
;

Type:
Node | DataType
;


DataType:
'datatype' name = ID
'mapped-to' javaType = [jvmTypes::JvmType | QualifiedName]
;

My aim is to use the generated DSL to create something like

datatype String mapped-to java.lang.String -> error "missing EOF at datatype"

package com.mycompany.common {
abstract node Something {
attribute AnotherThing thing
}

node AnotherThing {
attribute String key
attribute String value
}
}

What is wrong with my grammar file, why am I getting the missing EOF at datatype error. Please help.
Re: Help resolve this error [message #1408197 is a reply to message #1408038] Thu, 14 August 2014 13:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i cannot see where datatype can be a root element:

Domainmodel:
(elements += AbstractElement)*
;

a datatype is not an AbstractElement


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Help resolve this error [message #1786586 is a reply to message #1408197] Mon, 07 May 2018 22:17 Go to previous messageGo to next message
Maude Sabourin is currently offline Maude SabourinFriend
Messages: 11
Registered: May 2018
Junior Member
I am reviving this post as I have this exact same problem. Please note that this example actually comes from the official XText Tutorial

In the recent version (much clearer), datatype String can be rooted because
AbstractElement --> Type --> DataType

Domainmodel:
    (elements+=AbstractElement)*;
 
AbstractElement:
    PackageDeclaration | Type | Import;
 
Type:
    DataType | Entity;
  
DataType:
    'datatype' name=ID;
 


Yet, I still have the exact same error when attempting to copy the code on the tutorial
// datatypes.dmodel
 
datatype String
// commons.dmodel

package my.company.common {
  
    entity HasAuthor {
        author: String
    }
}


ERROR : missing EOF at 'package'

If it's of any use, here is the rest of the useful part of the definition

PackageDeclaration:
    'package' name=QualifiedName '{'
        (elements+=AbstractElement)*
    '}';
 
QualifiedName:
    ID ('.' ID)*;
Re: Help resolve this error [message #1786646 is a reply to message #1786586] Tue, 08 May 2018 21:53 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi i can still not reproduce this. are you use you regenerated the grammar

here is the one i used


Domainmodel:
    (elements+=AbstractElement)*;
 
PackageDeclaration:
    'package' name=QualifiedName '{'
        (elements+=AbstractElement)*
    '}';
 
AbstractElement:
    PackageDeclaration | Type | Import;
 
QualifiedName:
    ID ('.' ID)*;
 
Import:
    'import' importedNamespace=QualifiedNameWithWildcard;
  
QualifiedNameWithWildcard:
    QualifiedName '.*'?;
  
Type:
    DataType | Entity;
  
DataType:
    'datatype' name=ID;
 
Entity:
    'entity' name=ID ('extends' superType=[Entity|QualifiedName])? '{'
        (features+=Feature)*
    '}';
 
Feature:
    (many?='many')? name=ID ':' type=[Type|QualifiedName];



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:problem launching eclipse runtime and generating code
Next Topic:Xbase DSL library without source?
Goto Forum:
  


Current Time: Fri Apr 19 04:28:56 GMT 2024

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

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

Back to the top