Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Extended C Language Editor in XText(Extended C Language Editor in XText)
Extended C Language Editor in XText [message #644579] Mon, 13 December 2010 11:01 Go to next message
Salman  is currently offline Salman Friend
Messages: 2
Registered: December 2010
Junior Member
Hi,

I want to create a text editor which supports syntax highlighting, Outline view etc for a extended version of C language. I have some questions related to XText which are as follows;
1. I need to ask whether it is possible to use XText for creating such type of text Editor?
2. It will take a lot of time to write gammer for C Langauge and then for the extended keywords. Is there any way that I can import the existing grammer of C Language into my xtext DSL?

thanks and regards,
Salman.

Re: Extended C Language Editor in XText [message #644583 is a reply to message #644579] Mon, 13 December 2010 11:12 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
1. Yes. provided the language can be parsed using a (context-free) LL(*) parser.
2. Direct import is not supported and Xtext uses its own grammar definition language which combines productions with definition of/binding to the Semantic Model.

There are C grammars out there and if they happen to use a definition language which you can parse (using Xtext or not), then you might very well be able to generate the required Xtext grammar from there. Be sure to start implementing the grammar with a small, but representative part of that C-language though as else you'll undoubtedly run into the "unknown unknowns" much later on. And be sure to get a good understanding of Xtext as such as it's a little different from standard parser generators since it deals with all kinds of aspects at once.


Re: Extended C Language Editor in XText [message #644587 is a reply to message #644583] Mon, 13 December 2010 11:54 Go to previous messageGo to next message
Salman  is currently offline Salman Friend
Messages: 2
Registered: December 2010
Junior Member
thank you Meinte for your response.

Well what I understood from your reponse is that I have to understand the existing C language grammer and then convert it into the DSL of XText.
For example I have found the following grammer for C++ and according to you I have to transform it into DSL in Xtext. Please correct me if I am wrong.
http://www.csci.csusb.edu/dick/c++std/cd2/gram.html

I am also assuming that there is no other way to import the C language grammer into DSL in XText.

thanks and regards,
Salman.
Re: Extended C Language Editor in XText [message #644588 is a reply to message #644587] Mon, 13 December 2010 12:16 Go to previous message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
Again: there are no importing facilities for importing complete, pre-existing grammars (in some other grammar def. language) into Xtext.

What you'll have to consider when picking up an existing grammar (e.g., the one you linked):


  1. Is it actually an LL(*)-parsable language? This rules out left recursion as in the C++ one.
  2. How big is the conceptual distance between a grammar "just for parsing" (as the C++ one) and a grammar which actually produces a model (tree/attribute grammar)?


E.g., I see many productions in the C++ grammar which are just aliases for terminal rules (mostly identifier). This makes no sense in an Xtext grammar, as you'd most like transform this into an assignment like
namespaceName=ID
or something. You'll have to understand both the C(++)-language and both grammar languages quite well to be able to do this. It's certainly possible (and done before), but prepare to dig in into all these aspects.


Previous Topic:Xtext/Xpand - Could not find any exported element of type
Next Topic:newbie question
Goto Forum:
  


Current Time: Fri Apr 26 12:00:15 GMT 2024

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

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

Back to the top