Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Xtext OutputConfigurationProvider (Problem in Reading the statements inside //)
Xtext OutputConfigurationProvider [message #1225557] Mon, 30 December 2013 01:04 Go to next message
Eclipse UserFriend
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 09:30 Go to previous messageGo to next message
Eclipse UserFriend
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)
Re: Xtext OutputConfigurationProvider [message #1225910 is a reply to message #1225692] Tue, 31 December 2013 00:13 Go to previous messageGo to next message
Eclipse UserFriend
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 02:21] by Moderator

Re: Xtext OutputConfigurationProvider [message #1225971 is a reply to message #1225910] Tue, 31 December 2013 04:38 Go to previous messageGo to next message
Eclipse UserFriend
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;
Re: Xtext OutputConfigurationProvider [message #1226607 is a reply to message #1225971] Thu, 02 January 2014 02:29 Go to previous messageGo to next message
Eclipse UserFriend
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 03:32] by Moderator

Re: Xtext OutputConfigurationProvider [message #1226647 is a reply to message #1226607] Thu, 02 January 2014 04:54 Go to previous messageGo to next message
Eclipse UserFriend
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 05:20 Go to previous messageGo to next message
Eclipse UserFriend
and of course you do not have to redefine sl_comment since you already inherit it from the supergrammar
Re: Xtext OutputConfigurationProvider [message #1226659 is a reply to message #1226654] Thu, 02 January 2014 05:38 Go to previous messageGo to next message
Eclipse UserFriend
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.

Re: Xtext OutputConfigurationProvider [message #1226665 is a reply to message #1226647] Thu, 02 January 2014 05:47 Go to previous messageGo to next message
Eclipse UserFriend
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 03:32] by Moderator

Re: Xtext OutputConfigurationProvider [message #1226666 is a reply to message #1226665] Thu, 02 January 2014 05:48 Go to previous messageGo to next message
Eclipse UserFriend
have a look at my new posts
Re: Xtext OutputConfigurationProvider [message #1226686 is a reply to message #1226666] Thu, 02 January 2014 06:53 Go to previous messageGo to next message
Eclipse UserFriend
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 03:43] by Moderator

Re: Xtext OutputConfigurationProvider [message #1226688 is a reply to message #1226686] Thu, 02 January 2014 06:56 Go to previous messageGo to next message
Eclipse UserFriend
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 07:26 Go to previous messageGo to next message
Eclipse UserFriend
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;
Re: Xtext OutputConfigurationProvider [message #1227007 is a reply to message #1226695] Fri, 03 January 2014 04:24 Go to previous message
Eclipse UserFriend
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 Jul 08 15:22:06 EDT 2025

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

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

Back to the top