python-simple-vm icon indicating copy to clipboard operation
python-simple-vm copied to clipboard

IndexError: Unknown token NEWLINE: ''

Open VosMottor opened this issue 5 years ago • 1 comments

I guess it is caused by using mac (I'm using MacOSX High Sierra).

Hit CTRL+D or type "exit" to quit.
> 1 1 + println
IndexError: Unknown token NEWLINE: ''

VosMottor avatar Jun 11 '20 18:06 VosMottor

Same error on 3.7.3/RPI, but does not show up when i run the program on 2.x version of python. This is what i did to fix it:

In the Paser function i added 'tokenize.NEWLINE' criteria of the break rule

elif toknum in [tokenize.ENDMARKER, tokenize.NEWLINE]: break

De divide opcode is also not correct working, this my fix for that. added int() to the division

def div(self): last = self.pop() self.push(int(self.pop() / last))

janrutger avatar Aug 04 '22 16:08 janrutger