[il-antlr-interest: 32743] [antlr-interest] AST rewrite

2011-06-11 Thread srinivasan karthikeyan pitchai
Hi Gurus,
I'm a novice using ANTLR for a development project.  I am at a stage 
where I need to rewrite AST so that the transformed AST renders itself 
more easy for me to walk and emit the translation that I need.  In this 
context I've a concept question.

In general,  can I use the *same*  tree adapter,  used by the 
InputNodeStream used by the walker,  in a java method that I code to 
restructure the tree without using the rewrite rule?  That is can I add, 
delete, replace nodes at will in the source tree?  I am looking at this 
option as I need to move up a subtree from deep down to a much higher 
level.   In particular would manipulating the source tree mess up the 
iterator used by the ANTLR AST walker  to parse the tree?


(eg)  Just want to know if I can effect this in JAVA.   I am sure we can 
make it happen using rewrite rule.  However I want to conceptually know 
if what I desire above is a feasibility or it it a totally wrong approach.

^(ROOT a  b ^(ROOT c d  ^(ROOT e f g)))

I need to restructure the tree like, say,

^(ROOT a  b ^(ROOT c d ) ^(ROOT e f g))

Based on your input I need to chalk the future course of my coding.

Thanks in advance.

Regards,
Vasan



List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 32745] Re: [antlr-interest] AST rewrite

2011-06-11 Thread Trevor John Thompson
The short answer is yes, you can manipulate the tree (before walking, not 
during).
I am using tree adapter manipulations to reorganize the AST, and then handing 
the tree to the standard tree walker.

The only caution is that TreeIterator depends on parent pointers. I am 
contemplating a version that does not have this dependency, so i can base my 
trees on BaseTree, rather than CommonTree.

On 2011 Jun 11, at 00:53, srinivasan karthikeyan pitchai wrote:

 Hi Gurus,
 I'm a novice using ANTLR for a development project.  I am at a stage 
 where I need to rewrite AST so that the transformed AST renders itself 
 more easy for me to walk and emit the translation that I need.  In this 
 context I've a concept question.
 
 In general,  can I use the *same*  tree adapter,  used by the 
 InputNodeStream used by the walker,  in a java method that I code to 
 restructure the tree without using the rewrite rule?  That is can I add, 
 delete, replace nodes at will in the source tree?  I am looking at this 
 option as I need to move up a subtree from deep down to a much higher 
 level.   In particular would manipulating the source tree mess up the 
 iterator used by the ANTLR AST walker  to parse the tree?
 
 
 (eg)  Just want to know if I can effect this in JAVA.   I am sure we can 
 make it happen using rewrite rule.  However I want to conceptually know 
 if what I desire above is a feasibility or it it a totally wrong approach.
 
 ^(ROOT a  b ^(ROOT c d  ^(ROOT e f g)))
 
 I need to restructure the tree like, say,
 
 ^(ROOT a  b ^(ROOT c d ) ^(ROOT e f g))
 
 Based on your input I need to chalk the future course of my coding.
 
 Thanks in advance.
 
 Regards,
 Vasan
 
 
 
 List: http://www.antlr.org/mailman/listinfo/antlr-interest
 Unsubscribe: 
 http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--
Trevor John Thompson(425) 246-4023
net: ti...@me.com
Quidquid Latine dictum sit, altum videtur.


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 32746] Re: [antlr-interest] Extract all rules/lexems/keywords of a Language.g into XML format?

2011-06-11 Thread Ruslan Zasukhin
On 6/11/11 3:16 AM, Terence Parr pa...@cs.usfca.edu wrote:

Hi Terrence,

 Hi. Let me be more specific...I am going to serialize entire grammar as an
 augmented transition network into any generated parser or lexer. This will
 improve your recovery and error messages. There will be an API to figure out
 what could've come next.  I won't be using XML.

Okay, this sounds like feature, which will help us build
a smart auto-completion list of next token ...  Right?

Very nice. 

 As for the GUI widget, I'm providing a simple widget that, using reflection if
 I remember correctly, pulls out the appropriate information from a
 parser/lexer and then manages to automatically syntax highlight and flag
 erroneous syntax. For semantics, the programmer would be on their own. It is a
 cheap way for someone to get an editor for their DSL.

I do not catch ... Widget Java only?
   What will do C++ developers :-)

Actually we think not about GUI widget, but about
Feature of ANTLR to produce XML file from any grammar

Example:

Exists  
cpp.g
sql.g
php.g

We add into that .g   or into  antlr -switch
output=xml

and 
antlr  putput=xml  cpp.g

Will produce   cpp.g.xml (or sql.g.xml,  php.g.xml )

Which will contain language from .g expressed in XML format...
And may be reverse task XML to .g

Strange task?   :)   I know ...

 
 sometime late this summer I am hoping to have early access
 
 Ter
 On Jun 10, 2011, at 2:22 AM, Ruslan Zasukhin wrote:
 
 On 6/10/11 12:37 AM, Terence Parr pa...@cs.usfca.edu wrote:
 
 Hi Terence, 
 
 i have something like this but am not done.
 
 AST of any grammar into XML ?
 
 Great!
 
 Just keep in mind please that cTAG and GCC-XML products and their tasks.
 I believe ANTLR is a goold-tool to do same -- even better -- even more.
 
 
 This do not presents in the v4 betas yet?
 Any chance on early access?  :-)
 
 
 v4 will have a syntax highlighting  editor as a standard widget.
 
 Can you explain this in more details?
 
 You mean syntax highlighting editor where?
  in ANTLRworks? 
 
 Or ANTLR will be able produce something what
  any EDITOR app can use later ?

-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]



List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 32747] Re: [antlr-interest] Extract all rules/lexems/keywords of a Language.g into XML format?

2011-06-11 Thread Terence Parr

On Jun 11, 2011, at 7:40 AM, Ruslan Zasukhin wrote:

 On 6/11/11 3:16 AM, Terence Parr pa...@cs.usfca.edu wrote:
 
 Hi Terrence,
 
 Hi. Let me be more specific...I am going to serialize entire grammar as an
 augmented transition network into any generated parser or lexer. This will
 improve your recovery and error messages. There will be an API to figure out
 what could've come next.  I won't be using XML.
 
 Okay, this sounds like feature, which will help us build
 a smart auto-completion list of next token ...  Right?

yep.

 As for the GUI widget, I'm providing a simple widget that, using reflection 
 if
 I remember correctly, pulls out the appropriate information from a
 parser/lexer and then manages to automatically syntax highlight and flag
 erroneous syntax. For semantics, the programmer would be on their own. It is 
 a
 cheap way for someone to get an editor for their DSL.
 
 I do not catch ... Widget Java only?
   What will do C++ developers :-)

Make their own. ;)  It could be hooked up via sockets I guess.

 Actually we think not about GUI widget, but about
 Feature of ANTLR to produce XML file from any grammar
 
 Example:
 
 Exists  
cpp.g
sql.g
php.g
 
 We add into that .g   or into  antlr -switch
output=xml
 
 and 
 antlr  putput=xml  cpp.g
 
 Will produce   cpp.g.xml (or sql.g.xml,  php.g.xml )
 
 Which will contain language from .g expressed in XML format...
 And may be reverse task XML to .g
 
 Strange task?   :)   I know ...

What is the goal?
Ter

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 32748] Re: [antlr-interest] AST rewrite

2011-06-11 Thread srinivasan karthikeyan pitchai
Thanks for sharing your input.  I am able to do some pretty complex AST 
manipulation as stated initially.  First results are very encouraging,  
I am getting an end to end translation successfully.

Regards,
Vasan

On 6/11/2011 7:31 PM, Trevor John Thompson wrote:
 The short answer is yes, you can manipulate the tree (before walking, not 
 during).
 I am using tree adapter manipulations to reorganize the AST, and then handing 
 the tree to the standard tree walker.

 The only caution is that TreeIterator depends on parent pointers. I am 
 contemplating a version that does not have this dependency, so i can base my 
 trees on BaseTree, rather than CommonTree.

 On 2011 Jun 11, at 00:53, srinivasan karthikeyan pitchai wrote:

 Hi Gurus,
 I'm a novice using ANTLR for a development project.  I am at a stage
 where I need to rewrite AST so that the transformed AST renders itself
 more easy for me to walk and emit the translation that I need.  In this
 context I've a concept question.

 In general,  can I use the *same*  tree adapter,  used by the
 InputNodeStream used by the walker,  in a java method that I code to
 restructure the tree without using the rewrite rule?  That is can I add,
 delete, replace nodes at will in the source tree?  I am looking at this
 option as I need to move up a subtree from deep down to a much higher
 level.   In particular would manipulating the source tree mess up the
 iterator used by the ANTLR AST walker  to parse the tree?


 (eg)  Just want to know if I can effect this in JAVA.   I am sure we can
 make it happen using rewrite rule.  However I want to conceptually know
 if what I desire above is a feasibility or it it a totally wrong approach.

 ^(ROOT a  b ^(ROOT c d  ^(ROOT e f g)))

 I need to restructure the tree like, say,

 ^(ROOT a  b ^(ROOT c d ) ^(ROOT e f g))

 Based on your input I need to chalk the future course of my coding.

 Thanks in advance.

 Regards,
 Vasan



 List: http://www.antlr.org/mailman/listinfo/antlr-interest
 Unsubscribe: 
 http://www.antlr.org/mailman/options/antlr-interest/your-email-address
 --
 Trevor John Thompson(425) 246-4023
 net: ti...@me.com
 Quidquid Latine dictum sit, altum videtur.


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 32749] [antlr-interest] Comments in Tcl - Lexer

2011-06-11 Thread dmp
Hello,

I'm working with Antlr to provide syntax highlight for Tcl (in
Netbeans). I have a problem with COMMENT token.
Basic version for one line comment looks like this:

COMMENT :
 '#' (options {greedy=false;} : .)* NEWLINE
;

But comment in Tcl starts only at the beginning of a line with
optional whitespace or after ; also with optional whitespace.
How can I handle this using antlr grammar and lexer?

I've already allowed to use '#' in IDs:
ID :
 ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'#')+
;

It's difficult to find simple solution because char stream provided
from Netbeans it's not full source but only parts displayed/edited. I
followed some tips from this mailing list for example:
http://wklej.org/id/544171/ but It doesn't solve my problem.

I would be grateful if someone could give me some advices.

Thanks,
dmp

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
il-antlr-interest group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.