forked from rrevenantt/antlr4rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
csvvisitor.rs
103 lines (91 loc) · 3.05 KB
/
csvvisitor.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
#![allow(nonstandard_style)]
// Generated from CSV.g4 by ANTLR 4.8
use super::csvparser::*;
use antlr_rust::tree::{ParseTreeVisitor, ParseTreeVisitorCompat};
/**
* This interface defines a complete generic visitor for a parse tree produced
* by {@link CSVParser}.
*/
pub trait CSVVisitor<'input>: ParseTreeVisitor<'input, CSVParserContextType> {
/**
* Visit a parse tree produced by {@link CSVParser#csvFile}.
* @param ctx the parse tree
*/
fn visit_csvFile(&mut self, ctx: &CsvFileContext<'input>) {
self.visit_children(ctx)
}
/**
* Visit a parse tree produced by {@link CSVParser#hdr}.
* @param ctx the parse tree
*/
fn visit_hdr(&mut self, ctx: &HdrContext<'input>) {
self.visit_children(ctx)
}
/**
* Visit a parse tree produced by {@link CSVParser#row}.
* @param ctx the parse tree
*/
fn visit_row(&mut self, ctx: &RowContext<'input>) {
self.visit_children(ctx)
}
/**
* Visit a parse tree produced by {@link CSVParser#field}.
* @param ctx the parse tree
*/
fn visit_field(&mut self, ctx: &FieldContext<'input>) {
self.visit_children(ctx)
}
}
pub trait CSVVisitorCompat<'input>:
ParseTreeVisitorCompat<'input, Node = CSVParserContextType>
{
/**
* Visit a parse tree produced by {@link CSVParser#csvFile}.
* @param ctx the parse tree
*/
fn visit_csvFile(&mut self, ctx: &CsvFileContext<'input>) -> Self::Return {
self.visit_children(ctx)
}
/**
* Visit a parse tree produced by {@link CSVParser#hdr}.
* @param ctx the parse tree
*/
fn visit_hdr(&mut self, ctx: &HdrContext<'input>) -> Self::Return {
self.visit_children(ctx)
}
/**
* Visit a parse tree produced by {@link CSVParser#row}.
* @param ctx the parse tree
*/
fn visit_row(&mut self, ctx: &RowContext<'input>) -> Self::Return {
self.visit_children(ctx)
}
/**
* Visit a parse tree produced by {@link CSVParser#field}.
* @param ctx the parse tree
*/
fn visit_field(&mut self, ctx: &FieldContext<'input>) -> Self::Return {
self.visit_children(ctx)
}
}
impl<'input, T> CSVVisitor<'input> for T
where
T: CSVVisitorCompat<'input>,
{
fn visit_csvFile(&mut self, ctx: &CsvFileContext<'input>) {
let result = <Self as CSVVisitorCompat>::visit_csvFile(self, ctx);
*<Self as ParseTreeVisitorCompat>::temp_result(self) = result;
}
fn visit_hdr(&mut self, ctx: &HdrContext<'input>) {
let result = <Self as CSVVisitorCompat>::visit_hdr(self, ctx);
*<Self as ParseTreeVisitorCompat>::temp_result(self) = result;
}
fn visit_row(&mut self, ctx: &RowContext<'input>) {
let result = <Self as CSVVisitorCompat>::visit_row(self, ctx);
*<Self as ParseTreeVisitorCompat>::temp_result(self) = result;
}
fn visit_field(&mut self, ctx: &FieldContext<'input>) {
let result = <Self as CSVVisitorCompat>::visit_field(self, ctx);
*<Self as ParseTreeVisitorCompat>::temp_result(self) = result;
}
}