A Go Interpreter written in Python using Lark a modern parsing library for Python, with @markserver
Golang Grammar: https://golang.org/ref/spec
Lark: https://github.com/lark-parser/lark
If you want extend the project or reuse it, citate this project repository
Data types:
- Integer
- Boolean
- String
- Array Type
Arithmetic operators:
- Addition(+)
- Subtraction(-)
- Multiplication(*)
- Division (/)
Comparison Operators:
- Equal to(a == b)
- Not equal to(a != b)
- Greater than(a > b)
- Less than (a < b)
- Greater or equal to (a >= b)
- Less or equal to (a <= b)
Logical Operators:
- Logical NOT (!a)
- Logical AND (a && b)
- Logical OR (a || b)
Branching instructions:
- If Statement
- Else Statement
- Else If Statement
Loop Instructions:
- For Statement (works as While in Go)
Input Instructions:
- Keyboard input
Output Instructions:
- Print in command window
Execution methods:
- REPL mode
- Script file mode
-
Lexical error (missing or wrong symbols)
-
Syntax error:
- UnmatchedParenthesis number in statement
- MissingValue in variable declaration
-
Semantic error:
- ArrayOutOfLenght when we declare an array
- TypeDifferentError for variable type declaration
- UnsupportedOperationType for all operation of different type
- Install Python (3.9.4 our version if you have problems)
- pip install lark
REPL mode:
python main.py
Script mode:
python main.py -s (--script) script_test\test_*.go (PATH_to_file\file.go)
Debug mode (displays parse tree):
python main.py -d (--debug)
Supported both of REPL and Script mode