コード例 #1
0
ファイル: ParseCommand.py プロジェクト: ddcc/llvm-project
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
ファイル: ParseCommand.py プロジェクト: ddcc/llvm-project
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
ファイル: ParseCommand.py プロジェクト: ddcc/llvm-project
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)