Using stack-based contexts for dealing with AST states