Welcome,This program allows users to check the syntax of code written in different programming languages. The implementation uses the Factory pattern design.
The Factory pattern is used in this program to create objects of different lexer classes based on the file
extension.
It provides an interface for creating objects, but allows subclasses to decide which class to
instantiate.
In this case, the LexerFactory class creates lexer objects based on the file extension
provided.
The program currently supports the following languages:
- Run the program.
- Enter the path of the file you want to check the syntax for. The file path should include the extension (e.g., path/to/your/file.py, .java, .cpp, .c, .cs, .css, .scss, .html, .php, .go, .rb).
- The program will check if the file type is supported. If not, an error message will be displayed.
- If the file type is supported, the program will attempt to read the file and parse the code using the appropriate lexer for the file extension.
- If the syntax is correct, a success message will be displayed.
- If there is a syntax error, an error message will be displayed along with the list of errors and the
specific line of code where the error occurred.
- ast (for parsing the code)
- pygments (for code highlighting)
- pygments.formatters.TerminalFormatter (for formatting highlighted code)
- pygments.lexers (for lexers of different programming languages)
This program only checks the syntax of the code and does not perform any kind of semantic analysis or execute the code.
Enjoy checking your code's syntax !