Gola is a lightweight and fun programming language inspired by simplicity and Bengali expressions. This documentation provides an overview of its syntax, usage, and functionality.
- Lightweight and interactive interpreter.
- Uses Bengali-inspired keywords and syntax.
- Supports basic arithmetic, variable assignment, and conditional execution.
- Includes interactive and file-based execution modes.
- Go programming language installed.
Run the following commands to build the interpreter for your platform:
# Build for Linux
GOOS=linux GOARCH=amd64 go build -o gola-linux-x86_64
# Build for macOS
GOOS=darwin GOARCH=amd64 go build -o gola-darwin-x86_64
-v
or--version
: Display the version of the interpreter.-h
or--help
: Display help information.
Example:
gola -v
You can execute .gola
files or use the interactive mode.
gola <file_name>.gola
Ensure the file has a .gola
extension. For example:
gola sample.gola
Run the interpreter without arguments:
gola
Type commands interactively and press Enter to execute.
- Command:
kemon achis "<message>"
- Description: Prints the specified message to the console.
Example:
kemon achis "Hello, world!"
- Command:
bol bhai <variable>
- Description: Prompts the user to input a value for the specified variable.
Example:
bol bhai x
- Command:
<variable> = <expression>
- Description: Assigns the result of an expression to a variable.
Example:
x = 10 + 5
- Command:
dyakh jodi <condition>: <command> ar nahole: <command>
- Description: Executes the first command if the condition is true; otherwise, executes the second command.
Example:
dyakh jodi x > 5: kemon achis "Greater" ar nahole: kemon achis "Smaller or Equal"
- Error Messages: The interpreter provides Bengali-inspired error messages for invalid commands or conditions, such as:
bhul hoye gelo vai check kor ekbar
(Check your syntax.)
The core interpreter structure contains:
variables
: A map to store variable values.
NewInterpreter()
: Initializes the interpreter.Execute(line string)
: Parses and executes a single line of code.evaluateExpression(tokens []string)
: Evaluates arithmetic expressions.getValue(token string)
: Retrieves a variable's value or parses integers.
Commands are executed based on the first token in a line:
kemon achis
: Print messages or variables.bol bhai
: Accept user input for a variable.dyakh jodi
: Execute conditional logic.- Assignment (
=
): Assigns values to variables.
bol bhai x
y = x + 5
dyakh jodi y > 10: kemon achis "Value is greater" ar nahole: kemon achis "Value is smaller"
Expected Output:
Enter value for x: 6
Value is greater
Welcome to Gola - Bengali Edition!
Type 'exit' to quit.
>> bol bhai x
Enter value for x: 10
>> kemon achis "x is "
>> kemon achis x
10
>> exit
Jay Shree Ram Bhai!
Feel free to contribute to this project by submitting issues or pull requests to the GitHub repository.
This project is licensed under the MIT License.