To add to Michael's responses: during parsing, the AST is built bottom-up. When 
the parser builds an expression like id==id, that expression has neither 
parentExpr nor parentSymbol. In other words, both these fields are NULL. I 
think (I did not check) that these fields are set properly in parseFile() (see 
parser.cpp), specifically theProgram->block->insertAtTail(...), after the AST 
for the entire module has been built.

Vass

On 11/26/16 08:16, Tomsy Paul wrote:
> I want to do some processing with the variables in an expression. For
> example, from the expression i==j in,
>
> if i==j then writeln("yes");
>
> I want to get the lexemes i and j and also their other attributes, say
> types. I am doing something with the compiler, so I would like to know how
> I can get this from within the Expr or its derived classes. I tried a
>
> printf("%s",$2->parentSymbol->name); //Simplified grammar, if id == id
> then...
>
> from chapel.ypp, but it resulted in an internal error.
>
> PLease help.
>
>
>
> ------------------------------------------------------------------------------
>
>
>
> _______________________________________________
> Chapel-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/chapel-developers
>

------------------------------------------------------------------------------
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to