예제 #1
0
def format_undeclared_address_err(address: str, src: str, filename: str, lineno) -> CommandParseError:
    err = CommandParseError()
    err.src = src
    err.caret = '' # Don't bother trying to point to the bad address.
    err.filename = filename
    err.lineno = lineno
    err.info = f'Undeclared address: \'{address}\''
    return err
예제 #2
0
def format_parse_err(msg: str, path: str, lines: list, point: TextPoint) -> CommandParseError:
    err = CommandParseError()
    err.filename = path
    err.src = lines[point.line].rstrip()
    err.lineno = point.get_lineno()
    err.info = msg
    err.caret = '{}<r>^</>'.format(' ' * (point.char))
    return err
예제 #3
0
def format_unresolved_label_err(label: str, src: str, filename: str, lineno) -> CommandParseError:
    err = CommandParseError()
    err.src = src
    err.caret = '' # Don't bother trying to point to the bad label.
    err.filename = filename
    err.lineno = lineno
    err.info = f'Unresolved label: \'{label}\''
    return err
예제 #4
0
def add_line_label(labels, label, cmd_path, cmd_lineno):
    # Enforce unique line labels.
    if label.eval() in labels:
        err = CommandParseError()
        err.info = f'Found duplicate line label: \'{label.eval()}\''
        err.lineno = cmd_lineno
        err.filename = cmd_path
        err.src = label.raw_text
        # Don't both trying to point to it since we're only printing the raw
        # command, which isn't much text.
        err.caret = ''
        raise err
    labels[label.eval()] = label.get_line()
예제 #5
0
def add_address(addresses, address, cmd_path, cmd_lineno):
    # Enforce unique address variables.
    address_name = address.get_address_name()
    if address_name in addresses:
        err = CommandParseError()
        err.info = f'Found duplicate address: \'{address_name}\''
        err.lineno = cmd_lineno
        err.filename = cmd_path
        err.src = address.raw_text
        # Don't both trying to point to it since we're only printing the raw
        # command, which isn't much text.
        err.caret = ''
        raise err
    addresses.append(address_name)