Skip to content

dxtrity/Turtle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐢 Turtle

Turtle is a tiny little language. It has a lexer, (semi-working) parser and an 'evaluator' for parsing mathematical expressions.

Basics

Turtle has little to no functionality. It's a barebones interpreter for maths. That's it. It does support: addition, subtraction, multiplication and division. It does also support variables. Here's how it looks like:

1 + 1           // addition
10 - 5          // subtraction
10 / 2          // division
2 * 6           // multiplication

a = 5           // declare variables
b = 10          // can be any word letter etc.

5 + a           // use variable

5 + a - b + 6   // complex expression

Language Implementation

Basic Functionality

  • Addition
  • Subtraction
  • Multiplication
  • Division
  • Basic Variables
  • Variable Expressions
  • Parentheses

Extended Functionality

  • Variable Mutability
  • Loops

Known Issues

There is a lot of issue with the interpreter at the moment. Such as:

Variable Mutability
This isn't implemented. You can't reassign variables.

Variable Expressions
Can't use mathematical expressions on just variables x + b returns an error.

Any type of Parentheses Operations
They just don't work.

Installation

To install and build this you will need to install the latest version of Go. The repo has a build script for Windows PowerShell as it is my primary shell. I will add a build script for Linux and Mac in the future if I do anything with this.

  1. Firstly, clone the repo via:
git clone https://github.com/dxtrity/Turtle.git .
  1. Then run:
./build.ps1
  1. Finally, run this script:
./test.ps1

And if all goes well. You should be fine. I hope.

Usage

The build.ps1 script builds the executable inside of the build folder. Make sure that you have a test.tl in that folder for running and testing expressions. The test.ps1 script just runs the executable with the correct file. Feel free to edit these to your liking.

About

A very simple lexer, parser and evaluator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published