hscript-typer

A simple typer for hscript.
https://github.com/lemz1/hscript-typer

To install, run:

haxelib install hscript-typer 1.6.0 

See using Haxelib in Haxelib documentation for more information.

README.md

hscript-typer

A simple static type checker for HScript.

This library provides a basic typer for HScript, enabling limited type checking and inference for scripts written using the HScript language in Haxe.

Installation

Install via haxelib:

haxelib install hscript-typer

Usage

import hscript.Parser;
import hscript.Interp;
import hscript.typer.Typer;
import hscript.typer.TypedExpr;

using hscript.typer.TypedExprTools;

class Main {
    static function main() {
        var code:String = 'var a = 12.5; var b = 5; var c = a + b;';
        var parser:Parser = new Parser();
        parser.allowTypes = true;
        var e:Expr = parser.parseString(code);
        var interp:Interp = new Interp();
        var typer:Typer = new Typer(interp);
        var te:TypedExpr = typer.type(e, code);
        trace('Successfully typed expression!: ${te.toString()}');
    }
}

Features

  • Basic type inference and checking for HScript expressions
  • Support for variable declarations, operations, conditionals, and more

Limitations

  • Type checking is limited and may not cover all Haxe language features
  • Currently no null safety

Contributing

Feel free to open issues or submit pull requests if you'd like to improve the typer or help expand its capabilities.

Contributors
lemz1
Version
1.6.0
Published
1 year ago
Dependencies
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub

⌂