Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Serialization: Tolerant Expressions Grammar
Serialization: Tolerant Expressions Grammar [message #655691] Tue, 22 February 2011 10:37 Go to next message
Martin  is currently offline Martin Friend
Messages: 17
Registered: February 2011
Junior Member
Hi,

I just designed an expressions grammar and I would like to design concrete expressions in the XTextEditor and in the Sample EMF Editor. Unfortunately, I cannot write the expressions grammar very tolerant as the parser could not be generated in that case.

In consequence, it is easy to write syntactically incorrect expressions in the Sample EMF Editor. These expressions cannot be saved and very hardly debugged in the Sample EMF Editor.

Do you have an alternative idea how to make the Sample EMF Editor not crash that easily when saving?
Re: Serialization: Tolerant Expressions Grammar [message #655901 is a reply to message #655691] Wed, 23 February 2011 09:03 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Looks like a question for the EMF newsgroup.

If you plan to use other editors than the textual Xtext editor, it's
generally a good idea to write a more tolerant grammar and esure the
strictness by means of validation rules. See the section on EMF
Integration in the Xtext user guide for hints how to do that.

Am 22.02.11 11:37, schrieb Martin:
> Hi,
>
> I just designed an expressions grammar and I would like to design
> concrete expressions in the XTextEditor and in the Sample EMF Editor.
> Unfortunately, I cannot write the expressions grammar very tolerant as
> the parser could not be generated in that case.
>
> In consequence, it is easy to write syntactically incorrect expressions
> in the Sample EMF Editor. These expressions cannot be saved and very
> hardly debugged in the Sample EMF Editor.
>
> Do you have an alternative idea how to make the Sample EMF Editor not
> crash that easily when saving?


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: Serialization: Tolerant Expressions Grammar [message #655953 is a reply to message #655901] Wed, 23 February 2011 14:05 Go to previous messageGo to next message
Martin  is currently offline Martin Friend
Messages: 17
Registered: February 2011
Junior Member
Hi Jan,

I got the idea of making the grammar more tolerant from your docs and blogs. But I was wondering if this is possible for algebraic expressions, too.

Xbase expressions are not implemented in a tolerant way, right?

I dont unserstand why this is a question to the EMF, isnt it more a question of whether a tolerant LL(k) grammar is possible to design with tolerant algebraic expressions?
Re: Serialization: Tolerant Expressions Grammar [message #656011 is a reply to message #655953] Wed, 23 February 2011 18:04 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Martin,

what do you mean by 'tolerant expressions'?

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 23.02.11 15:05, schrieb Martin:
> Hi Jan,
>
> I got the idea of making the grammar more tolerant from your docs and
> blogs. But I was wondering if this is possible for algebraic
> expressions, too.
>
> Xbase expressions are not implemented in a tolerant way, right?
>
> I dont unserstand why this is a question to the EMF, isnt it more a
> question of whether a tolerant LL(k) grammar is possible to design with
> tolerant algebraic expressions?
Re: Serialization: Tolerant Expressions Grammar [message #656020 is a reply to message #656011] Wed, 23 February 2011 19:03 Go to previous messageGo to next message
Martin  is currently offline Martin Friend
Messages: 17
Registered: February 2011
Junior Member
Hi Sebastian,

I mean it would be nice if the grammar would also parse syntactically invalid expressions, e.g. "1 + " and its correctness later be validated. This way in the Sample EMF Editor you could create a BinaryExpression and just give it the AdditionOperator and an IntegerLiteral child.

Optimally, I would like to be able to serialize any expression node in the EMF Editor which has no children to allow the user to contructs arbitrarily broken expressions Smile

[Updated on: Wed, 23 February 2011 19:26]

Report message to a moderator

Re: Serialization: Tolerant Expressions Grammar [message #656024 is a reply to message #656011] Wed, 23 February 2011 19:25 Go to previous messageGo to next message
Martin  is currently offline Martin Friend
Messages: 17
Registered: February 2011
Junior Member
No Message Body

[Updated on: Wed, 23 February 2011 19:25]

Report message to a moderator

Re: Serialization: Tolerant Expressions Grammar [message #656028 is a reply to message #656020] Wed, 23 February 2011 19:08 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Martin,

the parser will create the mentioned incomplete expression - depending
on how you write your grammar. This error recovery suffers from
backtracking (if you enable it in your grammar) but works pretty well
for many cases.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 23.02.11 20:05, schrieb Martin:
> Hi Sebastian,
>
> I mean it would be nice if the grammar would also parse syntactically
> invalid expressions, e.g. "1 + " and its correctness later be validated.
> This way in the Sample EMF Editor you could not create a
> BinaryExpression and just give it the AdditionOperator and an
> IntegerLiteral child.
>
> Optimally, I would like to be able to serialize any expression node in
> the EMF Editor which has no children to allow the user to contructs
> arbitrarily broken expressions :)
Re: Serialization: Tolerant Expressions Grammar [message #656040 is a reply to message #656028] Wed, 23 February 2011 21:20 Go to previous message
Martin  is currently offline Martin Friend
Messages: 17
Registered: February 2011
Junior Member
Hi Sebastian,

I am not sure whether I get your point. I have binary expression productions like this:

Addition:
Multiplication ('+' Multiplication)*

Parsing with this one works fine but not serialization of for example an addition node without children. But I would like to have productions that behave like this:

Addition:
Multiplication? ('+' Multiplication?)*

Ideally, this one would offer exception-free serialization, right? But unfortunately, I cannot use ones like these, right?

I was wondering if there is another twist that I dont know of.

[Updated on: Wed, 23 February 2011 21:24]

Report message to a moderator

Previous Topic:Serialization: Missing whitespaces lead to parsing failure
Next Topic:OCL and XTEXT
Goto Forum:
  


Current Time: Fri Apr 26 01:35:13 GMT 2024

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

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

Back to the top