{"id":37130525,"url":"https://github.com/HaxeFoundation/hscript","last_synced_at":"2026-01-21T18:00:52.034Z","repository":{"id":8671537,"uuid":"10328746","full_name":"HaxeFoundation/hscript","owner":"HaxeFoundation","description":"Parser and interpreter for Haxe expressions","archived":false,"fork":false,"pushed_at":"2026-01-10T15:46:10.000Z","size":391,"stargazers_count":293,"open_issues_count":17,"forks_count":141,"subscribers_count":23,"default_branch":"master","last_synced_at":"2026-01-11T03:31:46.125Z","etag":null,"topics":["haxe","interpreter","scripting-language"],"latest_commit_sha":null,"homepage":"","language":"Haxe","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HaxeFoundation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2013-05-28T05:54:21.000Z","updated_at":"2026-01-10T15:46:13.000Z","dependencies_parsed_at":"2022-09-19T06:31:29.716Z","dependency_job_id":"08ade978-f45e-4d98-bdac-b371dbd51d61","html_url":"https://github.com/HaxeFoundation/hscript","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/HaxeFoundation/hscript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaxeFoundation%2Fhscript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaxeFoundation%2Fhscript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaxeFoundation%2Fhscript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaxeFoundation%2Fhscript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HaxeFoundation","download_url":"https://codeload.github.com/HaxeFoundation/hscript/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaxeFoundation%2Fhscript/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28638491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T17:36:33.271Z","status":"ssl_error","status_checked_at":"2026-01-21T17:36:30.617Z","response_time":86,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haxe","interpreter","scripting-language"],"created_at":"2026-01-14T15:00:37.673Z","updated_at":"2026-01-21T18:00:52.018Z","avatar_url":"https://github.com/HaxeFoundation.png","language":"Haxe","readme":"hscript\r\n=======\r\n\r\nParse and evalutate Haxe expressions.\r\n\r\n\r\nIn some projects it's sometimes useful to be able to interpret some code dynamically, without recompilation.\r\n\r\nHaxe script is a complete subset of the Haxe language.\r\n\r\nIt is dynamically typed but allows all Haxe expressions apart from type (class,enum,typedef) declarations.\r\n\r\nUsage\r\n-----\r\n\r\n```haxe\r\nvar expr = \"var x = 4; 1 + 2 * x\";\r\nvar parser = new hscript.Parser();\r\nvar ast = parser.parseString(expr);\r\nvar interp = new hscript.Interp();\r\ntrace(interp.execute(ast));\r\n```\r\n\r\nIn case of a parsing error an `hscript.Expr.Error` is thrown. You can use `parser.line` to check the line number.\r\n\r\nYou can set some globaly accessible identifiers by using `interp.variables.set(\"name\",value)`\r\n\r\nExample\r\n-------\r\n\r\nHere's a small example of Haxe Script usage :\r\n```haxe\r\nvar script = \"\r\n\tvar sum = 0;\r\n\tfor( a in angles )\r\n\t\tsum += Math.cos(a);\r\n\tsum; \r\n\";\r\nvar parser = new hscript.Parser();\r\nvar program = parser.parseString(script);\r\nvar interp = new hscript.Interp();\r\ninterp.variables.set(\"Math\",Math); // share the Math class\r\ninterp.variables.set(\"angles\",[0,1,2,3]); // set the angles list\r\ntrace( interp.execute(program) ); \r\n```\r\n\r\nThis will calculate the sum of the cosines of the angles given as input.\r\n\r\nHaxe Script has not been really optimized, and it's not meant to be very fast. But it's entirely crossplatform since it's pure Haxe code (it doesn't use any platform-specific API).\r\n\r\nAdvanced Usage\r\n--------------\r\n\r\nWhen compiled with `-D hscriptPos` you will get fine error reporting at parsing time.\r\n\r\nYou can subclass `hscript.Interp` to override behaviors for `get`, `set`, `call`, `fcall` and `cnew`.\r\n\r\nYou can add more binary and unary operations to the parser by setting `opPriority`, `opRightAssoc` and `unops` content.\r\n\r\nYou can use `parser.allowJSON` to allow JSON data.\r\n\r\nYou can use `parser.allowTypes` to parse types for local vars, exceptions, function args and return types. Types are ignored by the interpreter.\r\n\r\nYou can use `parser.allowMetadata` to parse metadata before expressions on in anonymous types. Metadata are ignored by the interpreter.\r\n\r\nYou can use `new hscript.Macro(pos).convert(ast)` to convert an hscript AST to a Haxe macros one.\r\n\r\nYou can use `hscript.Checker` in order to type check and even get completion, using `haxe -xml` output for type information.\r\n\r\nLimitations\r\n-----------\r\n\r\nCompared to Haxe, limitations are :\r\n\r\n- `switch` construct is supported but not pattern matching (no variable capture, we use strict equality to compare `case` values and `switch` value)\r\n- only one variable declaration is allowed in `var`\r\n- the parser supports optional types for `var` and `function` if `allowTypes` is set, but the interpreter ignores them\r\n- you can enable per-expression position tracking by compiling with `-D hscriptPos`\r\n- you can parse some type declarations (import, class, typedef, etc.) with parseModule\r\n\r\nInstall\r\n-------\r\n\r\nIn order to install Haxe Script, use `haxelib install hscript` and compile your program with `-lib hscript`.\r\n\r\nThese are the main required files in hscript :\r\n\r\n  - `hscript.Expr` : contains enums declarations\r\n  - `hscript.Parser` : a small parser that turns a string into an expression structure (AST)\r\n  - `hscript.Interp` : a small interpreter that execute the AST and returns the latest evaluated value\r\n\r\nSome other optional files :\r\n  \r\n  - `hscript.Async` : converts Expr into asynchronous version\r\n  - `hscript.Bytes` : Expr serializer/unserializer\r\n  - `hscript.Checker` : type checking and completion for hscript Expr\r\n  - `hscript.Macro` : convert Haxe macro into hscript Expr\r\n  - `hscript.Printer` : convert hscript Expr to String\r\n  - `hscript.Tools` : utility functions (map/iter)\r\n \r\n","funding_links":[],"categories":["Haxe"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHaxeFoundation%2Fhscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHaxeFoundation%2Fhscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHaxeFoundation%2Fhscript/lists"}