[antlr-interest] The Python target is in fact Jython target?

Tzu-Chien Chiu tzuchien.chiu at gmail.com
Thu Jun 21 02:11:51 PDT 2007


I used the C grammar downlowd from this page:

   http://www.antlr.org/grammar/list

The one posted by Terence Parr on Jul 19, 2006:

  http://www.antlr.org/grammar/1153358328744/c.g

It seems to be written for Jython. Here is the difference with
untime/Python/examples/C/C.g

42,47c41,42
< 	Set types; // only track types in order to get parser working
< }
<
< @header {
< import java.util.Set;
< import java.util.HashSet;
---
> 	types;
51,59c46,52
< 	boolean isTypeName(String name) {
< 		for (int i = Symbols_stack.size()-1; i>=0; i--) {
< 			Symbols_scope scope = (Symbols_scope)Symbols_stack.get(i);
< 			if ( scope.types.contains(name) ) {
< 				return true;
< 			}
< 		}
< 		return false;
< 	}
---
>     def isTypeName(self, name):
>         for scope in reversed(self.Symbols_stack):
>             if name in scope.types:
>                 return True
>
>         return False
>
65c58
<   $Symbols::types = new HashSet();
---
>   $Symbols::types = set()


More information about the antlr-interest mailing list