Skip to content

Commit

Permalink
Merge branch 'fix/error_messages' into 'dev'
Browse files Browse the repository at this point in the history
Showing full error messages in the editor tooltips again

See merge request es/lehre/rechnerarchitektur/architecture-simulator!25
  • Loading branch information
epkRichi committed Dec 6, 2023
2 parents e4177a9 + 4deeb5e commit 27119f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
16 changes: 8 additions & 8 deletions architecture_simulator/isa/parser_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ParserSyntaxException(ParserException):
"""A syntax exception that can be raised if the tokenization fails."""

def __repr__(self) -> str:
return f"There was a syntax error in line {self.line_number}: {self.line}"
return f"Syntax error in line {self.line_number}"


@dataclass
Expand All @@ -24,15 +24,15 @@ class ParserLabelException(ParserException):
label: str

def __repr__(self) -> str:
return f"Label '{self.label}' does not exist in line {self.line_number}: {self.line}"
return f"Label '{self.label}' in line {self.line_number} does not exist."


@dataclass
class ParserOddImmediateException(ParserException):
"""An exception that can be raised when an immediate value has to be even, because it will be used to modify the program counter."""

def __repr__(self) -> str:
return f"Immediate has to be even in line {self.line_number}: {self.line}"
return f"Immediate in line {self.line_number} has to be even."


@dataclass
Expand All @@ -42,23 +42,23 @@ class DuplicateLabelException(ParserException):
label: str

def __repr__(self) -> str:
return f"Label '{self.label}' in line {self.line_number}: '{self.line}' has already been declared before."
return f"Label '{self.label}' in line {self.line_number} has already been declared before."


@dataclass
class ParserDirectiveException(ParserException):
"""An exception that can be raised when an illegal directive is used."""

def __repr__(self) -> str:
return f"Illegal directive in line {self.line_number}: {self.line}"
return f"Illegal directive in line {self.line_number}."


@dataclass
class ParserDataSyntaxException(ParserException):
"""An exception that can be raised when syntax inside a data segment is incorrect."""

def __repr__(self) -> str:
return f"Syntax error in .data segment in line {self.line_number}: {self.line}"
return f"Syntax error in .data segment in line {self.line_number}."


@dataclass
Expand All @@ -68,7 +68,7 @@ class ParserDataDuplicateException(ParserException):
name: str

def __repr__(self) -> str:
return f"Redefinition of variable {self.name} in line {self.line_number}: {self.line}"
return f"Redefinition of variable '{self.name}' in line {self.line_number}."


@dataclass
Expand All @@ -78,7 +78,7 @@ class ParserVariableException(ParserException):
name: str

def __repr__(self) -> str:
return f"Variable {self.name} is not defined in line {self.line_number}: {self.line}"
return f"Variable '{self.name}' in line {self.line_number} is not defined."


@dataclass
Expand Down
3 changes: 1 addition & 2 deletions webgui/js/archsim.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,12 @@ const archsim_js = {
str.toString = function () {
return this.str;
};
output_str = `Syntax Error in line ${position}`;
var error_description = {
hint: function () {
return {
from: position,
to: position,
list: [output_str, ""],
list: [str.str, ""],
};
},
customKeys: {
Expand Down

0 comments on commit 27119f3

Please sign in to comment.