Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » References doesn't work in my grammar(I try to reference a "name" in my grammar, but it doesn't work)
References doesn't work in my grammar [message #1791258] Wed, 27 June 2018 02:58 Go to next message
Andres Espinoza is currently offline Andres EspinozaFriend
Messages: 1
Registered: June 2018
Junior Member
I'm new to XText, and I'm doing a project for the university, so I have this grammar that tries to look like function definitions of the programming language Racket:

Program:
func+=Function+
;

Function:
'(' def=Definition ')'
;

Definition:
'define' funcName=FunctionName body=(SimpleBody | Body)
;

FunctionName:
(ComplexFuncName | SimpleName)
;

ComplexFuncName:
'(' name=ID (parameters+=SimpleName)+ ')'
;

SimpleName:
name=ID
;

SimpleBody:
eval=Exp
;

Body:
'(' eval=Eval ')'
;

Eval:
op=Operator (arg+=(Exp | Body))+
;

Operator:
OperadorAritmetico
;

OperadorAritmetico:
name=('+' | '-' | '*' | '/')
;

Exp:
AtomVal | AtomInt
;

AtomVal:
ref=[SimpleName]
;

AtomInt:
val=INT
;
When I run the eclise runtime application, I create a file with the next code:
(define a 10)
(define (f1 x) (+ a x))

When I reference the name of "SimpleName" it works with the definition of "a", but when I try to reference the parameter "x", that is also a "SimpleName" it doesn't work, why is that happening? help please.
Re: References doesn't work in my grammar [message #1791566 is a reply to message #1791258] Mon, 02 July 2018 14:52 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
what happens if you change the grammar to

AtomVal:
ref=[SimpleName|FQN]
;

with

FQN: ID ("." ID)*;

????

=> likely you need to adopt nameproviders


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Is Maven supposed to work properly?
Next Topic:Xtext: Cannot resolve reference
Goto Forum:
  


Current Time: Thu Apr 25 15:30:21 GMT 2024

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

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

Back to the top