Xtext OutputConfigurationProvider [message #1225557] |
Mon, 30 December 2013 06:04 |
|
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 #1225910 is a reply to message #1225692] |
Tue, 31 December 2013 05:13 |
|
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 #1226607 is a reply to message #1225971] |
Thu, 02 January 2014 07:29 |
|
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 #1226659 is a reply to message #1226654] |
Thu, 02 January 2014 10:38 |
|
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 #1226695 is a reply to message #1226688] |
Thu, 02 January 2014 12:26 |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.05213 seconds