Skip to content
← Back

src/syntax/parsers/identifiers/qualified.ghul

1
namespace Syntax.Parsers.Identifiers is
2
use IO.Std;
3
4
5
use Source;
6
7
class QUALIFIED(): Base[Trees.Identifiers.Identifier] is
8
description: string => "qualified identifier";
9
10
super();
11
12
parse(context: CONTEXT) -> Trees.Identifiers.Identifier? is
13
let start = context.location;
14
15
if context.expect_token(Lexical.TOKEN.IDENTIFIER, syntax_error_message) then
16
let name = context.current.value_string;
17
let result mut = Trees.Identifiers.Identifier(context.location, name);
18
19
context.next_token();
20
21
while context.current.token == Lexical.TOKEN.DOT do
22
let completion_target_start = context.location;
23
24
context.next_token();
25
if context.expect_token(Lexical.TOKEN.IDENTIFIER, syntax_error_message) then
26
result =
27
Trees.Identifiers.QUALIFIED(
28
start::context.location,
29
result,
30
context.current.value_string,
31
completion_target_start::context.location,
32
context.location
33
);
34
35
context.next_token();
36
else
37
result =
38
Trees.Identifiers.QUALIFIED(
39
start::context.location,
40
result,
41
null,
42
completion_target_start::context.location,
43
context.location
44
);
45
46
result.poison();
47
48
return result;
49
fi
50
od
51
52
return result;
53
fi
54
return null;
55
si
56
si
57
si