From 4b9c7e38dd4692c74477abb61b05e600c8e67476 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 18 Oct 2018 13:27:09 -0700 Subject: [PATCH] Rename TypeName -> TypeIdentifier --- schala-lang/language/src/ast.rs | 18 +++++++++--------- schala-lang/language/src/parsing.rs | 12 ++++++------ schala-lang/language/src/symbol_table.rs | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/schala-lang/language/src/ast.rs b/schala-lang/language/src/ast.rs index df34f96..b0fc91f 100644 --- a/schala-lang/language/src/ast.rs +++ b/schala-lang/language/src/ast.rs @@ -15,7 +15,7 @@ pub type Block = Vec; pub type ParamName = Rc; pub type InterfaceName = Rc; //should be a singleton I think?? -pub type FormalParam = (ParamName, Option); +pub type FormalParam = (ParamName, Option); #[derive(Debug, PartialEq, Clone)] pub enum Declaration { @@ -33,7 +33,7 @@ pub enum Declaration { expr: Expression, }, Impl { - type_name: TypeName, + type_name: TypeIdentifier, interface_name: Option, block: Vec, }, @@ -48,7 +48,7 @@ pub struct Signature { pub name: Rc, pub operator: bool, pub params: Vec, - pub type_anno: Option, + pub type_anno: Option, } #[derive(Debug, PartialEq, Clone)] @@ -57,23 +57,23 @@ pub struct TypeBody(pub Vec); #[derive(Debug, PartialEq, Clone)] pub enum Variant { UnitStruct(Rc), - TupleStruct(Rc, Vec), - Record(Rc, Vec<(Rc, TypeName)>), + TupleStruct(Rc, Vec), + Record(Rc, Vec<(Rc, TypeIdentifier)>), } #[derive(Debug, PartialEq, Clone)] -pub struct Expression(pub ExpressionType, pub Option); +pub struct Expression(pub ExpressionType, pub Option); #[derive(Debug, PartialEq, Clone)] -pub enum TypeName { - Tuple(Vec), +pub enum TypeIdentifier { + Tuple(Vec), Singleton(TypeSingletonName) } #[derive(Debug, PartialEq, Clone)] pub struct TypeSingletonName { pub name: Rc, - pub params: Vec, + pub params: Vec, } #[derive(Debug, PartialEq, Clone)] diff --git a/schala-lang/language/src/parsing.rs b/schala-lang/language/src/parsing.rs index fea8b8b..f057183 100644 --- a/schala-lang/language/src/parsing.rs +++ b/schala-lang/language/src/parsing.rs @@ -354,7 +354,7 @@ impl Parser { } }); - parse_method!(typed_identifier(&mut self) -> ParseResult<(Rc, TypeName)> { + parse_method!(typed_identifier(&mut self) -> ParseResult<(Rc, TypeIdentifier)> { let identifier = self.identifier()?; expect!(self, Colon); let type_name = self.type_name()?; @@ -441,7 +441,7 @@ impl Parser { let result = match (first, second) { (first, Some(second)) => { match first { - TypeName::Singleton(TypeSingletonName { ref name, ref params }) if params.len() == 0 => + TypeIdentifier::Singleton(TypeSingletonName { ref name, ref params }) if params.len() == 0 => Declaration::Impl { type_name: second, interface_name: Some(name.clone()), block }, _ => return ParseError::new(&format!("Invalid name for an interface")), } @@ -468,13 +468,13 @@ impl Parser { Ok(expr_body) }); - parse_method!(type_anno(&mut self) -> ParseResult { + parse_method!(type_anno(&mut self) -> ParseResult { expect!(self, Colon); self.type_name() }); - parse_method!(type_name(&mut self) -> ParseResult { - use self::TypeName::*; + parse_method!(type_name(&mut self) -> ParseResult { + use self::TypeIdentifier::*; Ok(match self.peek() { LParen => Tuple(delimited!(self, LParen, type_name, Comma, RParen)), _ => Singleton(self.type_singleton_name()?), @@ -1026,7 +1026,7 @@ mod parse_tests { use super::Statement::*; use super::Declaration::*; use super::Signature; - use super::TypeName::*; + use super::TypeIdentifier::*; use super::TypeSingletonName; use super::ExpressionType::*; use super::Variant::*; diff --git a/schala-lang/language/src/symbol_table.rs b/schala-lang/language/src/symbol_table.rs index e886fb3..ab3976b 100644 --- a/schala-lang/language/src/symbol_table.rs +++ b/schala-lang/language/src/symbol_table.rs @@ -59,7 +59,7 @@ impl SymbolTable { /* note: this adds names for *forward reference* but doesn't actually create any types. solve that problem * later */ pub fn add_top_level_symbols(&mut self, ast: &ast::AST) -> Result<(), String> { - use self::ast::{Statement, TypeName, Variant, TypeSingletonName, TypeBody}; + use self::ast::{Statement, TypeIdentifier, Variant, TypeSingletonName, TypeBody}; use self::ast::Declaration::*; for statement in ast.0.iter() { if let Statement::Declaration(decl) = statement { @@ -100,8 +100,8 @@ impl SymbolTable { }, Variant::TupleStruct(variant_name, tuple_members) => { let type_args = tuple_members.iter().map(|type_name| match type_name { - TypeName::Singleton(TypeSingletonName { name, ..}) => name.clone(), - TypeName::Tuple(_) => unimplemented!(), + TypeIdentifier::Singleton(TypeSingletonName { name, ..}) => name.clone(), + TypeIdentifier::Tuple(_) => unimplemented!(), }).collect(); let spec = SymbolSpec::DataConstructor { index,