DisabledMallis / 84Script

A programming language that compiles to a TI-Basic program

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

84Script

A C-like programming language that compiles to TI-BASIC

Discord

Why

Idk why not, seems like a neat hobby project

Roadmap

Current progress of the project, shows what is currently done and what needs to be done.

Key: βœ… - Completed πŸ”„ - In progress ❌ - Incomplete

πŸ”„ - TI-Basic
	βœ… - 8xp file reading/generation
	βœ… - Ti token compilation
	βœ… - Ti token decompilation (for debugging)
	πŸ”„ - Complete Ti token enum
πŸ”„ - 84Script
	πŸ”„ - Antlr
		πŸ”„ - Complete antlr grammar for 84Script
		βœ… - Java code generation
	πŸ”„ - Compilation
		πŸ”„ - EFSCompiler.java
		βœ… - EFS Statement Block
		πŸ”„ - EFS Script Block
		πŸ”„ - Include other files
		πŸ”„ - Functions
			βœ… - Function parsing
			βœ… - Function defining
			βœ… - Function compiling
			βœ… - Function calling
		πŸ”„ - Expressions
			βœ… - Bracket expressions "(<expression>)"
			βœ… - Identifier expression
			βœ… - Number expression
			βœ… - Constant expression (pi, e, ...)
			βœ… - Boolean expression
				βœ… - True
				βœ… - False
				βœ… - Greater than
				βœ… - Less than
				βœ… - Equal to
				βœ… - Not equal
				βœ… - Greater than or equal to
				βœ… - Less than or equal to
			❌ - Text expression
			βœ… - Add expression
			βœ… - Subtract expression
			βœ… - Multiplication expression
			βœ… - Division expression
			βœ… - Method call expression
		πŸ”„ - Statements
			βœ… - Assign statement
			βœ… - Add assign statement
			βœ… - Subtract assign statement
			βœ… - Multiply assign statement
			βœ… - Divide assign statement
			βœ… - Increment statement
			βœ… - Decrement statement
			βœ… - If statement
			❌ - While statement
			βœ… - Var statement
			βœ… - Return statement
			πŸ”„ - TiBasic statement
				πŸ”„ - TiBasic grammar
				βœ… - TiBasic parser & lexer (Antlr generated)
				πŸ”„ - TiBasic compiler
	❌ - STIL (Standard TI Library)
	βœ… - 8xp from 84Script generation
		βœ… - File checksum

Using 84Script

84Script is quite simple to write code with, much like how TI-Basic itself is. If you're already farmiliar with a language such as Python, C, Java, etc. using 84Script should be quite simple.

Functions

Functions can be made using the def keyword, similarly to Python. Parameters are only accessible to the current function. They may be passed down to other functions as well. Example:

def Add(numA, numB)
{
    return numA + numB;
}

Multiple files

You can include multiple files using 84Script.

include: STIL.efs
include: anotherFile.efs

Inline Ti-Basic

Much like C++ inline assembly, you can use inline Ti-Basic. This feature will not be well supported though, and will mostly be used for creating a standard library for 84Script.

def display(myText)
{
	__tibasic {
		Disp myText;
	}
}

Inline assembly

Ti calculators have the ability to run assembly code, I would like to implement some kind of inline assembly at some point. Unfortunately, as far as I'm aware, modern firmwares are restricted from the use of assembly, so this feature may never come to be. If it does come to exist in the future, it will behave much like the "Inline Ti-Basic", but with a __asm block like you'd find in C++.

STIL

STIL (Standard TI Library) is an 84Script source file you can include in your code to invoke Ti-Basic in a 84Script format. For example, "display". Ti-Basic has a "Disp" token, which will display whatever variable succeeds it. Using it in STIL is as simple as a call to display(xyz) in your code. Considering the compiler isnt really done yet, don't expect much here to stay as is. Many compiler features are required for this lib to even be written.

Variables

All variables are only available in their given scope. They may be accessed and modified after their declaration, but not deleted. Keep this in mind when initializing them with repeating code. Variables are always numerical, other types of data, such as strings, are not possible for use with variables. Their numerical abilities are determined by the calculator's settings. If the calculator is in "Real" mode, only real numbers can be stored. Function calls create copies of the variables in each call, meaning recursive calls could fill the parameter stack (L2) with multiple of the same variables potentially taking up more memory than needed. In many cases, loops will be preferable to recursive calls. Variables can be defined using the var keyword. Example:

var awesomeVariable = 2.33;

Generated structure

This section is about how the generated .8xp file(s) are structured programatically, and how they work. This is important for debugging your code when either you or the compiler makes a mistake.

Program registers

Going forward, use of the A-Z & List variables will be replaced in favor of the [J] matrix. The matrix will store all of the "memory" for the entire program.

  • [J](1,1) - The initialization register. Used for program initialization. Set to true after its used and reset to 0 once program execution has completed.
  • [J](1,2) - The function register. Used to determine which function is being invoked.
  • [J](1,3) - Calling register. Used to determine if a function is meant to be invoked.
  • [J](1,4) - Return register. The value a function returns.
  • [J](1,5) - The current stack "pointer", tells which column of [J] contains variables for the current context

The 1 column is reserved for the purposes mentioned above. 2 and onward will be used for variables starting from the top script scope. A new scope will be pushed on the matrix each function call.

Variables

Since lists are no longer used, the [J] matrix will hold everything the program needs.

  • [J](2->?, ?) - Holds all variables, starting with the main script scope at 2. Function calls create a new scope, push the arguments and execute the function.

Visualization

Start
Init
Func Table
Program

Its quite a simple, yet effective structure.

Limitations

84Script is limited by a number of factors, all of which are limitations of Ti-Basic.

  • Only 6 strings can be stored at a time
  • You can only concatenate strings
  • All numeric vars are restricted by calculator settings

About

A programming language that compiles to a TI-Basic program

License:GNU General Public License v3.0


Languages

Language:Java 98.4%Language:ANTLR 1.6%