From 30676722a304f206fab4bed6870b1f21bb7a4c6a Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 7 Jan 2019 13:00:37 -0800 Subject: [PATCH] Transition to edition 2018 --- schala-lang/language/Cargo.toml | 1 + schala-lang/language/src/ast.rs | 2 +- schala-lang/language/src/builtin.rs | 2 +- schala-lang/language/src/eval.rs | 20 ++++++++++---------- schala-lang/language/src/lib.rs | 2 +- schala-lang/language/src/parsing.rs | 20 ++++++++++---------- schala-lang/language/src/reduced_ast.rs | 12 ++++++------ schala-lang/language/src/symbol_table.rs | 4 ++-- schala-lang/language/src/typechecking.rs | 8 ++++---- 9 files changed, 36 insertions(+), 35 deletions(-) diff --git a/schala-lang/language/Cargo.toml b/schala-lang/language/Cargo.toml index 9c891ad..ea09ac1 100644 --- a/schala-lang/language/Cargo.toml +++ b/schala-lang/language/Cargo.toml @@ -2,6 +2,7 @@ name = "schala-lang" version = "0.1.0" authors = ["greg "] +edition = "2018" [dependencies] itertools = "0.5.8" diff --git a/schala-lang/language/src/ast.rs b/schala-lang/language/src/ast.rs index 9563387..32b2ae7 100644 --- a/schala-lang/language/src/ast.rs +++ b/schala-lang/language/src/ast.rs @@ -1,7 +1,7 @@ use std::rc::Rc; use std::convert::From; -use builtin::{BinOp, PrefixOp}; +use crate::builtin::{BinOp, PrefixOp}; #[derive(Clone, Debug, PartialEq)] pub struct Node { diff --git a/schala-lang/language/src/builtin.rs b/schala-lang/language/src/builtin.rs index b0a7e96..cfc6405 100644 --- a/schala-lang/language/src/builtin.rs +++ b/schala-lang/language/src/builtin.rs @@ -2,7 +2,7 @@ use std::rc::Rc; use std::collections::HashMap; use std::fmt; -use tokenizing::TokenKind; +use crate::tokenizing::TokenKind; use self::BuiltinTypeSpecifier::*; use self::BuiltinTConst::*; diff --git a/schala-lang/language/src/eval.rs b/schala-lang/language/src/eval.rs index 7a89823..f79a40b 100644 --- a/schala-lang/language/src/eval.rs +++ b/schala-lang/language/src/eval.rs @@ -6,9 +6,9 @@ use std::io; use itertools::Itertools; -use util::ScopeStack; -use reduced_ast::{BoundVars, ReducedAST, Stmt, Expr, Lit, Func, Alternative, Subpattern}; -use symbol_table::{SymbolSpec, Symbol, SymbolTable}; +use crate::util::ScopeStack; +use crate::reduced_ast::{BoundVars, ReducedAST, Stmt, Expr, Lit, Func, Alternative, Subpattern}; +use crate::symbol_table::{SymbolSpec, Symbol, SymbolTable}; pub struct State<'a> { values: ScopeStack<'a, Rc, ValueEntry>, @@ -86,7 +86,7 @@ impl Node { } fn is_true(&self) -> bool { match self { - Node::Expr(Expr::Lit(::reduced_ast::Lit::Bool(true))) => true, + Node::Expr(Expr::Lit(crate::reduced_ast::Lit::Bool(true))) => true, _ => false, } } @@ -497,14 +497,14 @@ mod eval_tests { use std::cell::RefCell; use std::rc::Rc; - use tokenizing::{Token, tokenize}; - use ::parsing::ParseResult; - use ::ast::AST; - use symbol_table::SymbolTable; - use eval::State; + use crate::tokenizing::{Token, tokenize}; + use crate::parsing::ParseResult; + use crate::ast::AST; + use crate::symbol_table::SymbolTable; + use crate::eval::State; fn parse(tokens: Vec) -> ParseResult { - let mut parser = ::parsing::Parser::new(tokens); + let mut parser = crate::parsing::Parser::new(tokens); parser.parse() } diff --git a/schala-lang/language/src/lib.rs b/schala-lang/language/src/lib.rs index 8d0bdd6..ffbd440 100644 --- a/schala-lang/language/src/lib.rs +++ b/schala-lang/language/src/lib.rs @@ -110,7 +110,7 @@ fn tokenizing(input: &str, _handle: &mut Schala, comp: Option<&mut UnfinishedCom } fn parsing(input: Vec, handle: &mut Schala, comp: Option<&mut UnfinishedComputation>) -> Result { - use parsing::Parser; + use crate::parsing::Parser; let mut parser = match handle.active_parser.take() { None => Parser::new(input), diff --git a/schala-lang/language/src/parsing.rs b/schala-lang/language/src/parsing.rs index 54546d7..484295c 100644 --- a/schala-lang/language/src/parsing.rs +++ b/schala-lang/language/src/parsing.rs @@ -2,13 +2,13 @@ use std::rc::Rc; use std::iter::Peekable; use std::vec::IntoIter; -use tokenizing::*; -use tokenizing::Kw::*; -use tokenizing::TokenKind::*; +use crate::tokenizing::*; +use crate::tokenizing::Kw::*; +use crate::tokenizing::TokenKind::*; -use ast::*; +use crate::ast::*; -use builtin::{BinOp, PrefixOp}; +use crate::builtin::{BinOp, PrefixOp}; #[derive(Debug)] pub struct ParseError { @@ -1126,8 +1126,8 @@ mod parse_tests { use ::std::rc::Rc; use super::tokenize; use super::ParseResult; - use builtin::{PrefixOp, BinOp}; - use ast::{AST, Node, Expression, Statement, IfExpressionBody, Discriminator, Pattern, PatternLiteral, TypeBody, Enumerator, ForBody}; + use crate::builtin::{PrefixOp, BinOp}; + use crate::ast::{AST, Node, Expression, Statement, IfExpressionBody, Discriminator, Pattern, PatternLiteral, TypeBody, Enumerator, ForBody}; use super::Statement::*; use super::Declaration::*; use super::Signature; @@ -1138,7 +1138,7 @@ mod parse_tests { use super::ForBody::*; fn parse(input: &str) -> ParseResult { - let tokens: Vec<::tokenizing::Token> = tokenize(input); + let tokens: Vec = tokenize(input); let mut parser = super::Parser::new(tokens); parser.parse() } @@ -1169,7 +1169,7 @@ mod parse_tests { ($expr_type:expr) => { Expression($expr_type, None) }; (s $expr_text:expr) => { { - let tokens: Vec<::tokenizing::Token> = tokenize($expr_text); + let tokens: Vec = tokenize($expr_text); let mut parser = super::Parser::new(tokens); parser.expression().unwrap() } @@ -1188,7 +1188,7 @@ mod parse_tests { ($op:expr, $lhs:expr, $rhs:expr) => { Node::new(Statement::ExpressionStatement(ex!(binexp!($op, $lhs, $rhs)))) }; (s $statement_text:expr) => { { - let tokens: Vec<::tokenizing::Token> = tokenize($statement_text); + let tokens: Vec = tokenize($statement_text); let mut parser = super::Parser::new(tokens); Node::new(parser.statement().unwrap()) } diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index 854b353..5b164c8 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -1,8 +1,8 @@ use std::rc::Rc; -use ast::*; -use symbol_table::{Symbol, SymbolSpec, SymbolTable}; -use builtin::{BinOp, PrefixOp}; +use crate::ast::*; +use crate::symbol_table::{Symbol, SymbolSpec, SymbolTable}; +use crate::builtin::{BinOp, PrefixOp}; #[derive(Debug)] pub struct ReducedAST(pub Vec); @@ -106,7 +106,7 @@ impl AST { impl Statement { fn reduce(&self, symbol_table: &SymbolTable) -> Stmt { - use ast::Statement::*; + use crate::ast::Statement::*; match self { ExpressionStatement(expr) => Stmt::Expr(expr.node().reduce(symbol_table)), Declaration(decl) => decl.reduce(symbol_table), @@ -120,7 +120,7 @@ fn reduce_block(block: &Block, symbol_table: &SymbolTable) -> Vec { impl Expression { fn reduce(&self, symbol_table: &SymbolTable) -> Expr { - use ast::ExpressionType::*; + use crate::ast::ExpressionType::*; let ref input = self.0; match input { NatLiteral(n) => Expr::Lit(Lit::Nat(*n)), @@ -356,7 +356,7 @@ impl PatternLiteral { impl Declaration { fn reduce(&self, symbol_table: &SymbolTable) -> Stmt { use self::Declaration::*; - use ::ast::Signature; + use crate::ast::Signature; match self { Binding {name, constant, expr } => Stmt::Binding { name: name.clone(), constant: *constant, expr: expr.reduce(symbol_table) }, FuncDecl(Signature { name, params, .. }, statements) => Stmt::PreBinding { diff --git a/schala-lang/language/src/symbol_table.rs b/schala-lang/language/src/symbol_table.rs index 7f2cedc..86fdbc0 100644 --- a/schala-lang/language/src/symbol_table.rs +++ b/schala-lang/language/src/symbol_table.rs @@ -3,8 +3,8 @@ use std::rc::Rc; use std::fmt; use std::fmt::Write; -use ast; -use typechecking::TypeName; +use crate::ast; +use crate::typechecking::TypeName; //cf. p. 150 or so of Language Implementation Patterns pub struct SymbolTable { diff --git a/schala-lang/language/src/typechecking.rs b/schala-lang/language/src/typechecking.rs index c493735..df47e87 100644 --- a/schala-lang/language/src/typechecking.rs +++ b/schala-lang/language/src/typechecking.rs @@ -1,7 +1,7 @@ use std::rc::Rc; -use ast::*; -use util::ScopeStack; +use crate::ast::*; +use crate::util::ScopeStack; pub type TypeName = Rc; @@ -229,8 +229,8 @@ mod tests { use super::*; fn parse(input: &str) -> AST { - let tokens: Vec<::tokenizing::Token> = ::tokenizing::tokenize(input); - let mut parser = ::parsing::Parser::new(tokens); + let tokens: Vec = crate::tokenizing::tokenize(input); + let mut parser = crate::parsing::Parser::new(tokens); parser.parse().unwrap() }