Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Formatting for Python-like languages(formatting when no keyword indicate end of blocks)
Formatting for Python-like languages [message #821376] Thu, 15 March 2012 09:22 Go to next message
jean-Luc Meunier is currently offline jean-Luc MeunierFriend
Messages: 1
Registered: March 2012
Junior Member
Hi all,

Sorry if my question is too simple, but I'm struggling with how to format a language that has no bracket/keyword to mark the start and end of blocks (like in Python for instance).

Consider for instance a language like:
Type:
	'type' name=ID 
		(cases+=Case)+
	;
Case:
	'case' name=ID  STRING+


I'd like to format it like:
type toto
   case un 
      "foo"
      "second foo"
   case deux 
      "foo"
type tutu
   case trois 
      "foo"


...and I'm unable to format it, because if I indent (setIndentationIncrement) after the 'type' keyword, I do not know where to dedent (setIndentationDecrement)

Must be a trivial question, but I'm stuck.

Thanks

JL
Re: Formatting for Python-like languages [message #821548 is a reply to message #821376] Thu, 15 March 2012 13:56 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
With the current formatter it is only possible to use rules based on the
grammar. You need to write your own formatter.

I am however working on a semantic formatter with the intent of donating
it to Xtext. It is not quite finished yet, but for the brave, and those
that want to make sure their formatting needs are supported, it is
possible to experiment with it right now.

My plan was to invite others to try it and provide feedback in a week or
two - but if someone really wants to I am happy to help with information
how to use it.

It is in cloudsmith/geppetto @ github if you want to go on a hunt on
your own.

Regards
- henrik

On 2012-15-03 10:22, jean-Luc Meunier wrote:
> Hi all,
>
> Sorry if my question is too simple, but I'm struggling with how to
> format a language that has no bracket/keyword to mark the start and end
> of blocks (like in Python for instance).
>
> Consider for instance a language like:
> Type:
> 'type' name=ID (cases+=Case)+
> ;
> Case:
> 'case' name=ID STRING+
>
> I'd like to format it like:
>
> type toto
> case un "foo"
> "second foo"
> case deux "foo"
> type tutu
> case trois "foo"
>
>
> ...and I'm unable to format it, because if I indent
> (setIndentationIncrement) after the 'type' keyword, I do not know where
> to dedent (setIndentationDecrement)
>
> Must be a trivial question, but I'm stuck.
>
> Thanks
> JL
Previous Topic:Building Updatesite Problem for Xtext 2.0 plugins
Next Topic:Java Proposal
Goto Forum:
  


Current Time: Tue Apr 23 16:19:32 GMT 2024

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

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

Back to the top