davidcallanan / py-myopl-code

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

in episode 5 'AND' keyword to be '&&'. #41

Open ghost opened 1 year ago

ghost commented 1 year ago

i want my 'AND' keyword to be '&&' but whenever I use && the code pops out it as illegal: '&' BTW the code works fine when I use 'AND' as an keyword. i also tried using '\&\&' still didn't work

Sebwazhere commented 4 months ago

This is half a year late and I'm assuming you probably moved on or figured it out but it's still open so on line 14 change LETTERS to string.ascii.letters + '&' and on line 120 change the keyword 'AND' to '&&'.

foxypiratecove37350 commented 2 months ago

This is half a year late and I'm assuming you probably moved on or figured it out but it's still open so on line 14 change LETTERS to string.ascii.letters + '&' and on line 120 change the keyword 'AND' to '&&'.

I think it's not a good idea to directly change the LETTERS because it would allow for variable names such as a&a but I think it would be better to change the lexer to add a AND token and change the parser and the interpreter to use this new AND token instead of the Token(TT_KEYWORD, 'AND').