forked from rrevenantt/antlr4rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
visitorcalcvisitor.rs
111 lines (99 loc) · 3.5 KB
/
visitorcalcvisitor.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#![allow(nonstandard_style)]
// Generated from VisitorCalc.g4 by ANTLR 4.8
use super::visitorcalcparser::*;
use antlr_rust::tree::{ParseTreeVisitor, ParseTreeVisitorCompat};
/**
* This interface defines a complete generic visitor for a parse tree produced
* by {@link VisitorCalcParser}.
*/
pub trait VisitorCalcVisitor<'input>:
ParseTreeVisitor<'input, VisitorCalcParserContextType>
{
/**
* Visit a parse tree produced by {@link VisitorCalcParser#s}.
* @param ctx the parse tree
*/
fn visit_s(&mut self, ctx: &SContext<'input>) {
self.visit_children(ctx)
}
/**
* Visit a parse tree produced by the {@code add}
* labeled alternative in {@link VisitorCalcParser#expr}.
* @param ctx the parse tree
*/
fn visit_add(&mut self, ctx: &AddContext<'input>) {
self.visit_children(ctx)
}
/**
* Visit a parse tree produced by the {@code number}
* labeled alternative in {@link VisitorCalcParser#expr}.
* @param ctx the parse tree
*/
fn visit_number(&mut self, ctx: &NumberContext<'input>) {
self.visit_children(ctx)
}
/**
* Visit a parse tree produced by the {@code multiply}
* labeled alternative in {@link VisitorCalcParser#expr}.
* @param ctx the parse tree
*/
fn visit_multiply(&mut self, ctx: &MultiplyContext<'input>) {
self.visit_children(ctx)
}
}
pub trait VisitorCalcVisitorCompat<'input>:
ParseTreeVisitorCompat<'input, Node = VisitorCalcParserContextType>
{
/**
* Visit a parse tree produced by {@link VisitorCalcParser#s}.
* @param ctx the parse tree
*/
fn visit_s(&mut self, ctx: &SContext<'input>) -> Self::Return {
self.visit_children(ctx)
}
/**
* Visit a parse tree produced by the {@code add}
* labeled alternative in {@link VisitorCalcParser#expr}.
* @param ctx the parse tree
*/
fn visit_add(&mut self, ctx: &AddContext<'input>) -> Self::Return {
self.visit_children(ctx)
}
/**
* Visit a parse tree produced by the {@code number}
* labeled alternative in {@link VisitorCalcParser#expr}.
* @param ctx the parse tree
*/
fn visit_number(&mut self, ctx: &NumberContext<'input>) -> Self::Return {
self.visit_children(ctx)
}
/**
* Visit a parse tree produced by the {@code multiply}
* labeled alternative in {@link VisitorCalcParser#expr}.
* @param ctx the parse tree
*/
fn visit_multiply(&mut self, ctx: &MultiplyContext<'input>) -> Self::Return {
self.visit_children(ctx)
}
}
impl<'input, T> VisitorCalcVisitor<'input> for T
where
T: VisitorCalcVisitorCompat<'input>,
{
fn visit_s(&mut self, ctx: &SContext<'input>) {
let result = <Self as VisitorCalcVisitorCompat>::visit_s(self, ctx);
*<Self as ParseTreeVisitorCompat>::temp_result(self) = result;
}
fn visit_add(&mut self, ctx: &AddContext<'input>) {
let result = <Self as VisitorCalcVisitorCompat>::visit_add(self, ctx);
*<Self as ParseTreeVisitorCompat>::temp_result(self) = result;
}
fn visit_number(&mut self, ctx: &NumberContext<'input>) {
let result = <Self as VisitorCalcVisitorCompat>::visit_number(self, ctx);
*<Self as ParseTreeVisitorCompat>::temp_result(self) = result;
}
fn visit_multiply(&mut self, ctx: &MultiplyContext<'input>) {
let result = <Self as VisitorCalcVisitorCompat>::visit_multiply(self, ctx);
*<Self as ParseTreeVisitorCompat>::temp_result(self) = result;
}
}