Xtext Grammar - Exclusion of a specific Rule [message #1064689] |
Thu, 20 June 2013 14:47 |
|
So I have the following rules:
HtmlAcceptedElement:
BinaryElements | Image | Link | Text
;
and
BinaryElements:
Bold | Italic | Underline | Paragraph
;
now I want for Bold to do the following:
Bold:
'b' (htmlaccelement+=HtmlAcceptedElement)+ '/b'
;
but I want to don't allow Bold rule to be inside this: (htmlaccelement+=HtmlAcceptedElement)+
is this possible? to say somehow HtmlAcceptedElement except Bold ?
Thanks in advance!
Best regards,
Edwin W.T.
|
|
|
|
|
|
|
|
|
|
Re: Xtext Grammar - Exclusion of a specific Rule [message #1064748 is a reply to message #1064746] |
Thu, 20 June 2013 19:01 |
|
Hi,
in the additional rules is a flaw imagine that you have the following use case: b i <<here>> /i /b or i b <<here>> /b /i
at <<here>> i can add again b (or i) and /b (or /i) that I don't want. This assuming what you proposed plus:
HtmlAcceptedElementSpezial returns HtmlAcceptedElement:
BinaryElementsSpezialItalic | Image | Link | Text
;
BinaryElementsSpezialItalic returns BinaryElements:
Bold | Underline | Paragraph
;
Italic:
'i' (htmlaccelement+=HtmlAcceptedElementSpezialItalic )+ '/i'
;
Thanks for all the effort!
Edwin W.T.
|
|
|
Re: Xtext Grammar - Exclusion of a specific Rule [message #1064749 is a reply to message #1064748] |
Thu, 20 June 2013 19:10 |
|
Sorry i dont know any out of the box solutions for this usecase.
and you are right the rules might explode.
unfortunately ParserBasedContentAssistContextFactory does not seem to have nice hooks for filtering.
and i dont know how easy skipping elements works on later states. (org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider.createProposals(ContentAssistContext, ICompletionProposalAcceptor))
or even later.
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Xtext Grammar - Exclusion of a specific Rule [message #1064796 is a reply to message #1064689] |
Fri, 21 June 2013 07:30 |
Jan Koehnlein Messages: 760 Registered: July 2009 Location: Hamburg |
Senior Member |
|
|
You could write a separate rule for elements that can appear inside a
'Bold'. I would not recommend this, as the user would get an error from
the parser (unexpected token) instead of a helpful message (e.g. 'bold
not allowed within bold'). So rather be generous in the grammar and
cover these constraints with validation rules.
Am 20.06.13 16:47, schrieb Edwin Tuzar:
> So I have the following rules:
>
> HtmlAcceptedElement:
> BinaryElements | Image | Link | Text
> ;
>
>
> and
>
> BinaryElements:
> Bold | Italic | Underline | Paragraph
> ;
>
> now I want for Bold to do the following:
>
> Bold:
> 'b' (htmlaccelement+=HtmlAcceptedElement)+ '/b'
> ;
>
> but I want to don't allow Bold rule to be inside this:
> (htmlaccelement+=HtmlAcceptedElement)+ is this possible? to say somehow
> HtmlAcceptedElement except Bold ?
> Thanks in advance!
> Best regards,
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
---
Get professional support from the Xtext committers at www.typefox.io
|
|
|
Powered by
FUDForum. Page generated in 0.04403 seconds