Browse Source

Accessing via accessor arrays extracted to Lyst.

Herbert Vojčík 9 years ago
parent
commit
e36742be20
8 changed files with 658 additions and 507 deletions
  1. 1 0
      deploy.js
  2. 1 0
      local.amd.json
  3. 542 0
      src/Lyst.js
  4. 87 0
      src/Lyst.st
  5. 13 255
      src/Trapped-Backend.js
  6. 3 46
      src/Trapped-Backend.st
  7. 9 189
      src/Trapped-Frontend.js
  8. 2 17
      src/Trapped-Frontend.st

+ 1 - 0
deploy.js

@@ -1,6 +1,7 @@
 define([
     'amber/deploy',
     // --- packages to be deployed begin here ---
+    "lyst/Lyst",
     "trapped/Trapped-Backend",
     "trapped/Trapped-Processors"
     // --- packages to be deployed end here ---

+ 1 - 0
local.amd.json

@@ -2,6 +2,7 @@
     "paths": {
         "trapped": "src",
         "axon": "src",
+        "lyst": "src",
         "trapped-todo": "example-todo/src",
         "trapped-counter": "example-counter/src"
     }

+ 542 - 0
src/Lyst.js

@@ -0,0 +1,542 @@
+define("lyst/Lyst", ["amber/boot", "amber_core/Kernel-Objects", "amber_core/Kernel-Collections"], function($boot){
+var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
+$core.addPackage('Lyst');
+$core.packages["Lyst"].innerEval = function (expr) { return eval(expr); };
+$core.packages["Lyst"].transport = {"type":"amd","amdNamespace":"lyst"};
+
+$core.addClass('Lyst', $globals.Object, [], 'Lyst');
+
+$core.addMethod(
+$core.method({
+selector: "parse:",
+protocol: 'parsing',
+fn: function (message){
+var self=this;
+var result,stack,anArray;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1,$2,$3,$5,$4,$6,$7,$8,$9,$10,$11,$12;
+anArray=$recv(message)._tokenize_(" ");
+result=[];
+stack=[result];
+$recv(anArray)._do_((function(each){
+var asNum,inner,close;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+close=(0);
+close;
+inner=each;
+inner;
+$recv((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx3) {
+//>>excludeEnd("ctx");
+$1=$recv(inner)._notEmpty();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx3.sendIdx["notEmpty"]=1;
+//>>excludeEnd("ctx");
+return $recv($1)._and_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx4) {
+//>>excludeEnd("ctx");
+$2=$recv(inner)._first();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx4.sendIdx["first"]=1;
+//>>excludeEnd("ctx");
+return $recv($2).__eq("(");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx4.sendIdx["="]=1;
+//>>excludeEnd("ctx");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx4) {$ctx4.fillBlock({},$ctx3,3)});
+//>>excludeEnd("ctx");
+}));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx3.sendIdx["and:"]=1;
+//>>excludeEnd("ctx");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
+//>>excludeEnd("ctx");
+}))._whileTrue_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx3) {
+//>>excludeEnd("ctx");
+inner=$recv(inner)._allButFirst();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx3.sendIdx["allButFirst"]=1;
+//>>excludeEnd("ctx");
+inner;
+$3=stack;
+$5=$recv(stack)._last();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx3.sendIdx["last"]=1;
+//>>excludeEnd("ctx");
+$4=$recv($5)._add_([]);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx3.sendIdx["add:"]=2;
+//>>excludeEnd("ctx");
+return $recv($3)._add_($4);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx3.sendIdx["add:"]=1;
+//>>excludeEnd("ctx");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx3) {$ctx3.fillBlock({},$ctx2,4)});
+//>>excludeEnd("ctx");
+}));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx2.sendIdx["whileTrue:"]=1;
+//>>excludeEnd("ctx");
+$recv((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx3) {
+//>>excludeEnd("ctx");
+$6=$recv(inner)._notEmpty();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx3.sendIdx["notEmpty"]=2;
+//>>excludeEnd("ctx");
+return $recv($6)._and_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx4) {
+//>>excludeEnd("ctx");
+$7=$recv(inner)._last();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx4.sendIdx["last"]=2;
+//>>excludeEnd("ctx");
+return $recv($7).__eq(")");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx4.sendIdx["="]=2;
+//>>excludeEnd("ctx");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx4) {$ctx4.fillBlock({},$ctx3,6)});
+//>>excludeEnd("ctx");
+}));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx3.sendIdx["and:"]=2;
+//>>excludeEnd("ctx");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx3) {$ctx3.fillBlock({},$ctx2,5)});
+//>>excludeEnd("ctx");
+}))._whileTrue_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx3) {
+//>>excludeEnd("ctx");
+inner=$recv(inner)._allButLast();
+inner;
+close=$recv(close).__plus((1));
+return close;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx3) {$ctx3.fillBlock({},$ctx2,7)});
+//>>excludeEnd("ctx");
+}));
+$8=$recv($recv(inner)._notEmpty())._and_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx3) {
+//>>excludeEnd("ctx");
+return $recv($recv(inner)._first()).__eq("#");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx3.sendIdx["="]=3;
+//>>excludeEnd("ctx");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx3) {$ctx3.fillBlock({},$ctx2,8)});
+//>>excludeEnd("ctx");
+}));
+if($core.assert($8)){
+inner=[$recv(inner)._allButFirst()];
+inner;
+};
+$9=$recv(inner)._isString();
+if($core.assert($9)){
+asNum=$recv($recv(inner)._ifEmpty_((function(){
+return "NaN";
+
+})))._asNumber();
+} else {
+asNum=inner;
+};
+asNum;
+$10=$recv(asNum).__eq(asNum);
+if($core.assert($10)){
+$11=$recv(stack)._last();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx2.sendIdx["last"]=3;
+//>>excludeEnd("ctx");
+$recv($11)._add_(asNum);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx2.sendIdx["add:"]=3;
+//>>excludeEnd("ctx");
+} else {
+$recv(inner)._ifNotEmpty_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx3) {
+//>>excludeEnd("ctx");
+return $recv($recv(stack)._last())._add_(inner);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx3) {$ctx3.fillBlock({},$ctx2,15)});
+//>>excludeEnd("ctx");
+}));
+};
+return $recv(close)._timesRepeat_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx3) {
+//>>excludeEnd("ctx");
+return $recv(stack)._removeLast();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx3) {$ctx3.fillBlock({},$ctx2,16)});
+//>>excludeEnd("ctx");
+}));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({each:each,asNum:asNum,inner:inner,close:close},$ctx1,1)});
+//>>excludeEnd("ctx");
+}));
+$12=result;
+return $12;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"parse:",{message:message,result:result,stack:stack,anArray:anArray},$globals.Lyst.klass)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["message"],
+source: "parse: message\x0a\x09| result stack anArray |\x0a\x09anArray := message tokenize: ' '.\x0a\x09result := #().\x0a\x09stack := { result }.\x0a\x09anArray do: [ :each |\x0a\x09\x09| asNum inner close |\x0a\x09\x09close := 0.\x0a\x09\x09inner := each.\x0a\x09\x09[ inner notEmpty and: [ inner first = '(' ]] whileTrue: [ inner := inner allButFirst. stack add: (stack last add: #()) ].\x0a\x09\x09[ inner notEmpty and: [ inner last = ')' ]] whileTrue: [ inner := inner allButLast. close := close + 1 ].\x0a\x09\x09(inner notEmpty and: [ inner first = '#' ]) ifTrue: [ inner := { inner allButFirst } ].\x0a\x09\x09asNum := inner isString ifTrue: [ (inner ifEmpty: [ 'NaN' ]) asNumber ] ifFalse: [ inner ].\x0a\x09\x09asNum = asNum ifTrue: [ stack last add: asNum ] ifFalse: [\x0a\x09\x09\x09inner ifNotEmpty: [ stack last add: inner ] ].\x0a\x09\x09close timesRepeat: [ stack removeLast ] ].\x0a\x09^ result",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["tokenize:", "do:", "whileTrue:", "and:", "notEmpty", "=", "first", "allButFirst", "add:", "last", "allButLast", "+", "ifTrue:", "ifTrue:ifFalse:", "isString", "asNumber", "ifEmpty:", "ifNotEmpty:", "timesRepeat:", "removeLast"]
+}),
+$globals.Lyst.klass);
+
+$core.addMethod(
+$core.method({
+selector: "atYndexIn:ifAbsent:",
+protocol: '*Lyst',
+fn: function (anObject,aBlock){
+var self=this;
+var selector;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1,$2;
+var $early={};
+try {
+selector=self._first();
+$1=$recv(anObject)._respondsTo_(selector);
+$recv($1)._ifTrue_ifFalse_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+$2=$recv(anObject)._perform_(selector);
+throw $early=[$2];
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
+//>>excludeEnd("ctx");
+}),aBlock);
+return self;
+}
+catch(e) {if(e===$early)return e[0]; throw e}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:",{anObject:anObject,aBlock:aBlock,selector:selector},$globals.Array)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anObject", "aBlock"],
+source: "atYndexIn: anObject ifAbsent: aBlock\x0a\x09| selector |\x0a\x09selector := self first.\x0a\x09(anObject respondsTo: selector)\x0a\x09\x09ifTrue: [ ^ anObject perform: selector ]\x0a\x09\x09ifFalse: aBlock",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["first", "ifTrue:ifFalse:", "respondsTo:", "perform:"]
+}),
+$globals.Array);
+
+$core.addMethod(
+$core.method({
+selector: "atYndexIn:ifAbsent:put:",
+protocol: '*Lyst',
+fn: function (anObject,aBlock,anotherObject){
+var self=this;
+var selector;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1,$2;
+var $early={};
+try {
+selector=$recv(self._first())._asMutator();
+$1=$recv(anObject)._respondsTo_(selector);
+$recv($1)._ifTrue_ifFalse_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+$2=$recv(anObject)._perform_withArguments_(selector,[anotherObject]);
+throw $early=[$2];
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
+//>>excludeEnd("ctx");
+}),aBlock);
+return self;
+}
+catch(e) {if(e===$early)return e[0]; throw e}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:put:",{anObject:anObject,aBlock:aBlock,anotherObject:anotherObject,selector:selector},$globals.Array)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anObject", "aBlock", "anotherObject"],
+source: "atYndexIn: anObject ifAbsent: aBlock put: anotherObject\x0a\x09| selector |\x0a\x09selector := self first asMutator.\x0a\x09(anObject respondsTo: selector)\x0a\x09\x09ifTrue: [ ^ anObject perform: selector withArguments: { anotherObject } ]\x0a\x09\x09ifFalse: aBlock",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["asMutator", "first", "ifTrue:ifFalse:", "respondsTo:", "perform:withArguments:"]
+}),
+$globals.Array);
+
+$core.addMethod(
+$core.method({
+selector: "atYndexIn:ifAbsent:",
+protocol: '*Lyst',
+fn: function (anObject,aBlock){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1,$2;
+var $early={};
+try {
+$1=$recv(anObject)._respondsTo_("at:ifAbsent:");
+$recv($1)._ifTrue_ifFalse_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+$2=$recv(anObject)._at_ifAbsent_(self,aBlock);
+throw $early=[$2];
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
+//>>excludeEnd("ctx");
+}),aBlock);
+return self;
+}
+catch(e) {if(e===$early)return e[0]; throw e}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:",{anObject:anObject,aBlock:aBlock},$globals.Number)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anObject", "aBlock"],
+source: "atYndexIn: anObject ifAbsent: aBlock\x0a\x09(anObject respondsTo: #at:ifAbsent:)\x0a\x09\x09ifTrue: [ ^ anObject at: self ifAbsent: aBlock ]\x0a\x09\x09ifFalse: aBlock",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["ifTrue:ifFalse:", "respondsTo:", "at:ifAbsent:"]
+}),
+$globals.Number);
+
+$core.addMethod(
+$core.method({
+selector: "atYndexIn:ifAbsent:put:",
+protocol: '*Lyst',
+fn: function (anObject,aBlock,anotherObject){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1,$2;
+var $early={};
+try {
+$1=$recv(anObject)._respondsTo_("at:put:");
+$recv($1)._ifTrue_ifFalse_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+$2=$recv(anObject)._at_put_(self,anotherObject);
+throw $early=[$2];
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
+//>>excludeEnd("ctx");
+}),aBlock);
+return self;
+}
+catch(e) {if(e===$early)return e[0]; throw e}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:put:",{anObject:anObject,aBlock:aBlock,anotherObject:anotherObject},$globals.Number)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anObject", "aBlock", "anotherObject"],
+source: "atYndexIn: anObject ifAbsent: aBlock put: anotherObject\x0a\x09(anObject respondsTo: #at:put:)\x0a\x09\x09ifTrue: [ ^ anObject at: self put: anotherObject ]\x0a\x09\x09ifFalse: aBlock",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["ifTrue:ifFalse:", "respondsTo:", "at:put:"]
+}),
+$globals.Number);
+
+$core.addMethod(
+$core.method({
+selector: "atLyst:ifAbsent:",
+protocol: '*Lyst',
+fn: function (aCollection,aBlock){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $2,$1;
+var $early={};
+try {
+$1=$recv(aCollection)._inject_into_(self,(function(soFar,segment){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+return $recv(segment)._atYndexIn_ifAbsent_(soFar,(function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx3) {
+//>>excludeEnd("ctx");
+$2=$recv(aBlock)._value();
+throw $early=[$2];
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
+//>>excludeEnd("ctx");
+}));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({soFar:soFar,segment:segment},$ctx1,1)});
+//>>excludeEnd("ctx");
+}));
+return $1;
+}
+catch(e) {if(e===$early)return e[0]; throw e}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"atLyst:ifAbsent:",{aCollection:aCollection,aBlock:aBlock},$globals.Object)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aCollection", "aBlock"],
+source: "atLyst: aCollection ifAbsent: aBlock\x0a\x09^ aCollection inject: self into: [ :soFar :segment |\x0a\x09\x09segment atYndexIn: soFar ifAbsent: [ ^ aBlock value ]]",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["inject:into:", "atYndexIn:ifAbsent:", "value"]
+}),
+$globals.Object);
+
+$core.addMethod(
+$core.method({
+selector: "atYndexIn:ifAbsent:",
+protocol: '*Lyst',
+fn: function (anObject,aBlock){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$recv(aBlock)._value();
+return $1;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:",{anObject:anObject,aBlock:aBlock},$globals.Object)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anObject", "aBlock"],
+source: "atYndexIn: anObject ifAbsent: aBlock\x0a\x09^ aBlock value",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["value"]
+}),
+$globals.Object);
+
+$core.addMethod(
+$core.method({
+selector: "atYndexIn:ifAbsent:put:",
+protocol: '*Lyst',
+fn: function (anObject,aBlock,anotherObject){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$recv(aBlock)._value();
+return $1;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:put:",{anObject:anObject,aBlock:aBlock,anotherObject:anotherObject},$globals.Object)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anObject", "aBlock", "anotherObject"],
+source: "atYndexIn: anObject ifAbsent: aBlock put: anotherObject\x0a\x09^ aBlock value",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["value"]
+}),
+$globals.Object);
+
+$core.addMethod(
+$core.method({
+selector: "atYndexIn:ifAbsent:",
+protocol: '*Lyst',
+fn: function (anObject,aBlock){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1,$2;
+var $early={};
+try {
+$1=$recv(anObject)._respondsTo_("at:ifAbsent:");
+$recv($1)._ifTrue_ifFalse_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+$2=$recv(anObject)._at_ifAbsent_(self,aBlock);
+throw $early=[$2];
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
+//>>excludeEnd("ctx");
+}),aBlock);
+return self;
+}
+catch(e) {if(e===$early)return e[0]; throw e}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:",{anObject:anObject,aBlock:aBlock},$globals.String)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anObject", "aBlock"],
+source: "atYndexIn: anObject ifAbsent: aBlock\x0a\x09(anObject respondsTo: #at:ifAbsent:)\x0a\x09\x09ifTrue: [ ^ anObject at: self ifAbsent: aBlock ]\x0a\x09\x09ifFalse: aBlock",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["ifTrue:ifFalse:", "respondsTo:", "at:ifAbsent:"]
+}),
+$globals.String);
+
+$core.addMethod(
+$core.method({
+selector: "atYndexIn:ifAbsent:put:",
+protocol: '*Lyst',
+fn: function (anObject,aBlock,anotherObject){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1,$2;
+var $early={};
+try {
+$1=$recv(anObject)._respondsTo_("at:put:");
+$recv($1)._ifTrue_ifFalse_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+$2=$recv(anObject)._at_put_(self,anotherObject);
+throw $early=[$2];
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
+//>>excludeEnd("ctx");
+}),aBlock);
+return self;
+}
+catch(e) {if(e===$early)return e[0]; throw e}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"atYndexIn:ifAbsent:put:",{anObject:anObject,aBlock:aBlock,anotherObject:anotherObject},$globals.String)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anObject", "aBlock", "anotherObject"],
+source: "atYndexIn: anObject ifAbsent: aBlock put: anotherObject\x0a\x09(anObject respondsTo: #at:put:)\x0a\x09\x09ifTrue: [ ^ anObject at: self put: anotherObject ]\x0a\x09\x09ifFalse: aBlock",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["ifTrue:ifFalse:", "respondsTo:", "at:put:"]
+}),
+$globals.String);
+
+});

+ 87 - 0
src/Lyst.st

@@ -0,0 +1,87 @@
+Smalltalk createPackage: 'Lyst'!
+Object subclass: #Lyst
+	instanceVariableNames: ''
+	package: 'Lyst'!
+
+!Lyst class methodsFor: 'parsing'!
+
+parse: message
+	| result stack anArray |
+	anArray := message tokenize: ' '.
+	result := #().
+	stack := { result }.
+	anArray do: [ :each |
+		| asNum inner close |
+		close := 0.
+		inner := each.
+		[ inner notEmpty and: [ inner first = '(' ]] whileTrue: [ inner := inner allButFirst. stack add: (stack last add: #()) ].
+		[ inner notEmpty and: [ inner last = ')' ]] whileTrue: [ inner := inner allButLast. close := close + 1 ].
+		(inner notEmpty and: [ inner first = '#' ]) ifTrue: [ inner := { inner allButFirst } ].
+		asNum := inner isString ifTrue: [ (inner ifEmpty: [ 'NaN' ]) asNumber ] ifFalse: [ inner ].
+		asNum = asNum ifTrue: [ stack last add: asNum ] ifFalse: [
+			inner ifNotEmpty: [ stack last add: inner ] ].
+		close timesRepeat: [ stack removeLast ] ].
+	^ result
+! !
+
+!Array methodsFor: '*Lyst'!
+
+atYndexIn: anObject ifAbsent: aBlock
+	| selector |
+	selector := self first.
+	(anObject respondsTo: selector)
+		ifTrue: [ ^ anObject perform: selector ]
+		ifFalse: aBlock
+!
+
+atYndexIn: anObject ifAbsent: aBlock put: anotherObject
+	| selector |
+	selector := self first asMutator.
+	(anObject respondsTo: selector)
+		ifTrue: [ ^ anObject perform: selector withArguments: { anotherObject } ]
+		ifFalse: aBlock
+! !
+
+!Number methodsFor: '*Lyst'!
+
+atYndexIn: anObject ifAbsent: aBlock
+	(anObject respondsTo: #at:ifAbsent:)
+		ifTrue: [ ^ anObject at: self ifAbsent: aBlock ]
+		ifFalse: aBlock
+!
+
+atYndexIn: anObject ifAbsent: aBlock put: anotherObject
+	(anObject respondsTo: #at:put:)
+		ifTrue: [ ^ anObject at: self put: anotherObject ]
+		ifFalse: aBlock
+! !
+
+!Object methodsFor: '*Lyst'!
+
+atLyst: aCollection ifAbsent: aBlock
+	^ aCollection inject: self into: [ :soFar :segment |
+		segment atYndexIn: soFar ifAbsent: [ ^ aBlock value ]]
+!
+
+atYndexIn: anObject ifAbsent: aBlock
+	^ aBlock value
+!
+
+atYndexIn: anObject ifAbsent: aBlock put: anotherObject
+	^ aBlock value
+! !
+
+!String methodsFor: '*Lyst'!
+
+atYndexIn: anObject ifAbsent: aBlock
+	(anObject respondsTo: #at:ifAbsent:)
+		ifTrue: [ ^ anObject at: self ifAbsent: aBlock ]
+		ifFalse: aBlock
+!
+
+atYndexIn: anObject ifAbsent: aBlock put: anotherObject
+	(anObject respondsTo: #at:put:)
+		ifTrue: [ ^ anObject at: self put: anotherObject ]
+		ifFalse: aBlock
+! !
+

+ 13 - 255
src/Trapped-Backend.js

@@ -705,176 +705,6 @@ messageSends: ["asEavModel", ",", "model:read:"]
 $globals.IsolatingTrapper);
 
 
-$core.addMethod(
-$core.method({
-selector: "asTrapAtPut:sendTo:",
-protocol: '*Trapped-Backend',
-fn: function (value,anObject){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1;
-$1=$recv(anObject)._perform_withArguments_($recv($recv(self._first()).__comma(":"))._asSymbol(),[value]);
-return $1;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"asTrapAtPut:sendTo:",{value:value,anObject:anObject},$globals.Array)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["value", "anObject"],
-source: "asTrapAtPut: value sendTo: anObject\x0a    ^anObject perform: (self first, ':') asSymbol withArguments: { value }",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["perform:withArguments:", "asSymbol", ",", "first"]
-}),
-$globals.Array);
-
-$core.addMethod(
-$core.method({
-selector: "asTrapAtSendTo:",
-protocol: '*Trapped-Backend',
-fn: function (anObject){
-var self=this;
-function $MessageNotUnderstood(){return $globals.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1;
-var $early={};
-try {
-$1=$recv((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
-//>>excludeEnd("ctx");
-return $recv(anObject)._perform_(self._first());
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
-//>>excludeEnd("ctx");
-}))._on_do_($MessageNotUnderstood(),(function(){
-throw $early=[nil];
-
-}));
-return $1;
-}
-catch(e) {if(e===$early)return e[0]; throw e}
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"asTrapAtSendTo:",{anObject:anObject},$globals.Array)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["anObject"],
-source: "asTrapAtSendTo: anObject\x0a\x09^[anObject perform: self first] on: MessageNotUnderstood do: [^nil]",
-referencedClasses: ["MessageNotUnderstood"],
-//>>excludeEnd("ide");
-messageSends: ["on:do:", "perform:", "first"]
-}),
-$globals.Array);
-
-$core.addMethod(
-$core.method({
-selector: "asTrapAtPut:sendTo:",
-protocol: '*Trapped-Backend',
-fn: function (value,anObject){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1;
-$1=$recv(anObject)._at_put_(self,value);
-return $1;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"asTrapAtPut:sendTo:",{value:value,anObject:anObject},$globals.Number)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["value", "anObject"],
-source: "asTrapAtPut: value sendTo: anObject\x0a\x09^anObject at: self put: value",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["at:put:"]
-}),
-$globals.Number);
-
-$core.addMethod(
-$core.method({
-selector: "asTrapAtSendTo:",
-protocol: '*Trapped-Backend',
-fn: function (anObject){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1,$receiver;
-if(($receiver = anObject) == null || $receiver.isNil){
-$1=anObject;
-} else {
-$1=$recv(anObject)._at_ifAbsent_(self,(function(){
-return nil;
-
-}));
-};
-return $1;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"asTrapAtSendTo:",{anObject:anObject},$globals.Number)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["anObject"],
-source: "asTrapAtSendTo: anObject\x0a\x09^anObject ifNotNil: [ anObject at: self ifAbsent: [nil] ]",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["ifNotNil:", "at:ifAbsent:"]
-}),
-$globals.Number);
-
-$core.addMethod(
-$core.method({
-selector: "asTrapAtPut:sendTo:",
-protocol: '*Trapped-Backend',
-fn: function (value,anObject){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1;
-$1=$recv("Trapped cannot put at ".__comma($recv(self._class())._name())).__comma(" type key.");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx[","]=1;
-//>>excludeEnd("ctx");
-self._error_($1);
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"asTrapAtPut:sendTo:",{value:value,anObject:anObject},$globals.Object)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["value", "anObject"],
-source: "asTrapAtPut: value sendTo: anObject\x0a\x09self error: 'Trapped cannot put at ', self class name, ' type key.'",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["error:", ",", "name", "class"]
-}),
-$globals.Object);
-
-$core.addMethod(
-$core.method({
-selector: "asTrapAtSendTo:",
-protocol: '*Trapped-Backend',
-fn: function (anObject){
-var self=this;
-return nil;
-
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["anObject"],
-source: "asTrapAtSendTo: anObject\x0a\x09^nil",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.Object);
-
 $core.addMethod(
 $core.method({
 selector: "asEavModel",
@@ -886,26 +716,18 @@ function $EavModel(){return $globals.EavModel||(typeof EavModel=="undefined"?nil
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2,$receiver;
+var $1,$2;
 model=$recv($EavModel())._new();
 $recv(model)._getBlock_((function(anObject){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-return self._inject_into_(anObject,(function(soFar,segment){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx3) {
-//>>excludeEnd("ctx");
-return $recv(segment)._asTrapAtSendTo_(soFar);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx3.sendIdx["asTrapAtSendTo:"]=1;
-//>>excludeEnd("ctx");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx3) {$ctx3.fillBlock({soFar:soFar,segment:segment},$ctx2,2)});
-//>>excludeEnd("ctx");
+return $recv(anObject)._atLyst_ifAbsent_(self,(function(){
+return nil;
+
 }));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx2.sendIdx["inject:into:"]=1;
+$ctx2.sendIdx["atLyst:ifAbsent:"]=1;
 //>>excludeEnd("ctx");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({anObject:anObject},$ctx1,1)});
@@ -918,21 +740,14 @@ var penultimate;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-penultimate=$recv(self._allButLast())._inject_into_(anObject,(function(soFar,segment){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx3) {
-//>>excludeEnd("ctx");
-if(($receiver = soFar) == null || $receiver.isNil){
-return soFar;
-} else {
-return $recv(segment)._asTrapAtSendTo_(soFar);
-};
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx3) {$ctx3.fillBlock({soFar:soFar,segment:segment},$ctx2,5)});
-//>>excludeEnd("ctx");
+penultimate=$recv(anObject)._atLyst_ifAbsent_(self._allButLast(),(function(){
+return nil;
+
 }));
 penultimate;
-return $recv(self._last())._asTrapAtPut_sendTo_(value,penultimate);
+return $recv(self._last())._atYndexIn_ifAbsent_put_(penultimate,(function(){
+
+}),value);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({anObject:anObject,value:value,penultimate:penultimate},$ctx1,4)});
 //>>excludeEnd("ctx");
@@ -946,68 +761,11 @@ return $2;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "asEavModel\x0a    | model |\x0a    model := EavModel new.\x0a    model getBlock: [ :anObject |\x0a        self inject: anObject into: [ :soFar :segment |\x0a            segment asTrapAtSendTo: soFar ]].\x0a    self isEmpty ifFalse: [\x0a        model putBlock: [ :anObject :value | | penultimate |\x0a            penultimate :=  self allButLast inject: anObject into: [ :soFar :segment |\x0a                soFar ifNotNil: [ segment asTrapAtSendTo: soFar ]].\x0a            self last asTrapAtPut:value sendTo: penultimate ]].\x0a    ^model",
+source: "asEavModel\x0a    | model |\x0a    model := EavModel new.\x0a    model getBlock: [ :anObject | anObject atLyst: self ifAbsent: [ nil ] ].\x0a    self isEmpty ifFalse: [\x0a        model putBlock: [ :anObject :value | | penultimate |\x0a            penultimate := anObject atLyst: self allButLast ifAbsent: [ nil ].\x0a            self last atYndexIn: penultimate ifAbsent: [] put: value ]].\x0a    ^model",
 referencedClasses: ["EavModel"],
 //>>excludeEnd("ide");
-messageSends: ["new", "getBlock:", "inject:into:", "asTrapAtSendTo:", "ifFalse:", "isEmpty", "putBlock:", "allButLast", "ifNotNil:", "asTrapAtPut:sendTo:", "last"]
+messageSends: ["new", "getBlock:", "atLyst:ifAbsent:", "ifFalse:", "isEmpty", "putBlock:", "allButLast", "atYndexIn:ifAbsent:put:", "last"]
 }),
 $globals.SequenceableCollection);
 
-$core.addMethod(
-$core.method({
-selector: "asTrapAtPut:sendTo:",
-protocol: '*Trapped-Backend',
-fn: function (value,anObject){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1;
-$1=$recv(anObject)._at_put_(self,value);
-return $1;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"asTrapAtPut:sendTo:",{value:value,anObject:anObject},$globals.String)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["value", "anObject"],
-source: "asTrapAtPut: value sendTo: anObject\x0a\x09^anObject at: self put: value",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["at:put:"]
-}),
-$globals.String);
-
-$core.addMethod(
-$core.method({
-selector: "asTrapAtSendTo:",
-protocol: '*Trapped-Backend',
-fn: function (anObject){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1,$receiver;
-if(($receiver = anObject) == null || $receiver.isNil){
-$1=anObject;
-} else {
-$1=$recv(anObject)._at_ifAbsent_(self,(function(){
-return nil;
-
-}));
-};
-return $1;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"asTrapAtSendTo:",{anObject:anObject},$globals.String)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["anObject"],
-source: "asTrapAtSendTo: anObject\x0a\x09^anObject ifNotNil: [ anObject at: self ifAbsent: [nil] ]",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["ifNotNil:", "at:ifAbsent:"]
-}),
-$globals.String);
-
 });

+ 3 - 46
src/Trapped-Backend.st

@@ -206,59 +206,16 @@ read: path do: aBlock
     payload model: eavModel read: aBlock
 ! !
 
-!Array methodsFor: '*Trapped-Backend'!
-
-asTrapAtPut: value sendTo: anObject
-    ^anObject perform: (self first, ':') asSymbol withArguments: { value }
-!
-
-asTrapAtSendTo: anObject
-	^[anObject perform: self first] on: MessageNotUnderstood do: [^nil]
-! !
-
-!Number methodsFor: '*Trapped-Backend'!
-
-asTrapAtPut: value sendTo: anObject
-	^anObject at: self put: value
-!
-
-asTrapAtSendTo: anObject
-	^anObject ifNotNil: [ anObject at: self ifAbsent: [nil] ]
-! !
-
-!Object methodsFor: '*Trapped-Backend'!
-
-asTrapAtPut: value sendTo: anObject
-	self error: 'Trapped cannot put at ', self class name, ' type key.'
-!
-
-asTrapAtSendTo: anObject
-	^nil
-! !
-
 !SequenceableCollection methodsFor: '*Trapped-Backend'!
 
 asEavModel
     | model |
     model := EavModel new.
-    model getBlock: [ :anObject |
-        self inject: anObject into: [ :soFar :segment |
-            segment asTrapAtSendTo: soFar ]].
+    model getBlock: [ :anObject | anObject atLyst: self ifAbsent: [ nil ] ].
     self isEmpty ifFalse: [
         model putBlock: [ :anObject :value | | penultimate |
-            penultimate :=  self allButLast inject: anObject into: [ :soFar :segment |
-                soFar ifNotNil: [ segment asTrapAtSendTo: soFar ]].
-            self last asTrapAtPut:value sendTo: penultimate ]].
+            penultimate := anObject atLyst: self allButLast ifAbsent: [ nil ].
+            self last atYndexIn: penultimate ifAbsent: [] put: value ]].
     ^model
 ! !
 
-!String methodsFor: '*Trapped-Backend'!
-
-asTrapAtPut: value sendTo: anObject
-	^anObject at: self put: value
-!
-
-asTrapAtSendTo: anObject
-	^anObject ifNotNil: [ anObject at: self ifAbsent: [nil] ]
-! !
-

+ 9 - 189
src/Trapped-Frontend.js

@@ -1402,13 +1402,14 @@ $globals.Trapped.klass);
 $core.addMethod(
 $core.method({
 selector: "parse:",
-protocol: 'accessing',
+protocol: 'parsing',
 fn: function (aString){
 var self=this;
+function $Lyst(){return $globals.Lyst||(typeof Lyst=="undefined"?nil:Lyst)}
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $2,$3,$4,$5,$6,$8,$7,$9,$10,$11,$12,$13,$14,$1;
+var $2,$1;
 $2=$recv(aString)._tokenize_(".");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["tokenize:"]=1;
@@ -1417,194 +1418,13 @@ $1=$recv($2)._collect_((function(rule){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-$3=$recv(rule)._tokenize_(":");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx2.sendIdx["tokenize:"]=2;
-//>>excludeEnd("ctx");
-return $recv($3)._collect_((function(message){
-var result,stack,anArray;
+return $recv($recv(rule)._tokenize_(":"))._collect_((function(message){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx3) {
 //>>excludeEnd("ctx");
-anArray=$recv(message)._tokenize_(" ");
-anArray;
-result=[];
-result;
-stack=[result];
-stack;
-$recv(anArray)._do_((function(each){
-var asNum,inner,close;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx4) {
-//>>excludeEnd("ctx");
-close=(0);
-close;
-inner=each;
-inner;
-$recv((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx5) {
-//>>excludeEnd("ctx");
-$4=$recv(inner)._notEmpty();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx5.sendIdx["notEmpty"]=1;
-//>>excludeEnd("ctx");
-return $recv($4)._and_((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx6) {
-//>>excludeEnd("ctx");
-$5=$recv(inner)._first();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx6.sendIdx["first"]=1;
-//>>excludeEnd("ctx");
-return $recv($5).__eq("(");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx6.sendIdx["="]=1;
-//>>excludeEnd("ctx");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx6) {$ctx6.fillBlock({},$ctx5,5)});
-//>>excludeEnd("ctx");
-}));
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx5.sendIdx["and:"]=1;
-//>>excludeEnd("ctx");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx5) {$ctx5.fillBlock({},$ctx4,4)});
-//>>excludeEnd("ctx");
-}))._whileTrue_((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx5) {
-//>>excludeEnd("ctx");
-inner=$recv(inner)._allButFirst();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx5.sendIdx["allButFirst"]=1;
-//>>excludeEnd("ctx");
-inner;
-$6=stack;
-$8=$recv(stack)._last();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx5.sendIdx["last"]=1;
-//>>excludeEnd("ctx");
-$7=$recv($8)._add_([]);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx5.sendIdx["add:"]=2;
-//>>excludeEnd("ctx");
-return $recv($6)._add_($7);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx5.sendIdx["add:"]=1;
-//>>excludeEnd("ctx");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx5) {$ctx5.fillBlock({},$ctx4,6)});
-//>>excludeEnd("ctx");
-}));
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx4.sendIdx["whileTrue:"]=1;
-//>>excludeEnd("ctx");
-$recv((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx5) {
-//>>excludeEnd("ctx");
-$9=$recv(inner)._notEmpty();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx5.sendIdx["notEmpty"]=2;
-//>>excludeEnd("ctx");
-return $recv($9)._and_((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx6) {
-//>>excludeEnd("ctx");
-$10=$recv(inner)._last();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx6.sendIdx["last"]=2;
-//>>excludeEnd("ctx");
-return $recv($10).__eq(")");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx6.sendIdx["="]=2;
-//>>excludeEnd("ctx");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx6) {$ctx6.fillBlock({},$ctx5,8)});
-//>>excludeEnd("ctx");
-}));
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx5.sendIdx["and:"]=2;
-//>>excludeEnd("ctx");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx5) {$ctx5.fillBlock({},$ctx4,7)});
-//>>excludeEnd("ctx");
-}))._whileTrue_((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx5) {
-//>>excludeEnd("ctx");
-inner=$recv(inner)._allButLast();
-inner;
-close=$recv(close).__plus((1));
-return close;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx5) {$ctx5.fillBlock({},$ctx4,9)});
-//>>excludeEnd("ctx");
-}));
-$11=$recv($recv(inner)._notEmpty())._and_((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx5) {
-//>>excludeEnd("ctx");
-return $recv($recv(inner)._first()).__eq("#");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx5.sendIdx["="]=3;
-//>>excludeEnd("ctx");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx5) {$ctx5.fillBlock({},$ctx4,10)});
-//>>excludeEnd("ctx");
-}));
-if($core.assert($11)){
-inner=[$recv(inner)._allButFirst()];
-inner;
-};
-$12=$recv(inner)._isString();
-if($core.assert($12)){
-asNum=$recv($recv(inner)._ifEmpty_((function(){
-return "NaN";
-
-})))._asNumber();
-} else {
-asNum=inner;
-};
-asNum;
-$13=$recv(asNum).__eq(asNum);
-if($core.assert($13)){
-$14=$recv(stack)._last();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx4.sendIdx["last"]=3;
-//>>excludeEnd("ctx");
-$recv($14)._add_(asNum);
+return $recv($Lyst())._parse_(message);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx4.sendIdx["add:"]=3;
-//>>excludeEnd("ctx");
-} else {
-$recv(inner)._ifNotEmpty_((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx5) {
-//>>excludeEnd("ctx");
-return $recv($recv(stack)._last())._add_(inner);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx5) {$ctx5.fillBlock({},$ctx4,17)});
-//>>excludeEnd("ctx");
-}));
-};
-return $recv(close)._timesRepeat_((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx5) {
-//>>excludeEnd("ctx");
-return $recv(stack)._removeLast();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx5) {$ctx5.fillBlock({},$ctx4,18)});
-//>>excludeEnd("ctx");
-}));
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx4) {$ctx4.fillBlock({each:each,asNum:asNum,inner:inner,close:close},$ctx3,3)});
-//>>excludeEnd("ctx");
-}));
-return result;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx3) {$ctx3.fillBlock({message:message,result:result,stack:stack,anArray:anArray},$ctx2,2)});
+}, function($ctx3) {$ctx3.fillBlock({message:message},$ctx2,2)});
 //>>excludeEnd("ctx");
 }));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -1621,10 +1441,10 @@ return $1;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aString"],
-source: "parse: aString\x0a\x09^ (aString tokenize: '.') collect: [ :rule |\x0a\x09\x09(rule tokenize: ':') collect: [ :message |\x0a\x09\x09\x09| result stack anArray |\x0a\x09\x09\x09anArray := message tokenize: ' '.\x0a\x09\x09\x09result := #().\x0a\x09\x09\x09stack := { result }.\x0a\x09\x09\x09anArray do: [ :each |\x0a    \x09\x09\x09| asNum inner close |\x0a\x09\x09\x09\x09close := 0.\x0a\x09\x09\x09\x09inner := each.\x0a\x09\x09\x09\x09[ inner notEmpty and: [ inner first = '(' ]] whileTrue: [ inner := inner allButFirst. stack add: (stack last add: #()) ].\x0a\x09\x09\x09\x09[ inner notEmpty and: [ inner last = ')' ]] whileTrue: [ inner := inner allButLast. close := close + 1 ].\x0a\x09\x09\x09\x09(inner notEmpty and: [ inner first = '#' ]) ifTrue: [ inner := { inner allButFirst } ].\x0a\x09\x09       \x09asNum := inner isString ifTrue: [ (inner ifEmpty: [ 'NaN' ]) asNumber ] ifFalse: [ inner ].\x0a        \x09\x09asNum = asNum ifTrue: [ stack last add: asNum ] ifFalse: [\x0a\x09\x09\x09\x09\x09inner ifNotEmpty: [ stack last add: inner ] ].\x0a\x09\x09\x09\x09close timesRepeat: [ stack removeLast ] ].\x0a\x09\x09\x09result ] ]",
-referencedClasses: [],
+source: "parse: aString\x0a\x09^ (aString tokenize: '.') collect: [ :rule |\x0a\x09\x09(rule tokenize: ':') collect: [ :message |\x0a\x09\x09\x09Lyst parse: message ] ]",
+referencedClasses: ["Lyst"],
 //>>excludeEnd("ide");
-messageSends: ["collect:", "tokenize:", "do:", "whileTrue:", "and:", "notEmpty", "=", "first", "allButFirst", "add:", "last", "allButLast", "+", "ifTrue:", "ifTrue:ifFalse:", "isString", "asNumber", "ifEmpty:", "ifNotEmpty:", "timesRepeat:", "removeLast"]
+messageSends: ["collect:", "tokenize:", "parse:"]
 }),
 $globals.Trapped.klass);
 

+ 2 - 17
src/Trapped-Frontend.st

@@ -357,27 +357,12 @@ injectToElement: anElement
 	self injectToChildren: anElement
 ! !
 
-!Trapped class methodsFor: 'accessing'!
+!Trapped class methodsFor: 'parsing'!
 
 parse: aString
 	^ (aString tokenize: '.') collect: [ :rule |
 		(rule tokenize: ':') collect: [ :message |
-			| result stack anArray |
-			anArray := message tokenize: ' '.
-			result := #().
-			stack := { result }.
-			anArray do: [ :each |
-    			| asNum inner close |
-				close := 0.
-				inner := each.
-				[ inner notEmpty and: [ inner first = '(' ]] whileTrue: [ inner := inner allButFirst. stack add: (stack last add: #()) ].
-				[ inner notEmpty and: [ inner last = ')' ]] whileTrue: [ inner := inner allButLast. close := close + 1 ].
-				(inner notEmpty and: [ inner first = '#' ]) ifTrue: [ inner := { inner allButFirst } ].
-		       	asNum := inner isString ifTrue: [ (inner ifEmpty: [ 'NaN' ]) asNumber ] ifFalse: [ inner ].
-        		asNum = asNum ifTrue: [ stack last add: asNum ] ifFalse: [
-					inner ifNotEmpty: [ stack last add: inner ] ].
-				close timesRepeat: [ stack removeLast ] ].
-			result ] ]
+			Lyst parse: message ] ]
 ! !
 
 !Trapped class methodsFor: 'private'!