Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext OutputConfigurationProvider (Problem in Reading the statements inside //)
Xtext OutputConfigurationProvider [message #1225557] Mon, 30 December 2013 06:04 Go to next message
Kunal Khaware is currently offline Kunal KhawareFriend
Messages: 41
Registered: December 2013
Location: Hyderabad,India
Member

Hi All,

I am facing issues to read the statements inside // in xtext template using OutputConfiguration Provider class. I have written the grammar to read all statements that comes after // or /*.Any Help is appreciated.

Thanks
Kunal
Re: Xtext OutputConfigurationProvider [message #1225692 is a reply to message #1225557] Mon, 30 December 2013 14:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi can you please give some more Context of what you exactly want todo

Where you you want Todo this
What do you want to do (example)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext OutputConfigurationProvider [message #1225910 is a reply to message #1225692] Tue, 31 December 2013 05:13 Go to previous messageGo to next message
Kunal Khaware is currently offline Kunal KhawareFriend
Messages: 41
Registered: December 2013
Location: Hyderabad,India
Member

Hi,
I have a grammar file say AD.xtext,Below is the content of AD.xtext
======================================================================



Statement:
Note
;

Note:
('//' name = ID)
;

===============================================================

Now in the Template file whenever put any comments inside // I want to parse the content inside // into a txt file.

I am able to parse the content of other parts of template by creation custom OutputConfigurationProvider class but when comes to parse the content inside // or /*
*/, the xtext takes it as default comment and I am not able to see any thing in the Object for comment( ie Note in above case).

Is there any way to to parse this content?

Please let me know if you need further clarifications.

[Updated on: Fri, 03 January 2014 07:21]

Report message to a moderator

Re: Xtext OutputConfigurationProvider [message #1225971 is a reply to message #1225910] Tue, 31 December 2013 09:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi I assume you use the terminal grammar as a supergrammar.
There is a hidden SL comment rule that collides with your stuff
So what introducing a data type rule and use this one (you may need a value converter as well)

Note: name=NoteValue;

NoteValue hidden(): SL_COMMENT;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext OutputConfigurationProvider [message #1226607 is a reply to message #1225971] Thu, 02 January 2014 07:29 Go to previous messageGo to next message
Kunal Khaware is currently offline Kunal KhawareFriend
Messages: 41
Registered: December 2013
Location: Hyderabad,India
Member

Hi Chris,
Thanks for the reply.I tried with your code and below is the Grammar file and usage File :

Grammar File
====================



Statement:
Note
;

Note:
('//' name = ID)
;
terminal SL_COMMENT : '//' !('\n'|'\r')* ('\r'? '\n')? ;
name hidden(): SL_COMMENT;
==============================================================================================
Xtend class for parsing
===========================
class AdlGenerator implements IGenerator {

override void doGenerate(Resource resource, IFileSystemAccess fsa) {


fsa.generateFile('parsed.txt', 'Content of Note is: ' +
resource.allContents
.filter(typeof(Note))
.map[name]
.join(', '))

}
}
================================Usage File=================================
hh.ad
-----

Entity Action:{

}

{
//text
}



}

===================================
After saving the usage file.. I see the content of parsed.txt as empty.. Can u pls have a look. Appreciate your Help here...

[Updated on: Fri, 03 January 2014 08:32]

Report message to a moderator

Re: Xtext OutputConfigurationProvider [message #1226647 is a reply to message #1226607] Thu, 02 January 2014 09:54 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Hi Kunal,

I think you have not applied the example from Dietrich Correctly:
Note: name=NoteValue;
NoteValue hidden(): SL_COMMENT;

Your grammar reads:
Note:
('//' name = ID)
;
terminal SL_COMMENT : '//' !('\n'|'\r')* ('\r'? '\n')? ;
name hidden(): SL_COMMENT;

Think that makes the difference
Re: Xtext OutputConfigurationProvider [message #1226654 is a reply to message #1226647] Thu, 02 January 2014 10:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
and of course you do not have to redefine sl_comment since you already inherit it from the supergrammar

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext OutputConfigurationProvider [message #1226659 is a reply to message #1226654] Thu, 02 January 2014 10:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i had a look,
it is not enhough to switch it off on datatype rule level, you have to switch it off above

is there a reason to have comments as comments or shall they always be values?
if so you can unhide them on grammar level.

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
hidden (WS, ML_COMMENT)
...
Note:
name=NoteValue
;

NoteValue  : SL_COMMENT;


alternatively you could redefine the SL_COMMENT rule not to use // or do not
inherit from terminals and thus not having a SL_COMMENT rule at all.



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext OutputConfigurationProvider [message #1226665 is a reply to message #1226647] Thu, 02 January 2014 10:47 Go to previous messageGo to next message
Kunal Khaware is currently offline Kunal KhawareFriend
Messages: 41
Registered: December 2013
Location: Hyderabad,India
Member

Hi,
I changed the grammar below but still I am unable to parse the content:
AD.xtext
==========

Note
;

Note:
name=NoteValue
;
NoteValue hidden(): SL_COMMENT;

===============================================================

Thanks
Kunal

[Updated on: Fri, 03 January 2014 08:32]

Report message to a moderator

Re: Xtext OutputConfigurationProvider [message #1226666 is a reply to message #1226665] Thu, 02 January 2014 10:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
have a look at my new posts

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext OutputConfigurationProvider [message #1226686 is a reply to message #1226666] Thu, 02 January 2014 11:53 Go to previous messageGo to next message
Kunal Khaware is currently offline Kunal KhawareFriend
Messages: 41
Registered: December 2013
Location: Hyderabad,India
Member

url to elicpse xtext Terminal
hidden (WS, ML_COMMENT,SL_COMMENT)


Statement:
	Note
;

Note:
name=NoteValue
;

NoteValue  : '//';


	
	'{'
	   
	 (statements +=  Statement )*
	
	'}'
'}'  

;


Still same issue Sad

[Updated on: Fri, 03 January 2014 08:43]

Report message to a moderator

Re: Xtext OutputConfigurationProvider [message #1226688 is a reply to message #1226686] Thu, 02 January 2014 11:56 Go to previous messageGo to next message
Kunal Khaware is currently offline Kunal KhawareFriend
Messages: 41
Registered: December 2013
Location: Hyderabad,India
Member

I tried with :
Note:
name=NoteValue
;

NoteValue : SL_COMMENT;

Still no luck Sad
Re: Xtext OutputConfigurationProvider [message #1226695 is a reply to message #1226688] Thu, 02 January 2014 12:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi, seems you still did not do what i finallly told

this following works for me

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
hidden (WS, ML_COMMENT)

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

AD:
ActionDiagram
;

ActionDiagram:
'Action Diagram' name=ID 
'{'

'Import:'
'{'


'}'	

'Export:'
'{'



'}'
'Local:'
'{'


'}'
'Entity Action:'
'{'



'}'

'{'

(statements += Statement )*

'}'
'}' 

;

Statement:
Note
;

Note:
name=NoteValue
;

NoteValue  : SL_COMMENT;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext OutputConfigurationProvider [message #1227007 is a reply to message #1226695] Fri, 03 January 2014 09:24 Go to previous message
Kunal Khaware is currently offline Kunal KhawareFriend
Messages: 41
Registered: December 2013
Location: Hyderabad,India
Member

Yes, It worked for me !!!! Smile

Thanks a lot Chris...
Previous Topic:Xtext content assist
Next Topic:Xcore - Using annotations in IDE
Goto Forum:
  


Current Time: Tue Apr 23 17:10:09 GMT 2024

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

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

Back to the top