I'm trying to make a TreeWalker for a tree like this: input: int x = 3 output AST: ^(VARDEF int x 3)
My parser works just fine and also generates an AST like shown above, but whenever I want to resolve anything from the AST, like with $variableType.text, there is allways a NullReferenceException in the generated C# 2.0 TreeWalker. My TreeWalker: tree grammar SGLTreeWalker; options { tokenVocab = SGL; language = 'CSharp2'; } [...] compilationUnit : (statement)+ ; statement : variableDefinitionList ; variableDefinitionList : ^(VARDEF variableType variableName expression) { Console.WriteLine($variableType.text); } ; The problematic generated part looks like this: Match(input, Token.UP, null); Console.WriteLine(((variableType1 != null) ? input.TokenStream.ToString( input.TreeAdaptor.GetTokenStartIndex(variableType1.Start), input.TreeAdaptor.GetTokenStopIndex(variableType1.Start)) : null)); It turns out that input.TokenStream is null so it throws the NullReferenceException. I read that this can happen if the used TreeNodeStream isn't buffered, but I used the CommonTreeNodeStream so it should be buffered I think. Any idea on what's going wrong? 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.