aboutsummaryrefslogtreecommitdiffhomepage
path: root/notes/interface_parsing.txt
blob: f277fed3b0f1c0c0b269e1e07e7756881ac0da8b (plain)
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
27
28
29
30
31
32
33
34
35
36

Interface parsing
=================

Problem (arrays):
    int c = arr[0]
    [c]int arr = [3, 2, 1]
This will be tricky to parse/evaluate!

Problem (enums):
    ...

NOTE: Idents need to be BOUND first! (they could reference defs in other modules)

Solution 1:
- forbid identifier references in array types of toplevel data.
- enums...?

Solution 2: (better than 1?)
- forbid identifier references in initvals & enum values

Solution 3: (not possible?)
- Require identifier references to come in the right order??
- But how about refs to interfaces of other modules?

Solution 4:
- Allow refs, as long as they are not circular.
- Method 1:
    - Process definitions recursively, and mark them as they are processed (to avoid infinite recursion)
    - Can still cause stack overflow if there are very deep reference chains
- Method 2:
    - While the queue of defs is not empty:
        1. Mark as "started"
        2. Check if all referenced idents are defined.
            - Put any defs that are not defined first in the queue.
            - If any is already marked as "started", then report error (circular reference).
        3. If all referenced idents were defined, then process the definition.