Skip to main content


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?

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.


Allan

[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 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: Fri Apr 19 10:55:34 GMT 2024

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

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

Back to the top