T
T
toarugakusei2021-04-01 04:36:26
Python
toarugakusei, 2021-04-01 04:36:26

How to make paser written for English work?

I tried to parry the game with Nscripter on Rren'py, I found a ready-made code on github
, it works, so 606453129a582942921069.png
it replaces all Nscrirpt commands with renpy ones 60645321b23b5396798096.png, only it was written with the expectation of English and when you try to feed it a code with Russian text, it starts to swear at everything

D:\ren'py games\nscripter2renpy-master\src>python parsar.py 0.txt > script2.rpy
Traceback (most recent call last):
  File "parsar.py", line 905, in <module>
    parser.tokenize(input.read())
  File "parsar.py", line 59, in tokenize
    self.tokens = [token for token in lex.scan(content) if token is not None and token.type != "COMMENT"]
  File "parsar.py", line 59, in <listcomp>
    self.tokens = [token for token in lex.scan(content) if token is not None and token.type != "COMMENT"]
  File "D:\ren'py games\nscripter2renpy-master\src\lexer.py", line 49, in __next__
    return self.scan_next()
  File "D:\ren'py games\nscripter2renpy-master\src\lexer.py", line 74, in scan_next
    raise UnknownTokenError(self.input[self._position], self.lineno)
lexer.UnknownTokenError: Line #9866, Found token:

606455f2d70ba336628508.png
he swears at spaces, I suppose
if you try to change to
input = open(sys.argv[1], 'r', encoding = 'utf-8')
input = open(sys.argv[1], 'r', encoding='windows-1251')

then he starts to vomit
D:\ren'py games\nscripter2renpy-master\src>python parsar.py 0.txt > script2.rpy
Traceback (most recent call last):
  File "parsar.py", line 905, in <module>
    parser.tokenize(input.read())
  File "C:\Users\gama\AppData\Local\Programs\Python\Python38\lib\encodings\cp1251.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 248964: character maps to <undefined>

if you translate Cyrillic into Latin with him, then he starts swearing at the letter ''I'' 0x98 dots followed by a hyphen and everything else how can I make it work with Russian text? Thank
you in advance for your reply

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question