Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » 'Duplicate Statement' error
'Duplicate Statement' error [message #900125] Sat, 04 August 2012 10:45 Go to next message
Charalampos Alexopoulos is currently offline Charalampos AlexopoulosFriend
Messages: 11
Registered: July 2012
Junior Member
Hi

Based on arithmetics example i am creating the grammar for using variables. A valid example of the language is:

a=32;
b=27;
a=b/3;

This example produce "Duplicate Statement 'a' " error. It is normal while i am trying to declare twice the same variable but this is allowed by the language. So is any way to get rid of this error?

The grammar that i use for this example is:

Code:
(statements+=Statement)*;

Statement:
Variable;

AbstractDefinition:
Variable;

Variable:
name=ID '=' expression=Expression ';';

Expression:
('+' | '-')? Addition;

Addition returns Expression:
Multiplication (({Plus.left=current} '+' | {Minus.left=current} '-') right=Multiplication)*;

Multiplication returns Expression:
PrimaryExpression (({Multi.left=current} '*' | {Div.left=current} '/') right=PrimaryExpression)*;

PrimaryExpression returns Expression:
'(' Expression ')' | {NumberLiteral} value=NUMBER
| {FunctionCall} func=[AbstractDefinition] ('(' args+=Expression (',' args+=Expression)* ')')?;

terminal NUMBER returns ecore::EBigDecimal:
('0'..'9')* ('.' ('0'..'9')+)?;

terminal INT returns ecore::EInt:
'this one has been deactivated';



Thank you in advance
Re: 'Duplicate Statement' error [message #900127 is a reply to message #900125] Sat, 04 August 2012 10:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13493
Registered: July 2009
Senior Member
Hi

if you do not want to have such checks at all remove composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
from your workflow. alternatively customize org.eclipse.xtext.validation.NamesAreUniqueValidationHelper

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: 'Duplicate Statement' error [message #900128 is a reply to message #900127] Sat, 04 August 2012 11:16 Go to previous messageGo to next message
Charalampos Alexopoulos is currently offline Charalampos AlexopoulosFriend
Messages: 11
Registered: July 2012
Junior Member
Hi Christian

Thank you for the answer.
Can you please guide me where to found that class and that option?
I am looking at my generating source and i can't found something similar.

regards
Re: 'Duplicate Statement' error [message #900129 is a reply to message #900128] Sat, 04 August 2012 11:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13493
Registered: July 2009
Senior Member
Hi,

i am not quite sure what your provlem is.
which xtext version do you use?
the composed check is configured in the workflow
and the validation helper is part of the org.eclipse.xtext bundle and can be customized by a binding in the runtime module

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: 'Duplicate Statement' error [message #900131 is a reply to message #900129] Sat, 04 August 2012 12:11 Go to previous message
Charalampos Alexopoulos is currently offline Charalampos AlexopoulosFriend
Messages: 11
Registered: July 2012
Junior Member
Hi

Sorry for my ignorance, it took some time to figure out what you mean. I found the workflow in the .mwe2 and i found the mentioned class in the xtext plugin files.

Thank you for your help
Previous Topic:Computer Algebra Language
Next Topic:Scoping from external sources
Goto Forum:
  


Current Time: Sun Jul 12 01:19:18 GMT 2020

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

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

Back to the top