| Syntactic predicates in 0.8M4 [message #509390] |
Fri, 22 January 2010 01:02  |
Steven Derrien Messages: 43 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 #509665 is a reply to message #509390] |
Sun, 24 January 2010 05:00   |
Sven Efftinge Messages: 1667 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
--
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 10:41   |
Steven Derrien Messages: 43 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 03:19   |
Sven Efftinge Messages: 1667 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
--
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 #1007862 is a reply to message #509674] |
Thu, 07 February 2013 14:45  |
Roza Ghamari Messages: 22 Registered: January 2013 |
Junior 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
|
|
|
Powered by
FUDForum. Page generated in 0.01729 seconds