Sha256: e322c0e7a4d2b499092402adc417ab676b0e17e2e7d5e4758ce605b3a3063f5e
Contents?: true
Size: 849 Bytes
Versions: 1
Compression:
Stored size: 849 Bytes
Contents
# 已完成 module Antlr4ruby class ParseTreeWalker DEFAULT = ParseTreeWalker.new def walk(listener, tree) if tree.instance_of?(ErrorNode) listener.visit_error_node(tree) return elsif tree.instance_of?(TerminalNode) listener.visit_terminal(tree) return end enter_rule(listener, tree) n = tree.get_child_count n.times do |i| walk(listener, tree.get_child(i)) end exit_rule(listener, tree) end protected def enter_rule(listener, rule) ctx = rule.get_rule_context listener.enter_every_rule(ctx) ctx.enter_rule(listener) end def exit_rule(listener, rule) ctx = rule.get_rule_context listener.exit_every_rule(ctx) ctx.exit_rule(listener) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
antlr4ruby-0.1.0 | lib/antlr4ruby/tree/parse_tree_walker.rb |