-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqual.cpp
More file actions
26 lines (25 loc) · 715 Bytes
/
qual.cpp
File metadata and controls
26 lines (25 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#line 498 "1_fn-gen.md"
#include "qual.h"
#include "mod.h"
Declaration::Ptr parse_qualified_ident(Lexer &l, Declaration::Ptr scope) {
if (! scope) { err(quote(scope), "scope in parse_qualified"); }
l.expect(Token::Kind::identifier);
auto name { l.representation() };
l.advance();
auto got { scope->lookup(name) };
if (! got) { err(quote(name), " not found"); }
if (auto mod { std::dynamic_pointer_cast<Module>(got) }) {
if (l.is(Token::Kind::period)) {
l.advance();
l.expect(Token::Kind::identifier);
auto name { l.representation() };
l.advance();
auto got { mod->lookup(name) };
if (! got) {
err(quote(name), " not found in ", quote(mod));
}
return got;
}
}
return got;
}