✏️ Scripting language for Haxe
Haxe
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
tests
.gitignore
ChopChop.hxproj
LICENSE.md
README.md
build_cpp.hxml
build_flash.hxml
sample.chop

README.md

About

ChopChop script is a scripting language for Haxe. It can interface with Haxe code using runtime reflection.

Usage

var script:String = sys.io.File.getContent(path);
var lexer:ScriptLexer = new ScriptLexer(script);
var parser:ScriptParser = new ScriptParser(lexer);
var interp:ScriptInterp = new ScriptInterp();
trace(interp.interpret(parser.parse()));

For your own purposes you only need the src/script directory. This project also builds into an interpreter with the following usage:

Usage: ChopChop Interpreter
[source] -> the file to interpret -> expects: [path]
-[test] (-t) -> run tests and exit -> expects: []
ex: chopchop.exe test.cpcp
ex: chopchop.exe -t

You can download a pre-compiled version: https://github.com/Ohmnivore/ChopChopScript/releases

The language syntax is illustrated in the test suite directory (tests).

TODO

  • import functions from other chop scripts
  • enums
  • resolve packages for classes: new script.ast.AST("", []);
  • more robust syntax error reporting (match->[throw error if not expected token] instead of consume)
  • turn inNest into an inObject bool

Notes

  • enums are WIP
  • Do while loop syntax: do while (CONDITION) {STATEMENTS}
  • No ++ or -- operator
  • No shorthand blocks: if (true) x = 10;
  • No type checking
  • No ... operator aka no for (0...10) style loops
  • No class definitions
  • No ternary operator (?:)
  • No string interpolation
  • No array or iterator comprehension (aka [while (i < 10) i++] && for (while (i < 10) i++))
  • No conditional compilation
  • No macros
  • No switches
  • No pattern matching
  • No need for type casting

References