davidcallanan / py-myopl-code

Interpreter for the BASIC language written in Python 3
MIT License
469 stars 326 forks source link

First number's type before operator not showing #30

Open CodeElevator opened 2 years ago

CodeElevator commented 2 years ago

So I don't understand why but when I started to do some errors it gave me that: Error:

Traceback (most recent call last):
  File "c:\Users\..\Desktop\Real\shell.py", line 6, in <module>
    if error: print(error.as_string())
  File "c:\Users\..\Desktop\Real\basic.py", line 10, in as_string
    res += f'File {self.pos_start.fn}, line {self.pos_start.ln + 1}'
AttributeError: 'IllegalChar' object has no attribute 'pos_start'
class Error:
    def __init__(self, pos_start, pos_end,error, error_desc):
        self.start = pos_start
        self.end = pos_end
        self.error = error
        self.desc = error_desc
    def as_string(self):
        res = f'{self.error}: {self.desc}'
        res += f'File {self.pos_start.fn}, line {self.pos_start.ln + 1}'
        return res

class IllegalChar(Error):
    def __init__(self, pos_start, pos_end, desc):
        super().__init__(pos_start, pos_end, 'Illegal Character', desc)
CodeElevator commented 2 years ago

sorry fixed..

CodeElevator commented 2 years ago

I'm reopening this issue because: When it shows the type of numbers, parentheses etc.. it doesn't show the FIRST number's type..

BluTen commented 2 years ago

Code?

CodeElevator commented 2 years ago

The exact same code @BluTen