diff options
| author | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-02-28 18:48:49 +0100 |
|---|---|---|
| committer | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-02-28 18:48:49 +0100 |
| commit | 630bd52c8d5a7d362066d8d05c88a1e76c6c81b1 (patch) | |
| tree | a0995cb61d79f5a0d337eb3b4c6d12db6920cb30 | |
| parent | 7481792dacae44a7128b3ab250e28f2e6cc9b0b2 (diff) | |
| download | sylt-630bd52c8d5a7d362066d8d05c88a1e76c6c81b1.tar.gz | |
imports!
| -rw-r--r-- | main.sy | 2 | ||||
| -rw-r--r-- | other.sy | 2 | ||||
| -rw-r--r-- | src/compiler.rs | 12 |
3 files changed, 10 insertions, 6 deletions
@@ -2,5 +2,5 @@ use other start :: fn { other.f() - print other.g() + // print other.g() } @@ -5,5 +5,5 @@ f :: fn { // answer := 42 g :: fn { - ret 42 + // ret answer } diff --git a/src/compiler.rs b/src/compiler.rs index 1d0f17b..984a666 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -581,7 +581,8 @@ impl<'a, 'b> Compiler { /// The line of the current token. fn line(&self) -> usize { if self.section().tokens.len() == 0 { - unreachable!("An error occured without a section."); + // unreachable!("An error occured without a section."); + 666666 } else { self.section().tokens[std::cmp::min(self.current_token, self.section().tokens.len() - 1)].1 } @@ -1433,17 +1434,19 @@ impl<'a, 'b> Compiler { if let Some(_) = self.find_namespace(&name) { expect!(self, Token::Dot, "Expected '.' after namespace."); if let Token::Identifier(ident) = self.eat() { + println!("{:#?}", self.find_namespace(&name)); match self.find_namespace(&name).unwrap().get(&ident) { - Some(Name::Slot(slot, _)) => { + Some(Name::Slot(slot, _)) | + Some(Name::Unknown(slot, _)) => { add_op(self, block, Op::Constant(*slot)); self.call_maybe(block); } _ => { - error!(self, "?"); + error!(self, format!("Cannot find constant '{}' in namespace '{}'.", ident, name)); } } } else { - error!(self, "?"); + error!(self, "Expected identifier after namespace."); } } else if let Some(var) = self.find_variable(&name) { self.mark_read(self.frames().len() - 1, &var); @@ -1745,6 +1748,7 @@ impl<'a, 'b> Compiler { } } + self.init_section(0); let constant = self.find_constant("start"); add_op(self, &mut block, Op::Constant(constant)); add_op(self, &mut block, Op::Call(0)); |
