Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

CircleShift/tnsl-parse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tnsl-parse

The tokenizer for the TNSL Language. Written in Go for the moment.

The goal is to get this part written, and then write a backend for any arch (x86, arm, risc-v, etc.). After that, work can begin on the real parser/compiler which will be written in native TNSL

interpreter

This project was originally supposed to form a go based compiler for the language, but in the interest of time, it seems more efficient to build an interpreter instead so we can work on the TNSL based compiler sooner.

To build both for linux:

./gobuild.sh linux

To build just one:

./gobuild.sh linux <tint / parse>

Binaries will be dumped in the "build" folder.

Status

Parser: sorta works sometimes (subtext: AST generater is at least a little broken, but works for at least some use cases)
Interpreter: working (sorta)

TODO

THERE ARE PROBABLY MANY BUGS IN THIS CODE AS I HAVE NOT CREATED ANY COMPREHENSIVE TESTING

USE AT YOUR OWN RISK

What (seems to) work

  • Variable definition
  • Array definition
  • Struct definition
  • Control flow blocks (if and loop specifically)
  • Function Calls
  • Getting struct members
  • Array indexing
  • else blocks
  • File IO
  • Print statements
  • Appending to arrays [array variable].append( [value] )

Usage

Once you have built the parser, it can be invoked in the build folder with ./parse. The cli options are as follows:

  • -writelevel <0, 1, or 2> tells the parser at what stage it should stop parsing and output a file.

    • 0 will output the list of tokens generated by the tokenizer.
    • 1 will output the Abstract Syntax Tree as generated by the parser.
    • 2 will output a "virtual program". This is what the interpreter acts on.
    • The default value is 1
  • -in <file> tells the parser what file to parse. This is the only manditory option.

  • -out <file> tells the parser where to write the data. The default is out.tnt.

The interpreter can be invoked in the build folder with ./tint. The cli options are as follows:

  • -in <path to file> Tells the interpreter what file to interpret. This is the only manditory option.

  • -flags <quoted list of arguments> Arguments to pass to the interpreted program. Should be enclosed in quotes if you use multiple arguments.

Other notes

With some of the code I've written, I'm kinda supprised that this even compiles.

tint is short for Tnsl INTerpreter