Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » problem of semantic predicates in Xtext
problem of semantic predicates in Xtext [message #648231] Tue, 11 January 2011 22:33 Go to next message
Maria is currently offline MariaFriend
Messages: 49
Registered: October 2010
Member
I have read in a website: http://eclipse.dzone.com/articles/xtext that in Xtext, it is difficult to implement semantic predicates. What do we mean by this? Have you concreate examples?
Re: problem of semantic predicates in Xtext [message #648235 is a reply to message #648231] Tue, 11 January 2011 22:58 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
The concept of "semantic predicates" is explained very well in the antlr
litterature. (I bought "the antlr reference 3.0" to better understand
the parser technology on which Xtext stands).

Basically, "semantic predicate" means that if the parser is in a state
where several predictions are valid (i.e. there is ambiguity), a
semantic predicate (a rule) can specify that it should pick a particular
prediction (~ way to parse).

In order to benefit from semantic predicates you would need to be
dealing with a very complex language where for instance parsing needs to
be guided by types of thing already seen (the C language is such a
difficult language).

There are many options when using Xtext - using relaxed parsing and an
"anemic" model where you handle the more complex parts of your language
in validation or linking, or indeed in a second m2m transformation.

Why do you think you need "semantic predicates" ?

There is most likely a different solution to your problem (unless you
need to deal with a language such as C - a language which by the way
there is lots of articles to google for that describes the difficulties
parsing it. Hint: even if you are not writing a C parser, it is good to
know what royally screws up parsing, and thus are language constructs
that you want to avoid. That is if you have any say in the design of the
language you are writing a parser for).

Regards
- henrik

On 1/11/11 11:33 PM, Maria wrote:
> I have read in a website: http://eclipse.dzone.com/articles/xtext that
> in Xtext, it is difficult to implement semantic predicates. What do we
> mean by this? Have you concreate examples?
Re: problem of semantic predicates in Xtext [message #648237 is a reply to message #648235] Tue, 11 January 2011 23:25 Go to previous message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
In addendum to what Henrik said: I wrote a blog ( http://dslmeinte.wordpress.com/2010/12/08/getting-alternativ e-cross-references-to-work-with-existing-epackages/) about one of the problems you'd "normally" tackle with semantic predicates but have to solve differently with Xtext. The blog pertains to quite a specific scenario but the solution works in the more general case as well.

Previous Topic:File names of all the resources in workspace
Next Topic:[xtext/xtend] milestone update site / org.eclipse.xtend 1.1.0
Goto Forum:
  


Current Time: Thu Apr 25 16:01:46 GMT 2024

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

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

Back to the top