Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Syntactic predicates in 0.8M4
Syntactic predicates in 0.8M4 [message #509390] Fri, 22 January 2010 06:02 Go to next message
Steven Derrien is currently offline Steven DerrienFriend
Messages: 50
Registered: July 2009
Member
Hi,

Is support for syntactic predicates implemented in the 0.8M4 version of
Xtext ? I have read that it was part of the planned features for .8 but
I was wondering whether this is still the case (I need this feature for
adapting an ANTLR ANSI-C grammar).

Steven
Re: Syntactic predicates in 0.8M4 [message #509521 is a reply to message #509390] Fri, 22 January 2010 16:58 Go to previous messageGo to next message
Steven Derrien is currently offline Steven DerrienFriend
Messages: 50
Registered: July 2009
Member
I forgot the magic word : "thanks in advance,"

Steven Derrien a écrit :
> Hi,
>
> Is support for syntactic predicates implemented in the 0.8M4 version of
> Xtext ? I have read that it was part of the planned features for .8 but
> I was wondering whether this is still the case (I need this feature for
> adapting an ANTLR ANSI-C grammar).
>
> Steven
Re: Syntactic predicates in 0.8M4 [message #509665 is a reply to message #509390] Sun, 24 January 2010 10:00 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Hi Steven,

syntactic predicates are not yet supported nor is it a planned item (we
plan per milestone).
Could you outline what you want to solve. Many situations can be solved
with LL(*) and backtracking.

Cheers,
Sven

Steven Derrien schrieb:
> Hi,
>
> Is support for syntactic predicates implemented in the 0.8M4 version of
> Xtext ? I have read that it was part of the planned features for .8 but
> I was wondering whether this is still the case (I need this feature for
> adapting an ANTLR ANSI-C grammar).
>
> Steven


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: Syntactic predicates in 0.8M4 [message #509674 is a reply to message #509665] Sun, 24 January 2010 15:41 Go to previous messageGo to next message
Steven Derrien is currently offline Steven DerrienFriend
Messages: 50
Registered: July 2009
Member
Hi Sven,

> Hi Steven,
>
> syntactic predicates are not yet supported nor is it a planned item (we
> plan per milestone).


> Could you outline what you want to solve. Many situations can be solved
> with LL(*) and backtracking.
>

I just wanted to get an idea of the required effort to adapt an exising
ANTLR C-ANSI grammar to Xtext. I set backtrack=true in MWE, there was no
error message, but my grammar is obviously not working/

BTW, If some people are interested by an C-ANSI Xtext parser, I'd be
glad to share my efforts.

Following is an excerpt of the an ANTLR C-ANSI grammar
(http://www.antlr.org/grammar/1153358328744/C.g) which uses predicates
to cope with declarator/definition ambiguity.

> /** Either a function definition or any other kind of C decl/def.
> * The LL(*) analysis algorithm fails to deal with this due to
^^^^^^^^^^^^^^ ^^^^^
> * recursion in the declarator rules. I'm putting in a
> * manual predicate here so that we don't backtrack over
> * the entire function. Further, you get a better error
> * as errors within the function itself don't make it fail
> * to predict that it's a function. Weird errors previously.
> * Remember: the goal is to avoid backtrack like the plague
> * because it makes debugging, actions, and errors harder.
> *
> * Note that k=1 results in a much smaller predictor for the
> * fixed lookahead; k=2 made a few extra thousand lines. ;)
> * I'll have to optimize that in the future.
> */
> external_declaration
> options {k=1;}
> : ( declaration_specifiers? declarator declaration* '{' )=> function_definition
> | declaration
> ;

Steven
Re: Syntactic predicates in 0.8M4 [message #509722 is a reply to message #509674] Mon, 25 January 2010 08:19 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Steven Derrien schrieb:

>> /** Either a function definition or any other kind of C decl/def.
>> * The LL(*) analysis algorithm fails to deal with this due to
> ^^^^^^^^^^^^^^ ^^^^^
>> * recursion in the declarator rules. I'm putting in a
>> * manual predicate here so that we don't backtrack over
>> * the entire function. Further, you get a better error
>> * as errors within the function itself don't make it fail
>> * to predict that it's a function. Weird errors previously.
>> * Remember: the goal is to avoid backtrack like the plague
>> * because it makes debugging, actions, and errors harder.
>> *
>> * Note that k=1 results in a much smaller predictor for the *
>> fixed lookahead; k=2 made a few extra thousand lines. ;)
>> * I'll have to optimize that in the future.
>> */
>> external_declaration
>> options {k=1;}
>> : ( declaration_specifiers? declarator declaration* '{' )=>
>> function_definition
>> | declaration
>> ;

That one should work with backtrack=true, since in that mode antlr works
like a packrat parser, which tries to match the alternatives in the
given order.
That is if function_definition matches (i.e there's a '{') it comsumes
it, else it tries to consume declaration.

Cheers,
Sven



--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: Syntactic predicates in 0.8M4 [message #535856 is a reply to message #509674] Wed, 26 May 2010 03:54 Go to previous messageGo to next message
Pierrick is currently offline PierrickFriend
Messages: 15
Registered: May 2010
Junior Member
-sorry I'm new to this forum, but I didn't found any way to send private message-

Hi Steven,
Is your ANTL C grammar adaptation to Xtext working well ?
I'll be really interested to see the result / sources ...

Cheers,
Pierrick
Re: Syntactic predicates in 0.8M4 [message #1007862 is a reply to message #509674] Thu, 07 February 2013 19:45 Go to previous message
Roza Ghamari is currently offline Roza GhamariFriend
Messages: 82
Registered: January 2013
Member
Hi Setevn,

>>BTW, If some people are interested by an C-ANSI Xtext parser, I'd be
glad to share my efforts.

Could you please share? It would be really helpful, we are looking for an ANSI C xtext grammar as well.

Thanks,
Roza
Previous Topic:How do I make it so I can add decimals to the amount and quantity and also recieve a correct decimal
Next Topic:beginner question
Goto Forum:
  


Current Time: Thu Apr 18 22:51:26 GMT 2024

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

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

Back to the top