|Support of semantic predicates [message #989180]
||Wed, 05 December 2012 02:22
| Allan T
Registered: December 2012
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. antlr.org/grammar/1153358328744/C.g
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.
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
Powered by FUDForum
. Page generated in 0.21471 seconds