Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Pointers request for string-based microformat in DSL
Pointers request for string-based microformat in DSL [message #1817054] Thu, 14 November 2019 18:27 Go to next message
Savas Parastatidis is currently offline Savas ParastatidisFriend
Messages: 3
Registered: November 2019
Junior Member
Hi all,

I am new to xtext. I am looking for pointers to information about how to break down strings in my DSL within some context. I searched the Web but the closest I found was the templates-related grammar in Xtend. Unfortunately, I am trying to achieve something slightly different and I was unable to adapt the xtend grammar.

Here's a description of what I am trying to do...

// The argument is an ordinary string
call("i am an ordinary string")

// In the context of 'foo', the string takes special meaning
foo("I am a string with some {special parts | annotation variable} indicated by special characters").


In the context of foo, I'd like to extract "special parts", "annotation", and "variable".

// There can be multiple of these in a string
foor("Multiples { 1 | Int one} and { 2 | Double two } and { arbitrary text | String str}")


Should I be looking at writing some code?

Antlr has "modes" that allowed me to do this. What would be the equivalent for xtext?

I tried few things but, unfortunately, i keep getting ambiguity because of STRING. Even if I remove the dependency on Terminals, I get ambiguity with ID, which I need. The part that trips me is the text just after "{". Since it can be any arbitrary text and I have no special characters around it, the terminal for that part conflicts with ID.

Is there a write up about the strategy that I should follow?

Thank you,
.savas.
Re: Pointers request for string-based microformat in DSL [message #1817099 is a reply to message #1817054] Fri, 15 November 2019 14:16 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 157
Registered: February 2016
Senior Member
You can define a custom lexer based on the ANTLR modes and use that in your Xtext workflow. An examole can be found here:

https://github.com/eclipse/gef/blob/master/org.eclipse.gef.dot/src/org/eclipse/gef/dot/internal/language/GenerateDot.mwe2#L119
Re: Pointers request for string-based microformat in DSL [message #1817159 is a reply to message #1817099] Sat, 16 November 2019 22:54 Go to previous messageGo to next message
Savas Parastatidis is currently offline Savas ParastatidisFriend
Messages: 3
Registered: November 2019
Junior Member
Thank you. I'll give it a try.
Re: Pointers request for string-based microformat in DSL [message #1817232 is a reply to message #1817159] Mon, 18 November 2019 19:06 Go to previous messageGo to next message
Savas Parastatidis is currently offline Savas ParastatidisFriend
Messages: 3
Registered: November 2019
Junior Member
It seems that I need to find examples for xtext 2.9 and above. I get a deprecation notification when I use org.eclipse.xtext.generator.adapter.FragmentAdapter. I am encouraged to use the "new generator infrastructure". Where can I get more information of how to use a custom lexer using the new generator infrastructure? I went through the xtext documentation online but couldn't find anything relevant.

thanks!
Re: Pointers request for string-based microformat in DSL [message #1817235 is a reply to message #1817232] Mon, 18 November 2019 19:27 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
we are in work to provide an external lexer fragment that works with the new generator. if you dont want to wait you can c&p from here
https://github.com/eclipse/xtext-core/pull/1287/files


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Resolving JvmTypes in tests and standalone environments
Next Topic:Creating Serializer for different DSL
Goto Forum:
  


Current Time: Thu Mar 28 16:44:35 GMT 2024

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

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

Back to the top