diff options
| author | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-03-01 18:38:59 +0100 |
|---|---|---|
| committer | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-03-01 18:38:59 +0100 |
| commit | aa67c8b497c6f900147fdc2507a6279a18800e5b (patch) | |
| tree | d6d371eea39522c05299d75d7bcb215103246b62 /src/compiler.rs | |
| parent | ee514d4ca694cd6cf93307572ff2e65e1266a4b9 (diff) | |
| download | sylt-aa67c8b497c6f900147fdc2507a6279a18800e5b.tar.gz | |
ship it!!!!
Diffstat (limited to 'src/compiler.rs')
| -rw-r--r-- | src/compiler.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler.rs b/src/compiler.rs index acb29ab..5d8b2bd 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -770,6 +770,10 @@ impl<'a, 'b> Compiler { } } + fn to_namespace(&self, path: &PathBuf) -> String { + path.to_str().unwrap().strip_suffix(".sy").unwrap().to_string() + } + fn find_namespace(&self, name: &str) -> Option<&Namespace> { match self.names().get(name) { Some(Name::Namespace(path)) => Some(&self.contextes.get(path).unwrap().namespace), @@ -1047,6 +1051,7 @@ impl<'a, 'b> Compiler { if let Some(_) = self.find_namespace(&name) { self.eat(); + let mut name = name; loop { if self.eat() != Token::Dot { error!(self, "Expect '.' after namespace."); @@ -1057,6 +1062,10 @@ impl<'a, 'b> Compiler { Some(Name::Slot(slot, _)) | Some(Name::Unknown(slot, _)) => { add_op(self, block, Op::Constant(*slot)); self.call_maybe(block); + return; + } + Some(Name::Namespace(inner_name)) => { + name = self.to_namespace(&inner_name); } _ => { error!(self, "Invalid namespace field."); @@ -1065,7 +1074,6 @@ impl<'a, 'b> Compiler { } else { error!(self, "Expected fieldname after '.'."); } - return; } } |
