source.precompile.precompile()   A
last analyzed

Complexity

Conditions 5

Size

Total Lines 19
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 15
nop 1
dl 0
loc 19
rs 9.1832
c 0
b 0
f 0
1
from source.__config__ import PREUDOMSTRUCTION
2
3
4
def precompile(source: str):
5
6
    lines = source.split('\n')
7
    # Location Counter
8
    LC = 0
9
    symbols_address = dict()
10
11
    for line in lines:
12
        strings = line.split()
13
        if strings[0][-1] == ',':
14
            symbol = strings[0][:-1]
15
            symbols_address[symbol] = str(LC)
16
        elif strings[0] == PREUDOMSTRUCTION[0]:
17
            LC = int(strings[1]) - 1
18
        elif strings[0] == PREUDOMSTRUCTION[3]:
19
            break
20
        LC += 1
21
22
    return symbols_address
23