├── .gitignore ├── .vscode ├── launch.json └── tasks.json ├── LICENSE ├── README.md ├── assets └── expected-types.txt ├── build ├── code-builder.js ├── code-builder.js.map ├── heron-ast-rewrite.js ├── heron-ast-rewrite.js.map ├── heron-compiler.js ├── heron-compiler.js.map ├── heron-defs.js ├── heron-defs.js.map ├── heron-expr.js ├── heron-expr.js.map ├── heron-name-analysis.js ├── heron-name-analysis.js.map ├── heron-normal-form.js ├── heron-normal-form.js.map ├── heron-package.js ├── heron-package.js.map ├── heron-parser.js ├── heron-parser.js.map ├── heron-refs.js ├── heron-refs.js.map ├── heron-statement.js ├── heron-statement.js.map ├── heron-to-glsl.js ├── heron-to-glsl.js.map ├── heron-to-html.js ├── heron-to-html.js.map ├── heron-to-js.js ├── heron-to-js.js.map ├── heron-to-text.js ├── heron-to-text.js.map ├── heron-type-evaluator.js ├── heron-type-evaluator.js.map ├── heron-types.js ├── heron-types.js.map ├── js-intrinsics.js ├── js-intrinsics.js.map ├── tests.js ├── tests.js.map ├── type-parser.js ├── type-parser.js.map ├── type-system.js ├── type-system.js.map ├── utils.js └── utils.js.map ├── comparison.md ├── demo ├── demo.1.html ├── demo.html ├── js │ ├── OrbitControls.js.download │ ├── ParametricGeometries.js.download │ ├── dat.gui.min.js.download │ ├── geometry.js.download │ └── three.min.js.download ├── node_test.js ├── output.js └── sandbox │ └── shaders.html ├── history.md ├── img └── heron-source-torus.png ├── index.html ├── input ├── array.heron ├── geometry-mesh.heron ├── geometry-vector3.heron ├── intrinsics.heron ├── sandbox │ ├── color.heron │ ├── experiment-with-interfaces.txt │ ├── geometry-matrix4x4.heron │ ├── geometry-quaternion.heron │ ├── geometry-transform.heron │ ├── noise.heron │ ├── seascape.heron │ ├── simple_optimizer.py │ ├── square-cubes.heron │ └── voronoi-distances.heron └── test.heron ├── node_modules └── myna-parser │ ├── .gitattributes │ ├── .travis.yml │ ├── .vscode │ ├── launch.json │ └── tasks.json │ ├── LICENSE │ ├── dist │ └── myna.min.js │ ├── docs │ ├── Common_Myna.png │ ├── Common_Myna_Thumbnail.png │ ├── _config.yml │ ├── android-chrome-192x192.png │ ├── apple-touch-icon.png │ ├── browserconfig.xml │ ├── css │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap-theme.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── favicon.ico │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ ├── grammars │ │ ├── grammar_arithmetic.js │ │ ├── grammar_csv.js │ │ ├── grammar_glsl.js │ │ ├── grammar_heron.js │ │ ├── grammar_html_reserved_chars.js │ │ ├── grammar_json.js │ │ ├── grammar_lucene.js │ │ ├── grammar_markdown.js │ │ ├── grammar_mustache.js │ │ ├── grammar_pithy.js │ │ └── grammar_template.js │ ├── index.html │ ├── js │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ ├── ie10-viewport-bug-workaround.js │ │ └── npm.js │ ├── manifest.json │ ├── mstile-150x150.png │ ├── myna.js │ ├── myna.ts │ ├── safari-pinned-tab.svg │ └── tests │ │ ├── benchmark.js │ │ ├── glsl_printer.js │ │ ├── heron_tools.js │ │ ├── mocha_runner.js │ │ ├── myna_augment_ast.js │ │ ├── output_grammars.js │ │ ├── performance.html │ │ ├── playground.js │ │ ├── qunit-2.0.1.css │ │ ├── qunit-2.0.1.js │ │ ├── qunit.html │ │ ├── readme.md │ │ ├── rule_test_inputs.js │ │ ├── rule_tester.js │ │ ├── test_all_tools.js │ │ ├── test_arithmetic.js │ │ ├── test_browser_unpkg.html │ │ ├── test_escape_html_chars.js │ │ ├── test_glsl.js │ │ ├── test_lucene.js │ │ ├── test_markdown_to_html.js │ │ ├── test_mustache_expander.js │ │ ├── test_node.js │ │ ├── test_node_example-1.js │ │ ├── test_node_example-2.js │ │ ├── test_parser_failure.js │ │ ├── test_pithy.js │ │ ├── test_tools.js │ │ ├── test_typescript_import.js │ │ ├── test_typescript_import.js.map │ │ └── test_typescript_import.ts │ ├── grammars │ ├── grammar_arithmetic.js │ ├── grammar_csv.js │ ├── grammar_glsl.js │ ├── grammar_heron.js │ ├── grammar_html_reserved_chars.js │ ├── grammar_json.js │ ├── grammar_lucene.js │ ├── grammar_markdown.js │ ├── grammar_mustache.js │ ├── grammar_pithy.js │ └── readme.md │ ├── myna.js │ ├── myna.js.map │ ├── myna.ts │ ├── package.json │ ├── packages │ └── myna_markdown_to_html │ │ └── package.json │ ├── qunit-2.0.1.js │ ├── readme.md │ ├── sandbox │ ├── grammars_in_progress │ │ ├── comments.js │ │ └── javascript_tokens.js │ └── heron.md │ ├── test_arithmetic.js │ ├── tests │ ├── benchmark.js │ ├── heron_tools.js │ ├── input │ │ ├── 1K_json.js │ │ └── primitives.heron │ ├── mocha_runner.js │ ├── output │ │ ├── glsl_visitor.js │ │ └── readme.html │ ├── output_grammars.js │ ├── performance.html │ ├── qunit-2.0.1.css │ ├── qunit-2.0.1.js │ ├── qunit.html │ ├── readme.md │ ├── rule_test_inputs.js │ ├── rule_tester.js │ ├── test_all_tools.js │ ├── test_browser_unpkg.html │ ├── test_escape_html_chars.js │ ├── test_lucene.js │ ├── test_markdown_to_html.js │ ├── test_mustache_expander.js │ ├── test_node.js │ ├── test_parser_failure.js │ ├── test_pithy.js │ ├── test_typescript_import.js │ ├── test_typescript_import.js.map │ └── test_typescript_import.ts │ ├── tools │ ├── myna_all.js │ ├── myna_arithmetic_evaluator.js │ ├── myna_augment_ast.js │ ├── myna_build_site.js │ ├── myna_escape_html_chars.js │ ├── myna_generate_ast_visitor.js │ ├── myna_markdown_to_html.js │ ├── myna_mustache_expander.js │ └── readme.md │ ├── tsconfig.json │ └── website │ ├── index.md │ └── index.template.html ├── package-lock.json ├── package.json ├── source-browser ├── array.html ├── geometry-mesh.html ├── geometry-vector3.html ├── intrinsics.html ├── styles.css └── test.html ├── src ├── code-builder.ts ├── heron-ast-rewrite.ts ├── heron-compiler.ts ├── heron-defs.ts ├── heron-expr.ts ├── heron-name-analysis.ts ├── heron-normal-form.ts ├── heron-package.ts ├── heron-parser.ts ├── heron-refs.ts ├── heron-statement.ts ├── heron-to-glsl.ts ├── heron-to-html.ts ├── heron-to-js.ts ├── heron-to-text.ts ├── heron-types.ts ├── js-intrinsics.js ├── tests.ts ├── type-parser.ts ├── type-system.ts └── utils.ts ├── todo.md ├── tools ├── gen-spec.js └── gen-visitor.js └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/type-inference/.vscode/tasks.json 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible Node.js debug attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | { 9 | "type": "node", 10 | "request": "launch", 11 | "name": "Heron Test Output", 12 | "program": "${workspaceRoot}/demo/node_test.js", 13 | "cwd": "${workspaceRoot}", 14 | "outFiles": ["${workspaceRoot}/build/**/*.js"], 15 | "sourceMaps": true 16 | }, 17 | { 18 | "type": "node", 19 | "request": "launch", 20 | "name": "Launch Program", 21 | "program": "${workspaceRoot}/build/tests.js", 22 | "cwd": "${workspaceRoot}", 23 | "outFiles": ["${workspaceRoot}/build/**/*.js"], 24 | "sourceMaps": true 25 | }, 26 | { 27 | "type": "node", 28 | "request": "attach", 29 | "name": "Attach to Process", 30 | "port": 5858, 31 | "outFiles": [], 32 | "timeout": 30000, 33 | "sourceMaps": true 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | 4 | // The command is tsc. 5 | "command": "tsc", 6 | 7 | // Show the output window only if unrecognized errors occur. 8 | "showOutput": "always", 9 | 10 | // Under windows use tsc.exe. This ensures we don't need a shell. 11 | "windows": { 12 | "command": "tsc" 13 | }, 14 | 15 | // args is the program to compile. 16 | "args": ["--watch"], 17 | 18 | "isShellCommand": true, 19 | 20 | // use the standard tsc problem matcher to find compile problems 21 | // in the output. 22 | "problemMatcher": "$tsc" 23 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Christopher Diggins 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /build/code-builder.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | //===================================== 3 | // Helper class for constructing pretty printerd code 4 | // this is passed as a "state" object to visitors 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | function count(s, sub) { 7 | return s.split(sub).length - 1; 8 | } 9 | var CodeBuilder = /** @class */ (function () { 10 | function CodeBuilder() { 11 | this.lines = []; 12 | this.indent = 0; 13 | } 14 | Object.defineProperty(CodeBuilder.prototype, "indentString", { 15 | get: function () { 16 | var r = ''; 17 | for (var i = 0; i < this.indent; ++i) 18 | r += ' '; 19 | return r; 20 | }, 21 | enumerable: true, 22 | configurable: true 23 | }); 24 | CodeBuilder.prototype.pushLine = function (s) { 25 | if (s === void 0) { s = ''; } 26 | this.push(s + '\n'); 27 | this.lines.push(this.indentString); 28 | }; 29 | CodeBuilder.prototype.push = function (s) { 30 | var indentDelta = count(s, '{') - count(s, '}'); 31 | indentDelta += count(s, '(') - count(s, ')'); 32 | this.indent += indentDelta; 33 | if (indentDelta < 0) { 34 | if (this.lines.length > 0) { 35 | var lastLine = this.lines[this.lines.length - 1].trim(); 36 | if (lastLine.length === 0) { 37 | this.lines.pop(); 38 | this.lines.push(this.indentString); 39 | } 40 | } 41 | } 42 | this.lines.push(s); 43 | }; 44 | CodeBuilder.prototype.toString = function () { 45 | return this.lines.join(''); 46 | }; 47 | return CodeBuilder; 48 | }()); 49 | exports.CodeBuilder = CodeBuilder; 50 | //# sourceMappingURL=code-builder.js.map -------------------------------------------------------------------------------- /build/code-builder.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"code-builder.js","sourceRoot":"","sources":["../src/code-builder.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,sDAAsD;AACtD,iDAAiD;;AAEjD,eAAe,CAAS,EAAE,GAAW;IACjC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AACnC,CAAC;AAED;IAAA;QAEI,UAAK,GAAa,EAAE,CAAC;QACrB,WAAM,GAAW,CAAC,CAAC;IA6BvB,CAAC;IA5BG,sBAAI,qCAAY;aAAhB;YACI,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,GAAG,CAAC,CAAC,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAG,IAAI,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,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;IACL,kBAAC;AAAD,CAAC,AAhCD,IAgCC;AAhCY,kCAAW"} -------------------------------------------------------------------------------- /build/heron-compiler.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var heron_parser_1 = require("./heron-parser"); 4 | var heron_package_1 = require("./heron-package"); 5 | var heron_types_1 = require("./heron-types"); 6 | var g = heron_parser_1.heronGrammar; 7 | var fs = require('fs'); 8 | var path = require('path'); 9 | // TODO: use or throw out. 10 | //const nodePackage = JSON.parse(fs.readFileSync('package.json','utf8')); 11 | //const ver = nodePackage.version; 12 | //const flavor = 'std'; 13 | var ext = '.heron'; 14 | // Module resolution 15 | exports.moduleFolder = path.join('.', 'input'); 16 | exports.outputFolder = path.join('.', 'output'); 17 | exports.intrinsicModules = ['intrinsics']; 18 | exports.modules = []; 19 | //================================================================ 20 | // Main functions 21 | function createPackage(moduleNames) { 22 | var pkg = new heron_package_1.Package(); 23 | // Load the intrinsic (built-in) modules 24 | for (var _i = 0, intrinsicModules_1 = exports.intrinsicModules; _i < intrinsicModules_1.length; _i++) { 25 | var name_1 = intrinsicModules_1[_i]; 26 | addModuleToPackage(name_1, true, pkg); 27 | } 28 | // Load the specified modules (any order) 29 | for (var _a = 0, moduleNames_1 = moduleNames; _a < moduleNames_1.length; _a++) { 30 | var name_2 = moduleNames_1[_a]; 31 | addModuleToPackage(name_2, false, pkg); 32 | } 33 | // The package is doing the heavy lifting 34 | pkg.processModules(); 35 | // Compute types 36 | for (var _b = 0, _c = pkg.allVarDefs; _b < _c.length; _b++) { 37 | var v = _c[_b]; 38 | heron_types_1.computeVarType(v); 39 | } 40 | // Compute types 41 | for (var _d = 0, _e = pkg.allFuncDefs; _d < _e.length; _d++) { 42 | var f = _e[_d]; 43 | heron_types_1.computeFuncType(f); 44 | } 45 | return pkg; 46 | } 47 | exports.createPackage = createPackage; 48 | function addModuleToPackage(name, intrinsic, pkg) { 49 | var modulePath = moduleNameToPath(name); 50 | var ast = parseFile(modulePath); 51 | if (ast) 52 | pkg.addFile(ast, intrinsic, modulePath); 53 | } 54 | exports.addModuleToPackage = addModuleToPackage; 55 | function moduleNameToPath(f) { 56 | return path.join(exports.moduleFolder, f + ext); 57 | } 58 | exports.moduleNameToPath = moduleNameToPath; 59 | function parseModule(moduleName) { 60 | var modulePath = moduleNameToPath(moduleName); 61 | return parseFile(modulePath); 62 | } 63 | exports.parseModule = parseModule; 64 | function parseFile(f) { 65 | try { 66 | var code = fs.readFileSync(f, 'utf-8'); 67 | var ast = heron_parser_1.parseHeron(code, g.file); 68 | return ast; 69 | } 70 | catch (e) { 71 | console.log("An error occurred while parsing " + f); 72 | console.log(e.message); 73 | return null; 74 | } 75 | } 76 | exports.parseFile = parseFile; 77 | //# sourceMappingURL=heron-compiler.js.map -------------------------------------------------------------------------------- /build/heron-compiler.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"heron-compiler.js","sourceRoot":"","sources":["../src/heron-compiler.ts"],"names":[],"mappings":";;AACA,+CAA0D;AAC1D,iDAA0C;AAC1C,6CAAgE;AAEhE,IAAM,CAAC,GAAG,2BAAY,CAAC;AAIvB,IAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,IAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE7B,0BAA0B;AAC1B,yEAAyE;AACzE,mCAAmC;AACnC,uBAAuB;AAEvB,IAAM,GAAG,GAAG,QAAQ,CAAC;AAErB,oBAAoB;AACP,QAAA,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACvC,QAAA,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AACxC,QAAA,gBAAgB,GAAG,CAAC,YAAY,CAAC,CAAC;AAClC,QAAA,OAAO,GAAmB,EAAE,CAAC;AAE1C,kEAAkE;AAClE,k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AI,CAAC,oBAAY,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC;AAC5C,CAAC;AAFD,4CAEC;AAED,qBAA4B,UAAkB;IAC1C,IAAM,UAAU,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAChD,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AACjC,CAAC;AAHD,kCAGC;AAED,mBAA0B,CAAS;IAC/B,IACA,CAAC;QACG,IAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QACzC,IAAM,GAAG,GAAG,yBAAU,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC;IACf,CAAC;IACD,KAAK,CAAC,CAAC,CAAC,CAAC,CACT,CAAC;QACG,OAAO,CAAC,GAAG,CAAC,kCAAkC,GAAG,CAAC,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AAbD,8BAaC"} -------------------------------------------------------------------------------- /build/heron-name-analysis.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"heron-name-analysis.js","sourceRoot":"","sources":["../src/heron-name-analysis.ts"],"names":[],"mappings":";;AAKA;;;GAGG;AACH;IAQI,eAA4B,IAAkB;QAAlB,SAAI,GAAJ,IAAI,CAAc;QAN9C,OAAE,GAAW,CAAC,CAAC;QACf,SAAI,GAAU,EAAE,CAAC;QACjB,SAAI,GAAU,EAAE,CAAC;QACjB,aAAQ,GAAY,EAAE,CAAC;QACvB,WAAM,GAAe,IAAI,CAAC;QAGtB,EAAE,CAAC,CAAC,IAAI,CAAC;YACL,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED,+DAA+D;IAC/D,wBAAQ,GAAR,UAAS,IAAY;QACjB,IAAI,CAAC,GAAG,EAAE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,CAAC;IACD,uCAAgB,GAAhB,UAAiB,IAAkB,EAAE,KAAc;QAC/C,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAChC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACrB,CAAC;IACD,oCAAa,GAAb,UAAc,IAAkB,EAAE,KAAc;QAC5C,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAChC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACrB,CAAC;IACD,oCAAa,GAAb,UAAc,IAAkB,EAAE,KAAc;QAC5C,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC;IACL,mBAAC;AAAD,CAAC,AA3DD,IA2DC;AA3DY,oCAAY"} -------------------------------------------------------------------------------- /build/heron-normal-form.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Heron Normal Form (HNF) 3 | * 4 | * An intermediate compiler representation for optimization, transformation, code-generation, 5 | * analysis, and evaluation. 6 | * 7 | * Expression ::= 8 | * | Non-function (Bool, Int, Float, String, etc.) 9 | * | Function 10 | * | Function Set (Array of possible functions) 11 | * | Closure (Function + Closure record) 12 | * | Free variable (reference to entry in closure record) 13 | * | Parameter (bound variable) 14 | * | Function call (Function + Array of Expressions) 15 | * | Condition ( Expression ? Expression : Expression ) 16 | * 17 | * Other intermediate forms to look at: 18 | * * https://en.wikipedia.org/wiki/A-normal_form. 19 | * * https://en.wikipedia.org/wiki/Static_single_assignment_form 20 | * * https://en.wikipedia.org/wiki/Continuation-passing_style 21 | */ 22 | //# sourceMappingURL=heron-normal-form.js.map -------------------------------------------------------------------------------- /build/heron-normal-form.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"heron-normal-form.js","sourceRoot":"","sources":["../src/heron-normal-form.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG"} -------------------------------------------------------------------------------- /build/heron-refs.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // This module provides support for dealing with reference. 3 | // A reference is a name (identifier) that refers to a definition. 4 | // There can be more than one definitions (for examples when dealing with overloaded functions) 5 | var __extends = (this && this.__extends) || (function () { 6 | var extendStatics = Object.setPrototypeOf || 7 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 8 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 9 | return function (d, b) { 10 | extendStatics(d, b); 11 | function __() { this.constructor = d; } 12 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 13 | }; 14 | })(); 15 | Object.defineProperty(exports, "__esModule", { value: true }); 16 | var heron_ast_rewrite_1 = require("./heron-ast-rewrite"); 17 | // A reference to one or more definitions. 18 | var Ref = /** @class */ (function () { 19 | function Ref(node, name, scope, defs) { 20 | this.node = node; 21 | this.name = name; 22 | this.scope = scope; 23 | this.defs = defs; 24 | node.ref = this; 25 | if (defs.length === 0) 26 | heron_ast_rewrite_1.throwError(node, 'No definition found for ' + name); 27 | } 28 | Ref.prototype.toString = function () { 29 | return this.name + '_' + this.node['id'] + ':' + this.node.name + '[' + this.defs.join(', ') + ']'; 30 | }; 31 | return Ref; 32 | }()); 33 | exports.Ref = Ref; 34 | var VarRef = /** @class */ (function (_super) { 35 | __extends(VarRef, _super); 36 | function VarRef(node, name, scope, def) { 37 | var _this = _super.call(this, node, name, scope, [def]) || this; 38 | _this.node = node; 39 | _this.name = name; 40 | _this.scope = scope; 41 | _this.def = def; 42 | return _this; 43 | } 44 | return VarRef; 45 | }(Ref)); 46 | exports.VarRef = VarRef; 47 | var ForLoopVarRef = /** @class */ (function (_super) { 48 | __extends(ForLoopVarRef, _super); 49 | function ForLoopVarRef(node, name, scope, def) { 50 | var _this = _super.call(this, node, name, scope, [def]) || this; 51 | _this.node = node; 52 | _this.name = name; 53 | _this.scope = scope; 54 | _this.def = def; 55 | return _this; 56 | } 57 | return ForLoopVarRef; 58 | }(Ref)); 59 | exports.ForLoopVarRef = ForLoopVarRef; 60 | var FuncParamRef = /** @class */ (function (_super) { 61 | __extends(FuncParamRef, _super); 62 | function FuncParamRef(node, name, scope, def) { 63 | var _this = _super.call(this, node, name, scope, [def]) || this; 64 | _this.node = node; 65 | _this.name = name; 66 | _this.scope = scope; 67 | _this.def = def; 68 | return _this; 69 | } 70 | return FuncParamRef; 71 | }(Ref)); 72 | exports.FuncParamRef = FuncParamRef; 73 | var TypeRef = /** @class */ (function (_super) { 74 | __extends(TypeRef, _super); 75 | function TypeRef(node, name, scope, def) { 76 | var _this = _super.call(this, node, name, scope, [def]) || this; 77 | _this.node = node; 78 | _this.name = name; 79 | _this.scope = scope; 80 | _this.def = def; 81 | return _this; 82 | } 83 | return TypeRef; 84 | }(Ref)); 85 | exports.TypeRef = TypeRef; 86 | var TypeParamRef = /** @class */ (function (_super) { 87 | __extends(TypeParamRef, _super); 88 | function TypeParamRef(node, name, scope, def) { 89 | var _this = _super.call(this, node, name, scope, [def]) || this; 90 | _this.node = node; 91 | _this.name = name; 92 | _this.scope = scope; 93 | _this.def = def; 94 | return _this; 95 | } 96 | return TypeParamRef; 97 | }(Ref)); 98 | exports.TypeParamRef = TypeParamRef; 99 | var FuncRef = /** @class */ (function (_super) { 100 | __extends(FuncRef, _super); 101 | function FuncRef(node, name, scope, defs) { 102 | var _this = _super.call(this, node, name, scope, defs) || this; 103 | _this.node = node; 104 | _this.name = name; 105 | _this.scope = scope; 106 | _this.defs = defs; 107 | return _this; 108 | } 109 | return FuncRef; 110 | }(Ref)); 111 | exports.FuncRef = FuncRef; 112 | //# sourceMappingURL=heron-refs.js.map -------------------------------------------------------------------------------- /build/heron-refs.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"heron-refs.js","sourceRoot":"","sources":["../src/heron-refs.ts"],"names":[],"mappings":";AAA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AL,KAAK,CAAO;QACZ,SAAG,GAAH,GAAG,CAAc;;IAGrC,CAAC;IACL,mBAAC;AAAD,CAAC,AATD,CAAkC,GAAG,GASpC;AATY,oCAAY;AAWzB;IAA6B,2BAAG;IAC5B,iBACoB,IAAkB,EAClB,IAAY,EACZ,KAAY,EACZ,IAAe;QAJnC,YAMI,kBAAM,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,SACjC;QANmB,UAAI,GAAJ,IAAI,CAAc;QAClB,UAAI,GAAJ,IAAI,CAAQ;QACZ,WAAK,GAAL,KAAK,CAAO;QACZ,UAAI,GAAJ,IAAI,CAAW;;IAGnC,CAAC;IACL,cAAC;AAAD,CAAC,AATD,CAA6B,GAAG,GAS/B;AATY,0BAAO"} -------------------------------------------------------------------------------- /build/heron-type-evaluator.js: -------------------------------------------------------------------------------- 1 | //# sourceMappingURL=heron-type-evaluator.js.map -------------------------------------------------------------------------------- /build/heron-type-evaluator.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"heron-type-evaluator.js","sourceRoot":"","sources":["../src/heron-type-evaluator.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /build/js-intrinsics.js: -------------------------------------------------------------------------------- 1 | function arrayFromJavaScript(xs) { 2 | return { 3 | count: xs.length, 4 | array: xs, 5 | at: function (i) { return xs[i]; } 6 | }; 7 | } 8 | function toMutable(xs) { 9 | var count = xs.count; 10 | var array = []; 11 | for (var i = 0; i < count; ++i) 12 | array.push(xs.at(i)); 13 | return arrayFromJavaScript(array); 14 | } 15 | function int(x) { return Math.round(x); } 16 | function float(x) { return x; } 17 | function float2(x, y) { return ({ x: x, y: y }); } 18 | function float3(x, y, z) { return ({ x: x, y: y, z: z }); } 19 | function float4(x, y, z, w) { return ({ x: x, y: y, z: z, w: w }); } 20 | function x(v) { return v.x; } 21 | function y(v) { return v.y; } 22 | function z(v) { return v.z; } 23 | function w(v) { return v.w; } 24 | function abs(x) { return Math.abs(x); } 25 | function acos(x) { return Math.acos(x); } 26 | function asin(x) { return Math.asin(x); } 27 | function atan(x) { return Math.atan(x); } 28 | function atan2(y, x) { return Math.atan2(y, x); } 29 | function ceil(x) { return Math.ceil(x); } 30 | function cos(x) { return Math.cos(x); } 31 | function exp(x) { return Math.exp(x); } 32 | function floor(x) { return Math.floor(x); } 33 | function log(x) { return Math.log(x); } 34 | function pow(x, y) { return Math.pow(x, y); } 35 | function round(x) { return Math.round(x); } 36 | function sin(x) { return Math.sin(x); } 37 | function sqrt(x) { return Math.sqrt(x); } 38 | function tan(x) { return Math.tan(x); } 39 | function clamp(x, min, max) { return x < min ? min : x > max ? max : x; } 40 | ; 41 | function sign(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; } 42 | ; 43 | function op_add(x, y) { return x + y; } 44 | ; 45 | function op_sub(x, y) { return x - y; } 46 | ; 47 | function op_mul(x, y) { return x * y; } 48 | ; 49 | function op_div(x, y) { return x / y; } 50 | ; 51 | function op_mod(x, y) { return x % y; } 52 | ; 53 | function op_gt(x, y) { return x > y; } 54 | ; 55 | function op_gt_eq(x, y) { return x >= y; } 56 | ; 57 | function op_lt(x, y) { return x < y; } 58 | ; 59 | function op_lt_eq(x, y) { return x <= y; } 60 | ; 61 | function op_not_eq(x, y) { return x !== y; } 62 | ; 63 | function op_eq_eq(x, y) { return x === y; } 64 | ; 65 | function op_amp_amp(x, y) { return x && y; } 66 | ; 67 | function op_bar_bar(x, y) { return x || y; } 68 | ; 69 | function op_hat_hat(x, y) { return !!(x ^ y); } 70 | ; 71 | function op_not(x) { return !x; } 72 | ; 73 | function op_negate(x) { return -x; } 74 | ; 75 | function count(xs) { return xs.count; } 76 | ; 77 | function at(xs, i) { return xs.at(i); } 78 | ; 79 | function array(count, at) { return { count: count, at: at }; } 80 | function mutable(x) { return toMutable(x); } 81 | function immutable(xs) { return array(xs.array.length, xs.at); } 82 | function push(xs, x) { return (xs.array.push(x), xs); } 83 | ; 84 | function set(xs, i, x) { return (xs.array[i] = x, xs); } 85 | ; 86 | function print(x) { return console.log(x); } 87 | function assert(condition) { if (!condition) 88 | throw new Error("assertion failed"); } 89 | ; 90 | function mesh(vertexBuffer, indexBuffer) { return ({ vertexBuffer: vertexBuffer, indexBuffer: indexBuffer }); } 91 | ; 92 | function vertexBuffer(mesh) { return mesh.vertexBuffer; } 93 | ; 94 | function indexBuffer(mesh) { return mesh.indexBuffer; } 95 | ; 96 | //# sourceMappingURL=js-intrinsics.js.map -------------------------------------------------------------------------------- /build/type-parser.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var type_system_1 = require("./type-system"); 4 | var myna_parser_1 = require("myna-parser"); 5 | // Defines syntax parsers for type expression, the lambda calculus, and Cat 6 | function registerGrammars() { 7 | // A simple grammar for parsing type expressions 8 | var TypeGrammar = /** @class */ (function () { 9 | function TypeGrammar() { 10 | var _this = this; 11 | this.typeExprRec = myna_parser_1.Myna.delay(function () { return _this.typeExpr; }); 12 | this.typeList = myna_parser_1.Myna.guardedSeq('(', myna_parser_1.Myna.ws, this.typeExprRec.ws.zeroOrMore, ')').ast; 13 | this.typeVar = myna_parser_1.Myna.guardedSeq("'", myna_parser_1.Myna.identifier).ast; 14 | this.typeConstant = myna_parser_1.Myna.identifier.or(myna_parser_1.Myna.digits).or("->").or("*").or("[]").ast; 15 | this.typeExpr = myna_parser_1.Myna.choice(this.typeList, this.typeVar, this.typeConstant).ast; 16 | } 17 | return TypeGrammar; 18 | }()); 19 | var typeGrammar = new TypeGrammar(); 20 | myna_parser_1.Myna.registerGrammar('type', typeGrammar, typeGrammar.typeExpr); 21 | } 22 | registerGrammars(); 23 | exports.typeParser = myna_parser_1.Myna.parsers['type']; 24 | function parseType(input) { 25 | var ast = exports.typeParser(input); 26 | if (ast.end != input.length) 27 | throw new Error("Only part of input was consumed"); 28 | return astToType(ast); 29 | } 30 | exports.parseType = parseType; 31 | function astToType(ast) { 32 | if (!ast) 33 | return null; 34 | switch (ast.name) { 35 | case "typeVar": 36 | return type_system_1.typeVariable(ast.allText.substr(1)); 37 | case "typeConstant": 38 | return type_system_1.typeConstant(ast.allText); 39 | case "typeList": 40 | return type_system_1.polyType(ast.children.map(astToType)); 41 | case "typeExpr": 42 | if (ast.children.length != 1) 43 | throw new Error("Expected only one child of node, not " + ast.children.length); 44 | return astToType(ast.children[0]); 45 | default: 46 | throw new Error("Unrecognized type expression: " + ast.name); 47 | } 48 | } 49 | //# sourceMappingURL=type-parser.js.map -------------------------------------------------------------------------------- /build/type-parser.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"type-parser.js","sourceRoot":"","sources":["../src/type-parser.ts"],"names":[],"mappings":";;AAAA,6CAA2E;AAC3E,2CAAuC;AAEvC,4EAA4E;AAC5E;IAEI,gDAAgD;IAChD;QAAA;YAAA,iBAOC;YALG,gBAAW,GAAM,kBAAC,CAAC,KAAK,CAAC,cAAM,OAAA,KAAI,CAAC,QAAQ,EAAb,CAAa,CAAC,CAAC;YAC9C,aAAQ,GAAS,kBAAC,CAAC,UAAU,CAAC,GAAG,EAAE,kBAAC,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC;YAClF,YAAO,GAAU,kBAAC,CAAC,UAAU,CAAC,GAAG,EAAE,kBAAC,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC;YACrD,iBAAY,GAAK,kBAAC,CAAC,UAAU,CAAC,EAAE,CAAC,kBAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC;YACzE,aAAQ,GAAS,kBAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC;QAClF,CAAC;QAAD,kBAAC;IAAD,CAAC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C;QACtC;YACI,MAAM,IAAI,KAAK,CAAC,gCAAgC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;AACL,CAAC"} -------------------------------------------------------------------------------- /build/utils.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | function trace(label, message) { 4 | //console.log(message); 5 | } 6 | exports.trace = trace; 7 | //# sourceMappingURL=utils.js.map -------------------------------------------------------------------------------- /build/utils.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAEA,eAAsB,KAAiB,EAAE,OAAe;IACpD,uBAAuB;AAC3B,CAAC;AAFD,sBAEC"} -------------------------------------------------------------------------------- /comparison.md: -------------------------------------------------------------------------------- 1 | ## Heron Compared to TypeScript / JavaScript 2 | 3 | Heron most closely resembles a subset of the JavaScript language. It has a type system that is more restricted than TypeScript, but the type-inference system is more aggressive. For example Heron function parameter types are inferred based on usage in the function defintion, as opposed to resolving to `any`. 4 | 5 | The biggest standout difference is that Heron has no concept of classes or prototypes. 6 | 7 | Heron is an unordered list of various differences Heron has with TypeScript/JavaScript: 8 | 9 | * only primitive types, generic types (including array and function), and type variables 10 | * no object literals 11 | * no `this` keyword 12 | * functions can be called using dot notation on the first argument 13 | * functions can be ovoverloaded (two functions can have the same name if the inferred types are different) 14 | * operators can be overloaded 15 | * operators can be passed as functions 16 | * `var` statements are equivalent to `let` statements in TypeScript/JavaScript 17 | * no `const` statements 18 | * module level variables cannot be modified 19 | * variable types are inferred 20 | * parameter and return types of functions are inferred 21 | * variables have to always be initialized 22 | * variable binding expression allows variable declarations to be used as expressions 23 | * arrays are immutable 24 | * modifying arrays can only be done with `ArrayBuilder` 25 | * each `ArrayBuilder` modification creates a new array 26 | * only supports a `for..in` loop form which is the same as `for..of` loop in JavaScript 27 | * a built-in range operator `from..to` generates an array of contiguous values (exclusive upper bound) 28 | * arrays do not necessarily allocate memory, e.g. 0..100000000, has O(1) memory consumption 29 | * module names are URN's with the version number encoded in it 30 | * all files specify the version of the language 31 | * all definitions must be in a module 32 | * variables cannot be reassigned to objects of a different type 33 | * no `async` or `await` support 34 | * no operators spread support 35 | * no class or interface definitions 36 | * anonymous functions use a *fat arrow* syntax 37 | * Separation betwen integers (`Int`) and floating point numbers (`Float`) 38 | * Support for two, three, and four dimensional numerical types like in GLSL (`Float2`, `Float3`, `Float4`). 39 | * Semicolons are required as statement terminators. 40 | * No statement labels 41 | * No comma operator 42 | * No switch statement 43 | -------------------------------------------------------------------------------- /demo/node_test.js: -------------------------------------------------------------------------------- 1 | require('./output.js'); 2 | process.exit(); -------------------------------------------------------------------------------- /demo/sandbox/shaders.html: -------------------------------------------------------------------------------- 1 | 18 | 19 | 27 | 28 | 29 | 46 | 47 | -------------------------------------------------------------------------------- /history.md: -------------------------------------------------------------------------------- 1 | 2 | # History of Heron 3 | 4 | ### Why throw away a good name? 5 | 6 | This is technically the third incarnation of the programming language Heron, but only a handful of people will remember the older versions. The last time I announced a programming language named Heron was in 2010. Previous incarnations were intended as general purpose languages whereas Heron is now much more focused in scope and purpose. However, much of the original philosophy and intention is present in the language so I've decided to stick to the name. 7 | 8 | The first large public announcement of the original Heron language was in 2006 https://developers.slashdot.org/story/04/12/08/1944233/introducing-the-heron-programming-language. That implementation was a Heron to C++ translator. It's primary contribution was a more advanced meta-programming system for C++ and a more regular syntax. At that time the another systems language was being developed by Walter Bright called D, which had similar design goals. 9 | 10 | Heron underwent several modifications and extensions and was revived in 2010 http://www.artima.com/weblogs/viewpost.jsp?thread=284558 with many new features. Achilleas Margaritas described the differences as "this new Heron seems to be a very different beast. It seems to be an enterprise-friendly application language like Java and C#, rather than a system/application one like C and C++.". This reflected my new found interest in C#, and the idea of code and diagrams being closely related. 11 | 12 | After finishing a working implementation of the new version of Heron, I realized that I had created a general purpose programming language that had no tool support, no community, and no libraries. Convincing any professional software developer to use Heron as opposed to an entrenched general purpose languages (C++, Java, C#, Scala, etc.) was going to be effectively impossible. I decided at that point to put Heron on ice and focus on other things. 13 | 14 | After spending several years working with 3D and animation software, including designing a visual programming language for 3D processing (Max Creation Graph), I've realized that there is a real need for an easy to use yet efficient programming language, which can target multiple platforms. Therefore I decided to reincarnate Heron as a programming language that specializes in efficient array and numerical processing, but that has the look and feel of JavaScript. 15 | 16 | I've found it to be a very pleasant experience writing libraries in Heron for array, numerical, 2D, and 3D processing. I hope you enjoy it as well, and I'd appreciate your feedback on how I can make it better! 17 | 18 | ## Postscript: May 7th 2023 19 | 20 | It has been five years since I have contributed to Heron. After releasing a v0.1 version of Heron that had 21 | a very powerful type-inference system and a syntax which I found agreeable, I realized that the next steps of 22 | getting people to use the language would be virtually insurmountable. 23 | 24 | How do you convince people to use a new language with extremely limited tooling, no libraries, and 25 | the only advantage is a nicer syntax with less type annotations? People already had enough languages 26 | to choose from, and type-safety with simpler syntax wasn't a strong enough motivator. 27 | 28 | In the last few years I moved back to primarily C# development in the realm of real-time 3D graphics. 29 | I developed numerous libraries and software using a primarily functional style of programming. 30 | Pure functional programming in C# works surprisingly well for real-time 3D graphics processing, it 31 | can produce very robust and relatively efficient code. 32 | 33 | However there were still limitations: the C# compiler still does not do a particularly good job of optimizing 34 | functional code, C# cannot be run efficiently in the browser, and writing numerical code in a pure functional 35 | style requires a ton of boilerplate. 36 | 37 | This inspired me to develop a language that would allow me to write my algorithms and data-structures in a C# 38 | style language while targetting multiple languages and platforms, with less boilerplate, and that could 39 | be easily optimized. 40 | 41 | This [new programming language is called Plato](https://github.com/cdiggins/plato) and it borrows many of the ideas 42 | and design goals of Heron. It is a more ambitious project with more features and is being built with the aim of 43 | bootstrapping itself. 44 | -------------------------------------------------------------------------------- /img/heron-source-torus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdiggins/heron-language/f7c4da9f50b3c5b3cf0e78944cda463d60eb4ae5/img/heron-source-torus.png -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Heron 4 | 5 | 11 | 12 | 13 | 14 | 15 | Fork me on GitHub

Heron Language 3D Geometry Demo

16 | 17 |
18 |
19 |

20 | Heron is a new statically typed functional programming 21 | language with a JavaScript-like syntax that specializes in the processing of arrays of numerical data. 22 |

23 |

24 | This demo uses Heron to generate mesh data (vertices, faces, and colors) 25 | and uses Three.JS to display the resulting geometry. 26 | Browse the source code here: 27 |

33 |

34 |

35 | If you are interested in learning more, or collaborating please reach out to me, 36 | Christopher Diggins, via email 37 | LinkedIn, Twitter, 38 | or GitHub. 39 |

40 |
41 |
42 |