Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Support of semantic predicates
Support of semantic predicates [message #989180] Wed, 05 December 2012 02:22 Go to next message
Allan T is currently offline Allan TFriend
Messages: 2
Registered: December 2012
Junior Member
I am trying to write a parser for C based on a ANTLR grammar (see below). For this I will have to make use of context sensitive information, i.e. semantic predicates. As far as I know, Xtext does not support that feature.

Question 1: Or does Xtext now support semantic predicates similar to how they are implemented within ANTLR?

Question 2: Assuming semantic predicates are not supported. Is there any other way to solve my problem which is making rule decisions based on the existence of user types (typedefs, structs, enums)? Could perhaps cross-references be useful in this case?


ANTLR C Grammar: http:// www.


A sample to clarify:

    : temp += (Expression | Declaration | UserType)*

    : Type '*' name=ID ';'

    : temp1 = Primary ('*' temp2 += Primary)* ';'

    : temp1 = INT
    | temp2 = [Declaration]

    : temp1 = SimpleType
    | temp2 = [UserType]

    : 'int' | 'long'

    : 'typedef' name=ID ';'

Problems occur with Declaration and Expression, because both of them are syntacticly the same. However, I would like to make a semantic distinguishment.

typedef a;

Entity -> Declaration -> Type -> UserType -> 'a' could be resolved as a type, so take this rule and do not look in any other alternatives.

For that though, I will have to make use of some kind of semantic predicate.


[Updated on: Thu, 06 December 2012 09:52]

Report message to a moderator

icon9.gif  Re: Support of semantic predicates [message #1706424 is a reply to message #989180] Wed, 26 August 2015 18:59 Go to previous message
Harald Weiner is currently offline Harald WeinerFriend
Messages: 23
Registered: January 2015
Location: Linz, Austria
Junior Member
Seems like there has not been any progress on semantic predicates (yet)... Confused Sad Crying or Very Sad
I am also stuck with the same problem!
See also my post under
Previous Topic:java.lang.IllegalArgumentException
Next Topic:Feature-based RCP Product: - which feature?
Goto Forum:

Current Time: Thu Apr 19 09:51:45 GMT 2018

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

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