Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Support of semantic predicates
Support of semantic predicates [message #989180] Tue, 04 December 2012 21:22 Go to next message
Eclipse UserFriend
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?

Allan

ANTLR C Grammar: http:// www. antlr.org/grammar/1153358328744/C.g

Edit:

A sample to clarify:

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

Declaration
    : Type '*' name=ID ';'
;

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

Primary
    : temp1 = INT
    | temp2 = [Declaration]
;

Type
    : temp1 = SimpleType
    | temp2 = [UserType]
;

SimpleType
    : 'int' | 'long'
;

UserType
    : '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;
a*b;

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 04:52] by Moderator

icon9.gif  Re: Support of semantic predicates [message #1706424 is a reply to message #989180] Wed, 26 August 2015 14:59 Go to previous message
Eclipse UserFriend
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 https://www.eclipse.org/forums/index.php/t/1069632/
Previous Topic:java.lang.IllegalArgumentException
Next Topic:Feature-based RCP Product: com.google.guava - which feature?
Goto Forum:
  


Current Time: Sun Jul 06 13:27:11 EDT 2025

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

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

Back to the top