[antlr-interest] iterating trees and maps

Torsten Curdt tcurdt at vafer.org
Thu Oct 9 02:56:18 PDT 2008


Hey there,

Hope this is the right mailing list for stringtemplate questions.  
(Wasn't obvious from the site)

I have some trouble figuring out how to output tree like structures  
and maps with stringtemplate. Could not find an example for it.

Let's say I have

     Map<Integer, String> map = new HashMap<Integer, String();
     map.put(1, "test1");
     map.put(2, "test2")

While I accessing the values for the keys should be no problem - how  
do I iterate over all the keys to display the corresponding value?
This obviously does not work.

		    <map:{ m |
		
		      <m.key> <m.value>
		
		    }; separator="\n">

Another problem. Again iteration:

     public interface Node {
       Node getParent();
     }

How would I iterate this list? What if was a tree?

cheers
--
Torsten


More information about the antlr-interest mailing list