Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Macro's
Macro's [message #645307] Thu, 16 December 2010 14:56 Go to next message
No real name is currently offline No real nameFriend
Messages: 25
Registered: April 2010
Junior Member
Hey,

I got quite far with my grammar, but now I am wondering if its possible to implement in Xtext something which resembles a macro. What I have in mind is:

DefineMacro:
    '#define' name=ID value=XXX


XXX should be some magic which states that it is everything until the end of line. Is something like this possible or would the lexer come into the way? I thought about doing it as a terminal, but that doesnt make much sense to me as it wont allow for any flexibility in whitespaces

[Updated on: Thu, 16 December 2010 15:06]

Report message to a moderator

Re: Macro's [message #645434 is a reply to message #645307] Fri, 17 December 2010 09:21 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

The following snippet should give you an idea

DefineMacro hidden():
'#define' name=ID value=(ID|INT|WS|STRING|listOfAnyKeywordAllowedHere)* NL;

terminal NL: "\r?\n";

Note that the NL definition overlaps with the WS definition. Some more modifications might be necessary (in particular making NL hidden by default). You may also run into problems if a macro definition is allowed to be in the last line of your model file (right now a new line is mandatory after the definition).

Alex
Re: Macro's [message #645517 is a reply to message #645434] Fri, 17 December 2010 15:18 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 25
Registered: April 2010
Junior Member
thanks for the tip. Right now I am wondering if there is an inbuilt production rule or expression which would say "any keyword", so that I dont have to maintain the listOdKeywords manually.
Re: Macro's [message #645520 is a reply to message #645307] Fri, 17 December 2010 15:37 Go to previous message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
Well you can pre-process your grammar (using a M2M mechanism for example) and transform it into another when you generate.
Previous Topic:Content Assistant Proposal
Next Topic:Problems with unary ++, --
Goto Forum:
  


Current Time: Thu Sep 26 03:44:44 GMT 2024

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

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

Back to the top