exceptions module
Error handling.
Used in the Logic Simulator project. Mainly used by the parser.
- class exceptions.Errors
Bases:
object
Collect and handle errors found while parsing circuit descriptions.
- add_error(error: exceptions.ParseBaseException, show_end_of_word: bool, show_cursor=True, parse_entry_func_name='parse_network', base_depth=2) None
Add an error to the error list.
- Parameters
error (ParseBaseException) – The error instance
show_end_of_word (bool) – Set caret sign to the end or beginning of symbol
show_cursor (bool) – Show caret sign or not
parse_entry_func_name (str) – The name of the top level parse function
base_depth – Extra stack depth added on top of the top level parse function, by error handling functions.
- print_error_messages(names: names.Names, scanner: Scanner) None
Pretty print all error messages.
- class exceptions.ParseBaseException(description=None, end_of_word=False, show_cursor=True)
Bases:
object
Base parse exception.
- description: Union[None, str]
Error description
- depth
The stack depth where the error is thrown
- Type
int
- explain(names: names.Names, scanner: Scanner, show_depth=True) str
Return an explanation of the error.
If show_depth is True, the error message will be indented according to the stack depth of the function that throws the error.
- message = 'Base parse exception'
- class exceptions.ParseBaseExceptionMeta(classname, bases, dictionary)
Bases:
type
Metaclass create ParseBaseException classes.
This allows default message to be defined using the doc string, simplify the code.
- class exceptions.SemanticErrors
Bases:
object
Different types of semantic errors.
- class ConnectInToIn(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Attempting to connect input pin to input pin.
- message = 'Attempting to connect input pin to input pin'
- class ConnectOutToOut(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Attempting to connect output pin to output pin.
- message = 'Attempting to connect output pin to output pin'
- class FloatingInput(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Floating input.
- message = 'Floating input'
- class InvalidAndParam(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Invalid number of inputs for the gate.
- message = 'Invalid number of inputs for the gate'
- class InvalidClockParam(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Invalid clock period.
- message = 'Invalid clock period'
- class MonitorInputPin(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Attempting to monitor an input pin.
- message = 'Attempting to monitor an input pin'
- class MonitorSamePin(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Warning: duplicate monitor pin.
- message = 'Warning: duplicate monitor pin'
- class MultipleConnections(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Attempting to connect multiple pins to a single pin.
- message = 'Attempting to connect multiple pins to a single pin'
- class NameClash(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
NameClash.
- message = 'NameClash'
- class UndefinedDevice(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Undefined device name.
- message = 'Undefined device name'
- class UndefinedInPin(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Undefined input pin.
- message = 'Undefined input pin'
- class UndefinedOutPin(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Undefined output pin.
- message = 'Undefined output pin'
- class exceptions.SyntaxErrors
Bases:
object
Different types of syntax errors.
- class InvalidSwitchParam(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Invalid parameter for SWITCH device.
- message = 'Invalid parameter for SWITCH device'
- class MissingParam(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Missing parameter for device type.
- message = 'Missing parameter for device type'
- class MissingSemicolon(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Missing ‘;’ at the end of statement.
- message = "Missing ';' at the end of statement"
- class NoConnections(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
No connections found.
- message = 'No connections found'
- class NoDevices(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
No devices found.
- message = 'No devices found'
- class NoMonitors(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
No monitor pins found.
- message = 'No monitor pins found'
- class UnexpectedEOF(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Unexpected end of file.
- message = 'Unexpected end of file'
- class UnexpectedParam(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Unexpected parameter for device type.
- message = 'Unexpected parameter for device type'
- class UnexpectedToken(description=None, end_of_word=False, show_cursor=True)
Bases:
exceptions.ParseBaseException
Unexpected token.
- message = 'Unexpected token'