From 1146fe99d7d1ed955fbdc48d358b5fae9f15130c Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Mon, 16 Apr 2018 20:05:08 -0500 Subject: [PATCH] Add a walker for ASTs --- src/ast/mod.rs | 1 + src/ast/walk.rs | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/ast/walk.rs diff --git a/src/ast/mod.rs b/src/ast/mod.rs index 2710913..97e0623 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -16,3 +16,4 @@ #[macro_use] pub mod tree; +pub mod walk; diff --git a/src/ast/walk.rs b/src/ast/walk.rs new file mode 100644 index 0000000..b89a865 --- /dev/null +++ b/src/ast/walk.rs @@ -0,0 +1,22 @@ +// Copyright 2018 Jeremy Wall +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +use std::error; + +use ast::tree; + +pub trait Visit { + fn stmt(&self, stmt: &tree::Statement) -> Result<(), Box>; + fn expr(&self, expr: &tree::Expression) -> Result<(), Box>; + fn val(&self, expr: &tree::Value) -> Result<(), Box>; +}