Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » I want here to escape all characters including keywords declared in certain rules(I want here to escape all characters including keywords declared in certain rules)
I want here to escape all characters including keywords declared in certain rules [message #1728661] Wed, 06 April 2016 11:11 Go to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
Hello,
I have the following grammar

class_decl returns ClassDecl:
'class' name=id 'extends' id
statements=statments_decl
'end' 'class';

statments_decl returns Statements:
// I want here to escape all characters including keywords declared in other places in my grammar

I can't seem to this with words like 'class' & 'extends'
I used the operators defined in Xtext like '^' , '.' & '->' but i failed

I mean i need to write anything inside class declaration without reporting syntax errors
Re: I want here to escape all characters including keywords declared in certain rules [message #1728673 is a reply to message #1728661] Wed, 06 April 2016 11:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
The ID rules allows you to write ^keyword.

If you want to use keyword with no escape you have to use

MyID: ID|'keyword1'|...|'keywordn';


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: I want here to escape all characters including keywords declared in certain rules [message #1728685 is a reply to message #1728673] Wed, 06 April 2016 12:39 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
I tried declaring rule to be used inside statements called

statments_decl returns Statements:
identifier *
;

identifier :
^SIMPLE_IDENTIFIER
;
terminal SIMPLE_IDENTIFIER :
((A..Z)|(a..z))((A..Z)|(a..z))*
;

Again here i was trying to escape every thing inside statements_decl, but it doesnt work
Am i missing something?
Re: I want here to escape all characters including keywords declared in certain rules [message #1728687 is a reply to message #1728685] Wed, 06 April 2016 12:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Please share a complete grammar and unit test

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: I want here to escape all characters including keywords declared in certain rules [message #1734595 is a reply to message #1728687] Thu, 09 June 2016 15:57 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
example of what i need
Based on the grammer in the first of this thread.

file.dsl
----------
class A extends B

--i need anything written here to be ignore even if its another keyword
--example
class class class extends extends extends ASDASDASDkjhkjhadf anything....

end class;

so i need anything enclosed between 'class' and 'end class' to be ignore, is it possible in xtext, i hope you get my idea now.

what i mean is that i need this block not to be highlighted and no emf will be created for them, no errors..

is it possible ?

[Updated on: Thu, 09 June 2016 15:59]

Report message to a moderator

Re: I want here to escape all characters including keywords declared in certain rules [message #1734600 is a reply to message #1734595] Thu, 09 June 2016 18:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
i dont know an "easy way" to do this sry - you have to create a datatype rule that enlists all allowed stuff

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 09 June 2016 18:28]

Report message to a moderator

Re: I want here to escape all characters including keywords declared in certain rules [message #1734612 is a reply to message #1734600] Thu, 09 June 2016 23:07 Go to previous messageGo to next message
kimi raikonnan is currently offline kimi raikonnanFriend
Messages: 145
Registered: June 2015
Senior Member
Sorry i dont understand what do you mean by "datatype rule that enlists all allowed stuff " could you elaborate more
Re: I want here to escape all characters including keywords declared in certain rules [message #1734619 is a reply to message #1734612] Fri, 10 June 2016 03:19 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Stuff: (ID | INT | "keyword1"|...|"keywordn" | ANY_OTHER | CUSTOM_TERMINAL)+

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Go to Matching Bracket shortcut doesn't appear inkey assist
Next Topic:How to exclude some specific resource from xtext validation?
Goto Forum:
  


Current Time: Fri Mar 29 11:14:11 GMT 2024

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

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

Back to the top