def p_primary_this(p): 'primary : THIS' if (current_storage_kind == 'instance'): p[0] = ast.ThisExpr(p.lineno(1)) else: signal_error("'this' expression cannot be used in a static context", p.lineno(1)) p[0] = None
def p_field_access_id(p): 'field_access : ID' vname = p[1] v = current_vartable.find_in_scope(vname) if (v != None): # local variable in current scope p[0] = ast.VarExpr(v, p.lineno(1)) else: c = ast.lookup(ast.classtable, vname) if (c != None): # there is a class with this name p[0] = ast.ClassReferenceExpr(c, p.lineno(1)) else: # reference to a non-local var; assume field p[0] = ast.FieldAccessExpr(ast.ThisExpr(p.lineno(1)), vname, p.lineno(1))
def p_primary_this(p): 'primary : THIS' p[0] = ast.ThisExpr(p.lineno(1))