Skip to main content



      Home
Home » Modeling » TMF (Xtext) » 'Duplicate Statement' error
'Duplicate Statement' error [message #900125] Sat, 04 August 2012 06:45 Go to next message
Eclipse UserFriend
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 06:57 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: 'Duplicate Statement' error [message #900128 is a reply to message #900127] Sat, 04 August 2012 07:16 Go to previous messageGo to next message
Eclipse UserFriend
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 07:22 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: 'Duplicate Statement' error [message #900131 is a reply to message #900129] Sat, 04 August 2012 08:11 Go to previous message
Eclipse UserFriend
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: Fri Jul 04 21:38:26 EDT 2025

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

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

Back to the top