Browse Source

Upgrade pegjs.

Herby Vojčík 5 years ago
parent
commit
1e3baf7683
7 changed files with 237 additions and 155 deletions
  1. 8 0
      CHANGELOG
  2. 1 1
      Gruntfile.js
  3. 199 144
      lang/base/parser.js
  4. 4 0
      lang/base/parser.pegjs
  5. 2 3
      lang/package.json
  6. 19 6
      lang/src/Kernel-Infrastructure.js
  7. 4 1
      lang/src/Kernel-Infrastructure.st

+ 8 - 0
CHANGELOG

@@ -1,3 +1,11 @@
+? ??? 2019 - Release 0.24.0
+===================================
+
+* Deprecate global "SmalltalkParser".
+
+Commits: https://lolg.it/amber/amber/commits/0.23.0
+
+
 25 Feb 2019 - Release 0.23.0
 ===================================
 

+ 1 - 1
Gruntfile.js

@@ -138,7 +138,7 @@ module.exports = function (grunt) {
         },
 
         jshint: {
-            amber: ['lang/src/*.js', 'lang/base/*.js'],
+            amber: ['lang/src/*.js', 'lang/base/[^p]*.js'],
             cli: ['cli/src/*.js', 'cli/dist/*.js'],
             dev: ['sdk/lib/*.js'],
             grunt: ['Gruntfile.js', 'grunt-tasks/*.js', 'sdk/tasks/*.js']

+ 199 - 144
lang/base/parser.js

@@ -1,15 +1,11 @@
-// jshint ignore:start
-define(['./boot'], function($boot) {
-var $globals = $boot.globals;
-$globals.SmalltalkParser = (function() {
+/*
+ * Generated by PEG.js 0.10.0.
+ *
+ * http://pegjs.org/
+ */
+define(["./boot"], function($boot) {
   "use strict";
 
-  /*
-   * Generated by PEG.js 0.9.0.
-   *
-   * http://pegjs.org/
-   */
-
   function peg$subclass(child, parent) {
     function ctor() { this.constructor = child; }
     ctor.prototype = parent.prototype;
@@ -30,31 +26,137 @@ $globals.SmalltalkParser = (function() {
 
   peg$subclass(peg$SyntaxError, Error);
 
-  function peg$parse(input) {
-    var options = arguments.length > 1 ? arguments[1] : {},
-        parser  = this,
+  peg$SyntaxError.buildMessage = function(expected, found) {
+    var DESCRIBE_EXPECTATION_FNS = {
+          literal: function(expectation) {
+            return "\"" + literalEscape(expectation.text) + "\"";
+          },
+
+          "class": function(expectation) {
+            var escapedParts = "",
+                i;
+
+            for (i = 0; i < expectation.parts.length; i++) {
+              escapedParts += expectation.parts[i] instanceof Array
+                ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
+                : classEscape(expectation.parts[i]);
+            }
+
+            return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
+          },
+
+          any: function(expectation) {
+            return "any character";
+          },
+
+          end: function(expectation) {
+            return "end of input";
+          },
+
+          other: function(expectation) {
+            return expectation.description;
+          }
+        };
+
+    function hex(ch) {
+      return ch.charCodeAt(0).toString(16).toUpperCase();
+    }
+
+    function literalEscape(s) {
+      return s
+        .replace(/\\/g, '\\\\')
+        .replace(/"/g,  '\\"')
+        .replace(/\0/g, '\\0')
+        .replace(/\t/g, '\\t')
+        .replace(/\n/g, '\\n')
+        .replace(/\r/g, '\\r')
+        .replace(/[\x00-\x0F]/g,          function(ch) { return '\\x0' + hex(ch); })
+        .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x'  + hex(ch); });
+    }
+
+    function classEscape(s) {
+      return s
+        .replace(/\\/g, '\\\\')
+        .replace(/\]/g, '\\]')
+        .replace(/\^/g, '\\^')
+        .replace(/-/g,  '\\-')
+        .replace(/\0/g, '\\0')
+        .replace(/\t/g, '\\t')
+        .replace(/\n/g, '\\n')
+        .replace(/\r/g, '\\r')
+        .replace(/[\x00-\x0F]/g,          function(ch) { return '\\x0' + hex(ch); })
+        .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x'  + hex(ch); });
+    }
+
+    function describeExpectation(expectation) {
+      return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
+    }
+
+    function describeExpected(expected) {
+      var descriptions = new Array(expected.length),
+          i, j;
 
-        peg$FAILED = {},
+      for (i = 0; i < expected.length; i++) {
+        descriptions[i] = describeExpectation(expected[i]);
+      }
+
+      descriptions.sort();
+
+      if (descriptions.length > 0) {
+        for (i = 1, j = 1; i < descriptions.length; i++) {
+          if (descriptions[i - 1] !== descriptions[i]) {
+            descriptions[j] = descriptions[i];
+            j++;
+          }
+        }
+        descriptions.length = j;
+      }
+
+      switch (descriptions.length) {
+        case 1:
+          return descriptions[0];
+
+        case 2:
+          return descriptions[0] + " or " + descriptions[1];
+
+        default:
+          return descriptions.slice(0, -1).join(", ")
+            + ", or "
+            + descriptions[descriptions.length - 1];
+      }
+    }
+
+    function describeFound(found) {
+      return found ? "\"" + literalEscape(found) + "\"" : "end of input";
+    }
+
+    return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
+  };
+
+  function peg$parse(input, options) {
+    options = options !== void 0 ? options : {};
+
+    var peg$FAILED = {},
 
         peg$startRuleFunctions = { start: peg$parsestart },
         peg$startRuleFunction  = peg$parsestart,
 
         peg$c0 = /^[ \t\x0B\f\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF\n\r\u2028\u2029]/,
-        peg$c1 = { type: "class", value: "[ \\t\\v\\f\\u00A0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000\\uFEFF\\n\\r\\u2028\\u2029]", description: "[ \\t\\v\\f\\u00A0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000\\uFEFF\\n\\r\\u2028\\u2029]" },
+        peg$c1 = peg$classExpectation([" ", "\t", "\x0B", "\f", "\xA0", "\u1680", ["\u2000", "\u200A"], "\u202F", "\u205F", "\u3000", "\uFEFF", "\n", "\r", "\u2028", "\u2029"], false, false),
         peg$c2 = "\"",
-        peg$c3 = { type: "literal", value: "\"", description: "\"\\\"\"" },
+        peg$c3 = peg$literalExpectation("\"", false),
         peg$c4 = /^[^"]/,
-        peg$c5 = { type: "class", value: "[^\"]", description: "[^\"]" },
+        peg$c5 = peg$classExpectation(["\""], true, false),
         peg$c6 = ".",
-        peg$c7 = { type: "literal", value: ".", description: "\".\"" },
+        peg$c7 = peg$literalExpectation(".", false),
         peg$c8 = /^[a-zA-Z]/,
-        peg$c9 = { type: "class", value: "[a-zA-Z]", description: "[a-zA-Z]" },
+        peg$c9 = peg$classExpectation([["a", "z"], ["A", "Z"]], false, false),
         peg$c10 = /^[a-zA-Z0-9]/,
-        peg$c11 = { type: "class", value: "[a-zA-Z0-9]", description: "[a-zA-Z0-9]" },
+        peg$c11 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false),
         peg$c12 = ":",
-        peg$c13 = { type: "literal", value: ":", description: "\":\"" },
+        peg$c13 = peg$literalExpectation(":", false),
         peg$c14 = /^[A-Z]/,
-        peg$c15 = { type: "class", value: "[A-Z]", description: "[A-Z]" },
+        peg$c15 = peg$classExpectation([["A", "Z"]], false, false),
         peg$c16 = function(val) {
         	return $globals.ValueNode._new()
         		._location_(location())
@@ -62,16 +164,16 @@ $globals.SmalltalkParser = (function() {
         		._value_(val);
         },
         peg$c17 = "'",
-        peg$c18 = { type: "literal", value: "'", description: "\"'\"" },
+        peg$c18 = peg$literalExpectation("'", false),
         peg$c19 = "''",
-        peg$c20 = { type: "literal", value: "''", description: "\"''\"" },
+        peg$c20 = peg$literalExpectation("''", false),
         peg$c21 = function() {return '\'';},
         peg$c22 = /^[^']/,
-        peg$c23 = { type: "class", value: "[^']", description: "[^']" },
+        peg$c23 = peg$classExpectation(["'"], true, false),
         peg$c24 = function(val) {return val.join('');},
         peg$c25 = "$",
-        peg$c26 = { type: "literal", value: "$", description: "\"$\"" },
-        peg$c27 = { type: "any", description: "any character" },
+        peg$c26 = peg$literalExpectation("$", false),
+        peg$c27 = peg$anyExpectation(),
         peg$c28 = function(char) {
         	return $globals.ValueNode._new()
         		._location_(location())
@@ -79,44 +181,44 @@ $globals.SmalltalkParser = (function() {
         		._value_(char);
         },
         peg$c29 = "#",
-        peg$c30 = { type: "literal", value: "#", description: "\"#\"" },
+        peg$c30 = peg$literalExpectation("#", false),
         peg$c31 = function(rest) {return rest;},
         peg$c32 = "e",
-        peg$c33 = { type: "literal", value: "e", description: "\"e\"" },
+        peg$c33 = peg$literalExpectation("e", false),
         peg$c34 = function(n) {return parseFloat(n);},
         peg$c35 = "-",
-        peg$c36 = { type: "literal", value: "-", description: "\"-\"" },
+        peg$c36 = peg$literalExpectation("-", false),
         peg$c37 = "16r",
-        peg$c38 = { type: "literal", value: "16r", description: "\"16r\"" },
+        peg$c38 = peg$literalExpectation("16r", false),
         peg$c39 = /^[0-9a-fA-F]/,
-        peg$c40 = { type: "class", value: "[0-9a-fA-F]", description: "[0-9a-fA-F]" },
+        peg$c40 = peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false),
         peg$c41 = function(neg, num) {
         	return parseInt(((neg || '') + num), 16);
         },
         peg$c42 = /^[0-9]/,
-        peg$c43 = { type: "class", value: "[0-9]", description: "[0-9]" },
+        peg$c43 = peg$classExpectation([["0", "9"]], false, false),
         peg$c44 = function(n) {return parseFloat(n, 10);},
         peg$c45 = function(n) {return parseInt(n, 10);},
         peg$c46 = "#(",
-        peg$c47 = { type: "literal", value: "#(", description: "\"#(\"" },
+        peg$c47 = peg$literalExpectation("#(", false),
         peg$c48 = ")",
-        peg$c49 = { type: "literal", value: ")", description: "\")\"" },
+        peg$c49 = peg$literalExpectation(")", false),
         peg$c50 = function(rest) {
         	return rest
         		._location_(location())
         		._source_(text());
         },
         peg$c51 = "(",
-        peg$c52 = { type: "literal", value: "(", description: "\"(\"" },
+        peg$c52 = peg$literalExpectation("(", false),
         peg$c53 = function(lit) {return lit._value();},
         peg$c54 = function(lits) {
         		return $globals.ValueNode._new()
         			._value_(lits);
         	},
         peg$c55 = "{",
-        peg$c56 = { type: "literal", value: "{", description: "\"{\"" },
+        peg$c56 = peg$literalExpectation("{", false),
         peg$c57 = "}",
-        peg$c58 = { type: "literal", value: "}", description: "\"}\"" },
+        peg$c58 = peg$literalExpectation("}", false),
         peg$c59 = function(expressions) {
         	return $globals.DynamicArrayNode._new()
         		._location_(location())
@@ -124,7 +226,7 @@ $globals.SmalltalkParser = (function() {
         		._dagChildren_(expressions || []);
         },
         peg$c60 = "#{",
-        peg$c61 = { type: "literal", value: "#{", description: "\"#{\"" },
+        peg$c61 = peg$literalExpectation("#{", false),
         peg$c62 = function(expressions) {
         	return $globals.DynamicDictionaryNode._new()
         		._location_(location())
@@ -132,13 +234,13 @@ $globals.SmalltalkParser = (function() {
         		._dagChildren_(expressions || []);
         },
         peg$c63 = "true",
-        peg$c64 = { type: "literal", value: "true", description: "\"true\"" },
+        peg$c64 = peg$literalExpectation("true", false),
         peg$c65 = function() {return true;},
         peg$c66 = "false",
-        peg$c67 = { type: "literal", value: "false", description: "\"false\"" },
+        peg$c67 = peg$literalExpectation("false", false),
         peg$c68 = function() {return false;},
         peg$c69 = "nil",
-        peg$c70 = { type: "literal", value: "nil", description: "\"nil\"" },
+        peg$c70 = peg$literalExpectation("nil", false),
         peg$c71 = function() {return null;},
         peg$c72 = function(identifier) {
         	return $globals.VariableNode._new()
@@ -147,7 +249,7 @@ $globals.SmalltalkParser = (function() {
         		._value_(identifier);
         },
         peg$c73 = /^[\\+*\/=><,@%~|&\-]/,
-        peg$c74 = { type: "class", value: "[\\\\+*/=><,@%~|&-]", description: "[\\\\+*/=><,@%~|&-]" },
+        peg$c74 = peg$classExpectation(["\\", "+", "*", "/", "=", ">", "<", ",", "@", "%", "~", "|", "&", "-"], false, false),
         peg$c75 = function(key, arg) {return {key:key, arg:arg};},
         peg$c76 = function(pairs) {
         		var selector = '';
@@ -181,12 +283,12 @@ $globals.SmalltalkParser = (function() {
         		return $globals.Message._selector_arguments_(selector, args)
         	},
         peg$c83 = "<",
-        peg$c84 = { type: "literal", value: "<", description: "\"<\"" },
+        peg$c84 = peg$literalExpectation("<", false),
         peg$c85 = ">",
-        peg$c86 = { type: "literal", value: ">", description: "\">\"" },
+        peg$c86 = peg$literalExpectation(">", false),
         peg$c87 = function(message) {return message;},
         peg$c88 = ":=",
-        peg$c89 = { type: "literal", value: ":=", description: "\":=\"" },
+        peg$c89 = peg$literalExpectation(":=", false),
         peg$c90 = function(variable, expression) {
         	return $globals.AssignmentNode._new()
         		._location_(location())
@@ -195,7 +297,7 @@ $globals.SmalltalkParser = (function() {
         		._right_(expression);
         },
         peg$c91 = "^",
-        peg$c92 = { type: "literal", value: "^", description: "\"^\"" },
+        peg$c92 = peg$literalExpectation("^", false),
         peg$c93 = function(expression) {
         	return $globals.ReturnNode._new()
         		._location_(location())
@@ -203,7 +305,7 @@ $globals.SmalltalkParser = (function() {
         		._dagChildren_([expression]);
         },
         peg$c94 = "|",
-        peg$c95 = { type: "literal", value: "|", description: "\"|\"" },
+        peg$c95 = peg$literalExpectation("|", false),
         peg$c96 = function(variable) {return variable;},
         peg$c97 = function(vars) {
         	return vars;
@@ -235,9 +337,9 @@ $globals.SmalltalkParser = (function() {
         		._dagChildren_(statements || []);
         },
         peg$c105 = "[",
-        peg$c106 = { type: "literal", value: "[", description: "\"[\"" },
+        peg$c106 = peg$literalExpectation("[", false),
         peg$c107 = "]",
-        peg$c108 = { type: "literal", value: "]", description: "\"]\"" },
+        peg$c108 = peg$literalExpectation("]", false),
         peg$c109 = function(params, sequence) {
         	return $globals.BlockNode._new()
         		._location_(location())
@@ -281,7 +383,7 @@ $globals.SmalltalkParser = (function() {
         },
         peg$c116 = function(receiver, tail) {return tail.length > 0;},
         peg$c117 = ";",
-        peg$c118 = { type: "literal", value: ";", description: "\";\"" },
+        peg$c118 = peg$literalExpectation(";", false),
         peg$c119 = function(receiver, tail, mess) {return mess;},
         peg$c120 = function(receiver, tail, messages) {
         		messages.unshift(receiver._withTail_(tail));
@@ -309,7 +411,7 @@ $globals.SmalltalkParser = (function() {
 
         peg$currPos          = 0,
         peg$savedPos         = 0,
-        peg$posDetailsCache  = [{ line: 1, column: 1, seenCR: false }],
+        peg$posDetailsCache  = [{ line: 1, column: 1 }],
         peg$maxFailPos       = 0,
         peg$maxFailExpected  = [],
         peg$silentFails      = 0,
@@ -334,27 +436,44 @@ $globals.SmalltalkParser = (function() {
       return peg$computeLocation(peg$savedPos, peg$currPos);
     }
 
-    function expected(description) {
-      throw peg$buildException(
-        null,
-        [{ type: "other", description: description }],
+    function expected(description, location) {
+      location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
+
+      throw peg$buildStructuredError(
+        [peg$otherExpectation(description)],
         input.substring(peg$savedPos, peg$currPos),
-        peg$computeLocation(peg$savedPos, peg$currPos)
+        location
       );
     }
 
-    function error(message) {
-      throw peg$buildException(
-        message,
-        null,
-        input.substring(peg$savedPos, peg$currPos),
-        peg$computeLocation(peg$savedPos, peg$currPos)
-      );
+    function error(message, location) {
+      location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
+
+      throw peg$buildSimpleError(message, location);
+    }
+
+    function peg$literalExpectation(text, ignoreCase) {
+      return { type: "literal", text: text, ignoreCase: ignoreCase };
+    }
+
+    function peg$classExpectation(parts, inverted, ignoreCase) {
+      return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
+    }
+
+    function peg$anyExpectation() {
+      return { type: "any" };
+    }
+
+    function peg$endExpectation() {
+      return { type: "end" };
+    }
+
+    function peg$otherExpectation(description) {
+      return { type: "other", description: description };
     }
 
     function peg$computePosDetails(pos) {
-      var details = peg$posDetailsCache[pos],
-          p, ch;
+      var details = peg$posDetailsCache[pos], p;
 
       if (details) {
         return details;
@@ -367,23 +486,15 @@ $globals.SmalltalkParser = (function() {
         details = peg$posDetailsCache[p];
         details = {
           line:   details.line,
-          column: details.column,
-          seenCR: details.seenCR
+          column: details.column
         };
 
         while (p < pos) {
-          ch = input.charAt(p);
-          if (ch === "\n") {
-            if (!details.seenCR) { details.line++; }
-            details.column = 1;
-            details.seenCR = false;
-          } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
+          if (input.charCodeAt(p) === 10) {
             details.line++;
             details.column = 1;
-            details.seenCR = true;
           } else {
             details.column++;
-            details.seenCR = false;
           }
 
           p++;
@@ -423,71 +534,13 @@ $globals.SmalltalkParser = (function() {
       peg$maxFailExpected.push(expected);
     }
 
-    function peg$buildException(message, expected, found, location) {
-      function cleanupExpected(expected) {
-        var i = 1;
-
-        expected.sort(function(a, b) {
-          if (a.description < b.description) {
-            return -1;
-          } else if (a.description > b.description) {
-            return 1;
-          } else {
-            return 0;
-          }
-        });
-
-        while (i < expected.length) {
-          if (expected[i - 1] === expected[i]) {
-            expected.splice(i, 1);
-          } else {
-            i++;
-          }
-        }
-      }
-
-      function buildMessage(expected, found) {
-        function stringEscape(s) {
-          function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
-
-          return s
-            .replace(/\\/g,   '\\\\')
-            .replace(/"/g,    '\\"')
-            .replace(/\x08/g, '\\b')
-            .replace(/\t/g,   '\\t')
-            .replace(/\n/g,   '\\n')
-            .replace(/\f/g,   '\\f')
-            .replace(/\r/g,   '\\r')
-            .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
-            .replace(/[\x10-\x1F\x80-\xFF]/g,    function(ch) { return '\\x'  + hex(ch); })
-            .replace(/[\u0100-\u0FFF]/g,         function(ch) { return '\\u0' + hex(ch); })
-            .replace(/[\u1000-\uFFFF]/g,         function(ch) { return '\\u'  + hex(ch); });
-        }
-
-        var expectedDescs = new Array(expected.length),
-            expectedDesc, foundDesc, i;
-
-        for (i = 0; i < expected.length; i++) {
-          expectedDescs[i] = expected[i].description;
-        }
-
-        expectedDesc = expected.length > 1
-          ? expectedDescs.slice(0, -1).join(", ")
-              + " or "
-              + expectedDescs[expected.length - 1]
-          : expectedDescs[0];
-
-        foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
-
-        return "Expected " + expectedDesc + " but " + foundDesc + " found.";
-      }
-
-      if (expected !== null) {
-        cleanupExpected(expected);
-      }
+    function peg$buildSimpleError(message, location) {
+      return new peg$SyntaxError(message, null, null, location);
+    }
 
+    function peg$buildStructuredError(expected, found, location) {
       return new peg$SyntaxError(
-        message !== null ? message : buildMessage(expected, found),
+        peg$SyntaxError.buildMessage(expected, found),
         expected,
         found,
         location
@@ -4063,17 +4116,20 @@ $globals.SmalltalkParser = (function() {
       return s0;
     }
 
+
+       var $globals = $boot.globals;
+
+
     peg$result = peg$startRuleFunction();
 
     if (peg$result !== peg$FAILED && peg$currPos === input.length) {
       return peg$result;
     } else {
       if (peg$result !== peg$FAILED && peg$currPos < input.length) {
-        peg$fail({ type: "end", description: "end of input" });
+        peg$fail(peg$endExpectation());
       }
 
-      throw peg$buildException(
-        null,
+      throw peg$buildStructuredError(
         peg$maxFailExpected,
         peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
         peg$maxFailPos < input.length
@@ -4087,5 +4143,4 @@ $globals.SmalltalkParser = (function() {
     SyntaxError: peg$SyntaxError,
     parse:       peg$parse
   };
-})();
-});
+});

+ 4 - 0
lang/base/parser.pegjs

@@ -1,3 +1,7 @@
+{
+   var $globals = $boot.globals;
+}
+
 start = method
 
 separator =

+ 2 - 3
lang/package.json

@@ -28,10 +28,9 @@
     "buildParserEnd": "});"
   },
   "scripts": {
-    "echos": "node -e \"process.stdout.write(require('./package.json').strings[process.argv[1]])\"",
-    "build:parser": "(npm run -s echos buildParserBegin && pegjs --cache --export-var \"$\"globals.SmalltalkParser < base/parser.pegjs && npm run -s echos buildParserEnd) > base/parser.js"
+    "build:parser": "pegjs --cache -o base/parser.js --format amd --dependency $boot:./boot base/parser.pegjs"
   },
   "devDependencies": {
-    "pegjs": "^0.9.0"
+    "pegjs": "^0.10.0"
   }
 }

+ 19 - 6
lang/src/Kernel-Infrastructure.js

@@ -2,6 +2,11 @@ define(["amber/boot", "require", "amber/core/Kernel-Collections", "amber/core/Ke
 var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
 var $pkg = $core.addPackage("Kernel-Infrastructure");
 $pkg.innerEval = function (expr) { return eval(expr); };
+$pkg.imports = ["smalltalkParser=amber/parser"];
+//>>excludeStart("imports", pragmas.excludeImports);
+var smalltalkParser;
+$pkg.isReady = new Promise(function (resolve, reject) { requirejs(["amber/parser"], function ($1) {smalltalkParser=$1; resolve();}, reject); });
+//>>excludeEnd("imports");
 $pkg.transport = {"type":"amd","amdNamespace":"amber/core"};
 
 $core.addClass("AmberBootstrapInitialization", $globals.Object, [], "Kernel-Infrastructure");
@@ -93,17 +98,25 @@ return $core.withContext(function($ctx1) {
 $recv($globals.SmalltalkImage)._initialize();
 $self._organizeClasses();
 $self._organizeMethods();
-return $recv($globals.Smalltalk)._postLoad();
+return $recv($recv($globals.Smalltalk)._postLoad())._then_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+return $recv($recv($globals.Smalltalk)._globals())._at_put_("SmalltalkParser",smalltalkParser);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
+//>>excludeEnd("ctx");
+}));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"run",{},$globals.AmberBootstrapInitialization.a$cls)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "run\x0a\x09SmalltalkImage initialize.\x0a\x09self\x0a\x09\x09organizeClasses;\x0a\x09\x09organizeMethods.\x0a\x09^ Smalltalk postLoad",
+source: "run\x0a\x09SmalltalkImage initialize.\x0a\x09self\x0a\x09\x09organizeClasses;\x0a\x09\x09organizeMethods.\x0a\x09^ Smalltalk postLoad\x0a\x09\x09\x22TODO remove, backward compat\x22\x0a\x09\x09then: [ Smalltalk globals at: #SmalltalkParser put: smalltalkParser ]",
 referencedClasses: ["SmalltalkImage", "Smalltalk"],
 //>>excludeEnd("ide");
-messageSends: ["initialize", "organizeClasses", "organizeMethods", "postLoad"]
+messageSends: ["initialize", "organizeClasses", "organizeMethods", "then:", "postLoad", "at:put:", "globals"]
 }),
 $globals.AmberBootstrapInitialization.a$cls);
 
@@ -3105,15 +3118,15 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-return $recv($globals.SmalltalkParser)._parse_(aString);
+return $recv(smalltalkParser)._parse_(aString);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"basicParse:",{aString:aString},$globals.SmalltalkImage)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aString"],
-source: "basicParse: aString\x0a\x09^ SmalltalkParser parse: aString",
-referencedClasses: ["SmalltalkParser"],
+source: "basicParse: aString\x0a\x09^ smalltalkParser parse: aString",
+referencedClasses: [],
 //>>excludeEnd("ide");
 messageSends: ["parse:"]
 }),

+ 4 - 1
lang/src/Kernel-Infrastructure.st

@@ -1,4 +1,5 @@
 Smalltalk createPackage: 'Kernel-Infrastructure'!
+(Smalltalk packageAt: 'Kernel-Infrastructure' ifAbsent: [ self error: 'Package not created: Kernel-Infrastructure' ]) imports: {'smalltalkParser' -> 'amber/parser'}!
 Object subclass: #AmberBootstrapInitialization
 	slots: {}
 	package: 'Kernel-Infrastructure'!
@@ -23,6 +24,8 @@ run
 		organizeClasses;
 		organizeMethods.
 	^ Smalltalk postLoad
+		"TODO remove, backward compat"
+		then: [ Smalltalk globals at: #SmalltalkParser put: smalltalkParser ]
 ! !
 
 ProtoObject subclass: #JSObjectProxy
@@ -1065,7 +1068,7 @@ basicCreatePackage: packageName
 !
 
 basicParse: aString
-	^ SmalltalkParser parse: aString
+	^ smalltalkParser parse: aString
 !
 
 deleteClass: aClass