Skip to content
← Back

src/syntax/parsers/definitions/namespace.ghul

1
namespace Syntax.Parsers.Definitions is
2
use Source;
3
4
class NAMESPACE(
5
identifier_qualified_parser: Parser[Trees.Identifiers.Identifier],
6
definition_list_parser: Parser[Trees.Definitions.LIST]
7
): Base[Trees.Definitions.NAMESPACE] is
8
super();
9
10
parse(context: CONTEXT) -> Trees.Definitions.NAMESPACE? is
11
context.next_token(Lexical.TOKEN.NAMESPACE);
12
13
let start = context.location;
14
let identifier = identifier_qualified_parser.parse(context);
15
16
if
17
identifier? /\
18
(context.current.token == Lexical.TOKEN.IS \/ !identifier.is_poisoned) /\
19
context.next_token(Lexical.TOKEN.IS)
20
then
21
context.namespace_depth = context.namespace_depth + 1;
22
23
let body = definition_list_parser.parse(context)!;
24
25
context.namespace_depth = context.namespace_depth - 1;
26
27
let result =
28
Trees.Definitions.NAMESPACE(
29
start::context.location,
30
identifier,
31
body,
32
false
33
);
34
35
if !identifier.is_poisoned \/ context.current.token == Lexical.TOKEN.SI then
36
context.next_token(Lexical.TOKEN.SI);
37
fi
38
39
if identifier.is_poisoned then
40
result.poison();
41
fi
42
43
return result;
44
fi
45
return null;
46
si
47
si
48
si