Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » UNTIL token question
UNTIL token question [message #691075] Thu, 30 June 2011 16:22 Go to next message
drew frantz is currently offline drew frantzFriend
Messages: 340
Registered: July 2009
Senior Member
terminal BLOCK : '{' -> '}';

I want to impl a terminal rule to allow a block of arbitrary script code
inside the curly braces, the problem is that one can also nest a curlies
inside the block. What are the options other than trying to deal with the
entire syntax of the BLOCK script language.

{
// some script
if(foo)
{
.....
}
}
Re: UNTIL token question [message #691081 is a reply to message #691075] Thu, 30 June 2011 16:39 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
You can deal with it in the lexer. You need to switch to an external
lexer written in antlr syntax. Xtext support the use of this, and it is
quite straight forward to use.

With an external lexer you can do tricks like having conditional rules.
I am using this in cloudsmith/geppetto on github if you like to take a
peek at code using this.

- henrik

On 6/30/11 6:22 PM, Drew wrote:
> terminal BLOCK : '{' -> '}';
>
> I want to impl a terminal rule to allow a block of arbitrary script code
> inside the curly braces, the problem is that one can also nest a curlies
> inside the block. What are the options other than trying to deal with
> the entire syntax of the BLOCK script language.
>
> {
> // some script
> if(foo)
> {
> .....
> }
> }
Re: UNTIL token question [message #691133 is a reply to message #691081] Thu, 30 June 2011 19:33 Go to previous messageGo to next message
drew frantz is currently offline drew frantzFriend
Messages: 340
Registered: July 2009
Senior Member
DO you I just override the Lexer that is generated by xtext, or is there
something more to this?
Does this work with xtext prior to 2.0?

"Henrik Lindberg" <henrik.lindberg@cloudsmith.com> wrote in message
news:iui89v$hh$2@news.eclipse.org...
> You can deal with it in the lexer. You need to switch to an external lexer
> written in antlr syntax. Xtext support the use of this, and it is quite
> straight forward to use.
>
> With an external lexer you can do tricks like having conditional rules.
> I am using this in cloudsmith/geppetto on github if you like to take a
> peek at code using this.
>
> - henrik
>
> On 6/30/11 6:22 PM, Drew wrote:
>> terminal BLOCK : '{' -> '}';
>>
>> I want to impl a terminal rule to allow a block of arbitrary script code
>> inside the curly braces, the problem is that one can also nest a curlies
>> inside the block. What are the options other than trying to deal with
>> the entire syntax of the BLOCK script language.
>>
>> {
>> // some script
>> if(foo)
>> {
>> .....
>> }
>> }
>
Re: UNTIL token question [message #691177 is a reply to message #691133] Thu, 30 June 2011 21:50 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
You can start with the generated antlr source (I can't remember if I did
that or if I copied and edited my xtext grammar part that defines the
terminals - the syntax is very similar but still different). The trick
is that you have to defined the terminals in your grammar, and your
external lexer *must* use the same tokens (the main hassle is to keep
them in sync if you are modifying things in your grammar (wrt. terminals
that is).

IIRC this is/was available for Xtext 1.x as well.

- henrik

On 6/30/11 9:33 PM, Drew wrote:
> DO you I just override the Lexer that is generated by xtext, or is there
> something more to this?
> Does this work with xtext prior to 2.0?
>
> "Henrik Lindberg" <henrik.lindberg@cloudsmith.com> wrote in message
> news:iui89v$hh$2@news.eclipse.org...
>> You can deal with it in the lexer. You need to switch to an external
>> lexer written in antlr syntax. Xtext support the use of this, and it
>> is quite straight forward to use.
>>
>> With an external lexer you can do tricks like having conditional rules.
>> I am using this in cloudsmith/geppetto on github if you like to take a
>> peek at code using this.
>>
>> - henrik
>>
>> On 6/30/11 6:22 PM, Drew wrote:
>>> terminal BLOCK : '{' -> '}';
>>>
>>> I want to impl a terminal rule to allow a block of arbitrary script code
>>> inside the curly braces, the problem is that one can also nest a curlies
>>> inside the block. What are the options other than trying to deal with
>>> the entire syntax of the BLOCK script language.
>>>
>>> {
>>> // some script
>>> if(foo)
>>> {
>>> .....
>>> }
>>> }
>>
Previous Topic:Unassigned actions and cross links
Next Topic:[Xtext] getCommentsForEObject fails
Goto Forum:
  


Current Time: Sun Nov 01 02:17:15 GMT 2020

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

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

Back to the top