Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Data Type Rule
Data Type Rule [message #1857568] Wed, 15 February 2023 14:10 Go to next message
jo ber is currently offline jo berFriend
Messages: 94
Registered: August 2018
Member
Hi

I've the following grammar:

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

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
	greetings+=GreetingRobot*;
	
GreetingRobot:
	'Hello' name=ROBOT_ID '!';

ROBOT_ID :
    'ROBOT_' INT
;


The following text:
Hello ROBOT_1 !


produce the error:
org.opentest4j.AssertionFailedError: Unexpected errors: XtextSyntaxDiagnostic: null:1 mismatched input 'ROBOT_1' expecting 'ROBOT_' ==> expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:55)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:40)
	at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:210)


I would like to keep 'ROBOT_ID' as a DataType rule, i.e. not a terminal. I would like to know what is the problem and how to fix it.

thank you and kind regards,
Re: Data Type Rule [message #1857569 is a reply to message #1857568] Wed, 15 February 2023 14:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
ROBOT_1 is an ID so what about

ROBOT_ID :
ID
;

+ implement a value converter

or remove the _ from ID


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Data Type Rule [message #1857573 is a reply to message #1857569] Wed, 15 February 2023 15:22 Go to previous message
jo ber is currently offline jo berFriend
Messages: 94
Registered: August 2018
Member
thank you for the quick answer.
Previous Topic:Language server respond with error missing header in mac
Next Topic:InMemoryJavaCompiler: test for Java 8 compatibility
Goto Forum:
  


Current Time: Fri Dec 06 17:19:01 GMT 2024

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

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

Back to the top