implementing double dispatch for semantic analysis