marcelogdeandrade / PythonCompiler

Code used on "Writing your own programming language and compiler with Python" post
GNU General Public License v3.0
232 stars 53 forks source link

rply.errors.LexingError #8

Open kleo-dev opened 1 year ago

kleo-dev commented 1 year ago

specification

python version: 3.10.9 cpu: M1 os: macOS Ventura 13.1 MBA 2020

error

if I run it using the print(1) method it works. but if I try a str print("Hello, World") it gives this error: rply.errors.LexingError: (None, SourcePosition(idx=0, lineno=1, colno=1))

Full error:


  return self.pg.build()
Traceback (most recent call last):
  File "/Users/klestiselimaj/Projects/lang/main.py", line 21, in <module>
    parser.parse(tokens).eval()
  File "/Users/klestiselimaj/Library/Python/3.9/lib/python/site-packages/rply/parser.py", line 32, in parse
    lookahead = next(tokenizer)
  File "/Users/klestiselimaj/Library/Python/3.9/lib/python/site-packages/rply/lexer.py", line 62, in __next__
    return self.next()
  File "/Users/klestiselimaj/Library/Python/3.9/lib/python/site-packages/rply/lexer.py", line 58, in next
    raise LexingError(None, SourcePosition(
rply.errors.LexingError: (None, SourcePosition(idx=0, lineno=1, colno=1))```
TENTHER101 commented 3 months ago

The creator of the repo didn't add support for strings, he only added support for integers and basic mathematical equations. You could add support for them though. One year late...

Happy coding!

kleo-dev commented 3 months ago

Thanks for the reply! I'm making my own parser and lexer in rust now.