Skip to content
This repository has been archived by the owner on Dec 29, 2019. It is now read-only.

[impl-j] Visitor pattern #27

Closed
at15 opened this issue Nov 27, 2017 · 0 comments
Closed

[impl-j] Visitor pattern #27

at15 opened this issue Nov 27, 2017 · 0 comments
Assignees
Labels
Milestone

Comments

@at15
Copy link
Owner

at15 commented Nov 27, 2017

It is used when traverse ANTLR generated parse tree, also mentioned in ANTLR3 book P113 External Tree Visitor

  • it seems the accept method, although identical, need to be declared in every subclass of node
@at15 at15 self-assigned this Nov 27, 2017
@at15 at15 added this to the 0.1 milestone Nov 27, 2017
at15 added a commit that referenced this issue Nov 27, 2017
- when implementing #24, triggered #27
- seems I didn't figure out the right way to use visitor, it is not
dispatched to the right node? or I need to rename
at15 added a commit that referenced this issue Nov 27, 2017
- without override in every subclass, when accept is called, it calls
visitor.visit(this), and this is of abstract class Node, however in
visitor, visit(Node n) just calls n.accept, cause the recursion ...
at15 added a commit that referenced this issue Nov 27, 2017
- when we have Node n, and call checker.visit(n), visit(Node n) would
call n.accept(this), which is same as root.accept(checker)
@at15 at15 closed this as completed in #25 Nov 27, 2017
@at15 at15 mentioned this issue Nov 27, 2017
6 tasks
at15 added a commit that referenced this issue Nov 30, 2017
- also created a simple language SimpleBin to show how to use visitor
pattern to do type check and evaluation
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant