Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Problem with quoted string that should be split(Problem with quoted string that should be split)
Problem with quoted string that should be split [message #1608452] Mon, 09 February 2015 09:28 Go to next message
Eclipse UserFriend
Hi, first post of probably many.

I am using XText to define a DSL that needs to understand both:

base myPrefix:myName;


and

base "myPrefix:myName";


"myPrefix" is optional and should map to "namespace" in the ecore model, "myName" is mandatory and should map to "name" in the ecore model

I have tried without success both to have a terminal rule for a quoted string and also to hide all quotes with the "hidden" keyword.

What I try with now is to have a terminal rule eat the whole string and have a value converter split it into namespace and name, but so far no success with that either...

So any suggestions for way forward is highly appreciated! Let me know if I should clarify anything.

Thanks, Fredrik

Re: Problem with quoted string that should be split [message #1608503 is a reply to message #1608452] Mon, 09 February 2015 10:08 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

just to clear semantics:

is it really two pointers? or is it a pointer by a (optionally) qualified name? if so you could use a datatype rule like

NAME: STRING | ID ":" ID; //+ a value converter that does the validation

if it really are 2 different pointer it will be very tricky (if you want to keep the normal strings as well)
Re: Problem with quoted string that should be split [message #1608865 is a reply to message #1608503] Mon, 09 February 2015 15:26 Go to previous messageGo to next message
Eclipse UserFriend
Hi, thanks for your quick answer.

Yes, two pointers unfortunately, the parser rule looks like this currently:

Base returns dsl::Base: 
	'base' (namespace=[dsl::Prefix]':')?name=StringPatternToSplit ';'
;


This works for unqouted strings, and also for quoted strings if I make a terminal rule to eat the quotes and hide them. However that solution breaks the dsl in other places. The basic problem is that the language needs to allow anything betweet quotes, so if I grab only the quotes with a terminal rule I need to handle everything in between specifically.

I also tried to make a terminal rule to grab quoted strings that contained "{" and/or "}" but failed. Is this possible and if so do you have any pointers on how to do it?

Thanks, Fredrik
Re: Problem with quoted string that should be split [message #1608962 is a reply to message #1608865] Mon, 09 February 2015 16:58 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

sounds you want to have context sensual lexing. this can be done if you use a custom lexer in xtext. there should be some threads on that in the forum.
Re: Problem with quoted string that should be split [message #1609617 is a reply to message #1608962] Tue, 10 February 2015 03:22 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Ok, I will have a look at that,

Thanks for the pointer!
Regards, Fredrik
Re: Problem with quoted string that should be split [message #1609636 is a reply to message #1609617] Tue, 10 February 2015 03:35 Go to previous message
Eclipse UserFriend
another search term may be "external lexer"
Previous Topic:syntactic predicates mapping from ANTLR to XTEXT
Next Topic:Problem Importing a DSL into another
Goto Forum:
  


Current Time: Sat Nov 08 11:05:41 EST 2025

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

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

Back to the top