aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.sy2
-rw-r--r--src/compiler.rs37
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;
}
}