From ee514d4ca694cd6cf93307572ff2e65e1266a4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Th=C3=B6rnros?= Date: Mon, 1 Mar 2021 18:27:47 +0100 Subject: clean it up a bit --- main.sy | 2 +- src/compiler.rs | 37 +++++++++++++++---------------------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/main.sy b/main.sy index e7c344d..96e055d 100644 --- a/main.sy +++ b/main.sy @@ -7,6 +7,6 @@ start :: fn { 42 <=> other.g() other.g() <=> 42 - other.third.print_the_third() + // other.third.print_the_third() third.print_the_third() } diff --git a/src/compiler.rs b/src/compiler.rs index 1aee642..acb29ab 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -1048,31 +1048,24 @@ impl<'a, 'b> Compiler { if let Some(_) = self.find_namespace(&name) { self.eat(); loop { - match self.peek() { - Token::Dot => { - self.eat(); - if let Token::Identifier(field) = self.eat() { - match self.find_namespace(&name).unwrap().get(&field) { - Some(Name::Slot(slot, _)) - | Some(Name::Unknown(slot, _)) => { - add_op(self, block, Op::Constant(*slot)); - self.call_maybe(block); - return; - } - _ => { - error!(self, "Invalid namespace field."); - } - } - } else { - error!(self, "Expected fieldname after '.'."); - return; + if self.eat() != Token::Dot { + error!(self, "Expect '.' after namespace."); + return; + } + if let Token::Identifier(field) = self.eat() { + match self.find_namespace(&name).unwrap().get(&field) { + Some(Name::Slot(slot, _)) | Some(Name::Unknown(slot, _)) => { + add_op(self, block, Op::Constant(*slot)); + self.call_maybe(block); + } + _ => { + error!(self, "Invalid namespace field."); } } - _ => { - error!(self, "Expect '.' after namespace."); - return; - } + } else { + error!(self, "Expected fieldname after '.'."); } + return; } } -- cgit v1.2.1