Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Trying to create boolean logic
Trying to create boolean logic [message #1871589] Mon, 30 September 2024 18:45 Go to next message
Thomas Chiang is currently offline Thomas ChiangFriend
Messages: 106
Registered: March 2020
Senior Member
Hello all,

I am relatively new to Xtext and I'm trying to create a boolean algebra to implement an if-else language. I copied the method for creating an AST from here: https://eclipse.dev/Xtext/documentation/307_special_languages.html#expressions

I somewhat adapted it for the my boolean algebra but now I'm getting the following error: error(211): ../org.xtext.mcmaster.requirements.gherkin.rgh/src-gen/org/xtext/mcmaster/requirements/gherkin/rgh/parser/antlr/internal/InternalRgh.g:387:2: [fatal] rule ruleMultiFeature has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.

Here is my text code:
Context:
	{Context} 'If' '(' check=FeatureExpression ')' 'exists' '{'
		steps+=Steps+
	'}'
	(-> 'else' '{' elseSteps+=Steps+ '}')?
;

FeatureExpression:
	MultiFeature
;

SingleFeature:
	'Feature' name=Description
;

MultiFeature:
	FeatureAndFeature | FeatureOrFeature
;

FeatureOrFeature returns MultiFeature:
	FeatureAndFeature ({FeatureOrFeature.left=current} 'OR' right=FeatureAndFeature)*
;

FeatureAndFeature returns MultiFeature:
	Primary ({FeatureAndFeature.left=current} 'AND' right=Primary)*
;

Primary returns MultiFeature:
	SingleFeature | '(' FeatureOrFeature ')'
;


I'm not sure where I'm going wrong and any help would be appreciated.
Re: Trying to create boolean logic [message #1871592 is a reply to message #1871589] Tue, 01 October 2024 04:57 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14722
Registered: July 2009
Senior Member

without trying
i dont understand the


MultiFeature:
FeatureAndFeature | FeatureOrFeature
;

rule.

just use the entry rule of your expression hiearchy here

FeatureExpression:
FeatureOrFeature
;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Previous Topic: Xtext 2.37.0.M0 is out
Next Topic:dsl changes break incremental maven build
Goto Forum:
  


Current Time: Fri Oct 11 08:57:18 GMT 2024

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

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

Back to the top