'lexer and Python parser

Inside the Python interpreter, which is a compiler that translates the source code into intermediate code and then interprets and executes the byte code.

But my questions before compiling and interpreting are:

If there is an unauthorized token in the code, at what stage does the syntax error related to the detection token occur? lexing or parsing

It is written in some places because the task of the lexer is to separate the signs of the language is meaningful and permissible, it gives an error at this stage.

In some places, hitting a meaningless token is considered unknown and is transferred to the next stage of parsing, where an error is taken.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source