Browse Source

Use "attr = value" syntax instead "attr: value" one.

Herbert Vojčík 7 years ago
parent
commit
352c6331a1
2 changed files with 101 additions and 79 deletions
  1. 92 72
      support/parser.js
  2. 9 7
      support/parser.pegjs

+ 92 - 72
support/parser.js

@@ -264,46 +264,48 @@ $globals.SmalltalkParser = (function() {
         			._dagChildren_(messages);
         	},
         peg$c113 = function(operand) {return operand;},
-        peg$c114 = function(key, value) {
+        peg$c114 = "=",
+        peg$c115 = { type: "literal", value: "=", description: "\"=\"" },
+        peg$c116 = function(selector, value) {
         	return $globals.SendNode._new()
         		._location_(location())
         		._source_(text())
-        		._selector_(key)
+        		._selector_(selector + ':')
         		._arguments_([value]);
         },
-        peg$c115 = "<",
-        peg$c116 = { type: "literal", value: "<", description: "\"<\"" },
-        peg$c117 = function(tag, messages, operands) {return operands;},
-        peg$c118 = ">",
-        peg$c119 = { type: "literal", value: ">", description: "\">\"" },
-        peg$c120 = function(tag, messages, operands) {
+        peg$c117 = "<",
+        peg$c118 = { type: "literal", value: "<", description: "\"<\"" },
+        peg$c119 = function(tag, attributes, operands) {return operands;},
+        peg$c120 = ">",
+        peg$c121 = { type: "literal", value: ">", description: "\">\"" },
+        peg$c122 = function(tag, attributes, children) {
         		return $globals.StxNode._new()
         			._location_(location())
         			._source_(text())
         			._tag_(tag)
-        			._attributes_(messages)
-        			._children_(operands || []);
+        			._attributes_(attributes)
+        			._children_(children || []);
         	},
-        peg$c121 = ">>",
-        peg$c122 = { type: "literal", value: ">>", description: "\">>\"" },
-        peg$c123 = function() {return '>';},
-        peg$c124 = /^[^>]/,
-        peg$c125 = { type: "class", value: "[^>]", description: "[^>]" },
-        peg$c126 = function(val) {return !/^\s*inlineJS/.test(val.join(''));},
-        peg$c127 = function(val) {
+        peg$c123 = ">>",
+        peg$c124 = { type: "literal", value: ">>", description: "\">>\"" },
+        peg$c125 = function() {return '>';},
+        peg$c126 = /^[^>]/,
+        peg$c127 = { type: "class", value: "[^>]", description: "[^>]" },
+        peg$c128 = function(val) {return !/^\s*inlineJS/.test(val.join(''));},
+        peg$c129 = function(val) {
         		console.warn('Use of <...js code...> is deprecated, in:\n' + val.join(''));
         		return $globals.JSStatementNode._new()
         			._location_(location())
         			._source_(val.join(''))
         	},
-        peg$c128 = "inlineJS:",
-        peg$c129 = { type: "literal", value: "inlineJS:", description: "\"inlineJS:\"" },
-        peg$c130 = function(val) {
+        peg$c130 = "inlineJS:",
+        peg$c131 = { type: "literal", value: "inlineJS:", description: "\"inlineJS:\"" },
+        peg$c132 = function(val) {
         	return $globals.JSStatementNode._new()
         		._location_(location())
         		._source_(val)
         },
-        peg$c131 = function(pattern, sequence) {
+        peg$c133 = function(pattern, sequence) {
         		return $globals.MethodNode._new()
         			._location_(location())
         			._source_(text())
@@ -311,11 +313,11 @@ $globals.SmalltalkParser = (function() {
         			._arguments_(pattern[1])
         			._dagChildren_([sequence]);
         	},
-        peg$c132 = function(send) { return send._isSendNode() && send._selector() === '->' },
-        peg$c133 = function(send) {
+        peg$c134 = function(send) { return send._isSendNode() && send._selector() === '->' },
+        peg$c135 = function(send) {
         		return [send._receiver(), send._arguments()[0]];
         	},
-        peg$c134 = function(first, others) {
+        peg$c136 = function(first, others) {
         	return first.concat.apply(first, others);
         },
 
@@ -3554,8 +3556,8 @@ $globals.SmalltalkParser = (function() {
       return s0;
     }
 
-    function peg$parsewsKeyValueMessage() {
-      var s0, s1, s2, s3;
+    function peg$parsewsValueAttrDef() {
+      var s0, s1, s2, s3, s4, s5;
 
       var key    = peg$currPos * 66 + 56,
           cached = peg$resultsCache[key];
@@ -3569,13 +3571,31 @@ $globals.SmalltalkParser = (function() {
       s0 = peg$currPos;
       s1 = peg$parsews();
       if (s1 !== peg$FAILED) {
-        s2 = peg$parsekeyword();
+        s2 = peg$parseidentifier();
         if (s2 !== peg$FAILED) {
-          s3 = peg$parsewsOperand();
+          s3 = peg$parsews();
           if (s3 !== peg$FAILED) {
-            peg$savedPos = s0;
-            s1 = peg$c114(s2, s3);
-            s0 = s1;
+            if (input.charCodeAt(peg$currPos) === 61) {
+              s4 = peg$c114;
+              peg$currPos++;
+            } else {
+              s4 = peg$FAILED;
+              if (peg$silentFails === 0) { peg$fail(peg$c115); }
+            }
+            if (s4 !== peg$FAILED) {
+              s5 = peg$parsewsOperand();
+              if (s5 !== peg$FAILED) {
+                peg$savedPos = s0;
+                s1 = peg$c116(s2, s5);
+                s0 = s1;
+              } else {
+                peg$currPos = s0;
+                s0 = peg$FAILED;
+              }
+            } else {
+              peg$currPos = s0;
+              s0 = peg$FAILED;
+            }
           } else {
             peg$currPos = s0;
             s0 = peg$FAILED;
@@ -3594,7 +3614,7 @@ $globals.SmalltalkParser = (function() {
       return s0;
     }
 
-    function peg$parsewsRestrictedMessage() {
+    function peg$parsewsAttrDef() {
       var s0;
 
       var key    = peg$currPos * 66 + 57,
@@ -3606,9 +3626,9 @@ $globals.SmalltalkParser = (function() {
         return cached.result;
       }
 
-      s0 = peg$parsewsUnaryMessage();
+      s0 = peg$parsewsValueAttrDef();
       if (s0 === peg$FAILED) {
-        s0 = peg$parsewsKeyValueMessage();
+        s0 = peg$parsewsUnaryMessage();
       }
 
       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@@ -3630,20 +3650,20 @@ $globals.SmalltalkParser = (function() {
 
       s0 = peg$currPos;
       if (input.charCodeAt(peg$currPos) === 60) {
-        s1 = peg$c115;
+        s1 = peg$c117;
         peg$currPos++;
       } else {
         s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c116); }
+        if (peg$silentFails === 0) { peg$fail(peg$c118); }
       }
       if (s1 !== peg$FAILED) {
         s2 = peg$parsewsOperand();
         if (s2 !== peg$FAILED) {
           s3 = [];
-          s4 = peg$parsewsRestrictedMessage();
+          s4 = peg$parsewsAttrDef();
           while (s4 !== peg$FAILED) {
             s3.push(s4);
-            s4 = peg$parsewsRestrictedMessage();
+            s4 = peg$parsewsAttrDef();
           }
           if (s3 !== peg$FAILED) {
             s4 = peg$currPos;
@@ -3665,7 +3685,7 @@ $globals.SmalltalkParser = (function() {
                 }
                 if (s7 !== peg$FAILED) {
                   peg$savedPos = s4;
-                  s5 = peg$c117(s2, s3, s7);
+                  s5 = peg$c119(s2, s3, s7);
                   s4 = s5;
                 } else {
                   peg$currPos = s4;
@@ -3686,15 +3706,15 @@ $globals.SmalltalkParser = (function() {
               s5 = peg$parsews();
               if (s5 !== peg$FAILED) {
                 if (input.charCodeAt(peg$currPos) === 62) {
-                  s6 = peg$c118;
+                  s6 = peg$c120;
                   peg$currPos++;
                 } else {
                   s6 = peg$FAILED;
-                  if (peg$silentFails === 0) { peg$fail(peg$c119); }
+                  if (peg$silentFails === 0) { peg$fail(peg$c121); }
                 }
                 if (s6 !== peg$FAILED) {
                   peg$savedPos = s0;
-                  s1 = peg$c120(s2, s3, s4);
+                  s1 = peg$c122(s2, s3, s4);
                   s0 = s1;
                 } else {
                   peg$currPos = s0;
@@ -3762,72 +3782,72 @@ $globals.SmalltalkParser = (function() {
 
       s0 = peg$currPos;
       if (input.charCodeAt(peg$currPos) === 60) {
-        s1 = peg$c115;
+        s1 = peg$c117;
         peg$currPos++;
       } else {
         s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c116); }
+        if (peg$silentFails === 0) { peg$fail(peg$c118); }
       }
       if (s1 !== peg$FAILED) {
         s2 = [];
         s3 = peg$currPos;
-        if (input.substr(peg$currPos, 2) === peg$c121) {
-          s4 = peg$c121;
+        if (input.substr(peg$currPos, 2) === peg$c123) {
+          s4 = peg$c123;
           peg$currPos += 2;
         } else {
           s4 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c122); }
+          if (peg$silentFails === 0) { peg$fail(peg$c124); }
         }
         if (s4 !== peg$FAILED) {
           peg$savedPos = s3;
-          s4 = peg$c123();
+          s4 = peg$c125();
         }
         s3 = s4;
         if (s3 === peg$FAILED) {
-          if (peg$c124.test(input.charAt(peg$currPos))) {
+          if (peg$c126.test(input.charAt(peg$currPos))) {
             s3 = input.charAt(peg$currPos);
             peg$currPos++;
           } else {
             s3 = peg$FAILED;
-            if (peg$silentFails === 0) { peg$fail(peg$c125); }
+            if (peg$silentFails === 0) { peg$fail(peg$c127); }
           }
         }
         while (s3 !== peg$FAILED) {
           s2.push(s3);
           s3 = peg$currPos;
-          if (input.substr(peg$currPos, 2) === peg$c121) {
-            s4 = peg$c121;
+          if (input.substr(peg$currPos, 2) === peg$c123) {
+            s4 = peg$c123;
             peg$currPos += 2;
           } else {
             s4 = peg$FAILED;
-            if (peg$silentFails === 0) { peg$fail(peg$c122); }
+            if (peg$silentFails === 0) { peg$fail(peg$c124); }
           }
           if (s4 !== peg$FAILED) {
             peg$savedPos = s3;
-            s4 = peg$c123();
+            s4 = peg$c125();
           }
           s3 = s4;
           if (s3 === peg$FAILED) {
-            if (peg$c124.test(input.charAt(peg$currPos))) {
+            if (peg$c126.test(input.charAt(peg$currPos))) {
               s3 = input.charAt(peg$currPos);
               peg$currPos++;
             } else {
               s3 = peg$FAILED;
-              if (peg$silentFails === 0) { peg$fail(peg$c125); }
+              if (peg$silentFails === 0) { peg$fail(peg$c127); }
             }
           }
         }
         if (s2 !== peg$FAILED) {
           if (input.charCodeAt(peg$currPos) === 62) {
-            s3 = peg$c118;
+            s3 = peg$c120;
             peg$currPos++;
           } else {
             s3 = peg$FAILED;
-            if (peg$silentFails === 0) { peg$fail(peg$c119); }
+            if (peg$silentFails === 0) { peg$fail(peg$c121); }
           }
           if (s3 !== peg$FAILED) {
             peg$savedPos = peg$currPos;
-            s4 = peg$c126(s2);
+            s4 = peg$c128(s2);
             if (s4) {
               s4 = void 0;
             } else {
@@ -3835,7 +3855,7 @@ $globals.SmalltalkParser = (function() {
             }
             if (s4 !== peg$FAILED) {
               peg$savedPos = s0;
-              s1 = peg$c127(s2);
+              s1 = peg$c129(s2);
               s0 = s1;
             } else {
               peg$currPos = s0;
@@ -3873,21 +3893,21 @@ $globals.SmalltalkParser = (function() {
 
       s0 = peg$currPos;
       if (input.charCodeAt(peg$currPos) === 60) {
-        s1 = peg$c115;
+        s1 = peg$c117;
         peg$currPos++;
       } else {
         s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c116); }
+        if (peg$silentFails === 0) { peg$fail(peg$c118); }
       }
       if (s1 !== peg$FAILED) {
         s2 = peg$parsews();
         if (s2 !== peg$FAILED) {
-          if (input.substr(peg$currPos, 9) === peg$c128) {
-            s3 = peg$c128;
+          if (input.substr(peg$currPos, 9) === peg$c130) {
+            s3 = peg$c130;
             peg$currPos += 9;
           } else {
             s3 = peg$FAILED;
-            if (peg$silentFails === 0) { peg$fail(peg$c129); }
+            if (peg$silentFails === 0) { peg$fail(peg$c131); }
           }
           if (s3 !== peg$FAILED) {
             s4 = peg$parsews();
@@ -3897,15 +3917,15 @@ $globals.SmalltalkParser = (function() {
                 s6 = peg$parsews();
                 if (s6 !== peg$FAILED) {
                   if (input.charCodeAt(peg$currPos) === 62) {
-                    s7 = peg$c118;
+                    s7 = peg$c120;
                     peg$currPos++;
                   } else {
                     s7 = peg$FAILED;
-                    if (peg$silentFails === 0) { peg$fail(peg$c119); }
+                    if (peg$silentFails === 0) { peg$fail(peg$c121); }
                   }
                   if (s7 !== peg$FAILED) {
                     peg$savedPos = s0;
-                    s1 = peg$c130(s5);
+                    s1 = peg$c132(s5);
                     s0 = s1;
                   } else {
                     peg$currPos = s0;
@@ -3965,7 +3985,7 @@ $globals.SmalltalkParser = (function() {
         s2 = peg$parsewsSequenceWs();
         if (s2 !== peg$FAILED) {
           peg$savedPos = s0;
-          s1 = peg$c131(s1, s2);
+          s1 = peg$c133(s1, s2);
           s0 = s1;
         } else {
           peg$currPos = s0;
@@ -3997,7 +4017,7 @@ $globals.SmalltalkParser = (function() {
       s1 = peg$parsebinarySend();
       if (s1 !== peg$FAILED) {
         peg$savedPos = peg$currPos;
-        s2 = peg$c132(s1);
+        s2 = peg$c134(s1);
         if (s2) {
           s2 = void 0;
         } else {
@@ -4005,7 +4025,7 @@ $globals.SmalltalkParser = (function() {
         }
         if (s2 !== peg$FAILED) {
           peg$savedPos = s0;
-          s1 = peg$c133(s1);
+          s1 = peg$c135(s1);
           s0 = s1;
         } else {
           peg$currPos = s0;
@@ -4098,7 +4118,7 @@ $globals.SmalltalkParser = (function() {
           }
           if (s3 !== peg$FAILED) {
             peg$savedPos = s0;
-            s1 = peg$c134(s2, s3);
+            s1 = peg$c136(s2, s3);
             s0 = s1;
           } else {
             peg$currPos = s0;

+ 9 - 7
support/parser.pegjs

@@ -266,27 +266,29 @@ cascade =
 
 wsOperand = ws operand:operand {return operand;}
 
-wsKeyValueMessage = ws key:keyword value:wsOperand {
+wsDefaultAttrDef = wsUnaryMessage
+
+wsValueAttrDef = ws selector:unarySelector ws '=' value:wsOperand {
 	return $globals.SendNode._new()
 		._location_(location())
 		._source_(text())
-		._selector_(key)
+		._selector_(selector + ':')
 		._arguments_([value]);
 }
 
-wsRestrictedMessage = wsUnaryMessage / wsKeyValueMessage
+wsAttrDef = wsValueAttrDef / wsDefaultAttrDef
 
 stx =
 	'<'
-	tag:wsOperand messages:wsRestrictedMessage*
-	operands:(ws '|' operands:wsOperand* {return operands;})?
+	tag:wsOperand attributes:wsAttrDef*
+	children:(ws '|' operands:wsOperand* {return operands;})?
 	ws '>' {
 		return $globals.StxNode._new()
 			._location_(location())
 			._source_(text())
 			._tag_(tag)
-			._attributes_(messages)
-			._children_(operands || []);
+			._attributes_(attributes)
+			._children_(children || []);
 	}
 
 jsStatement = pragmaJsStatement / legacyJsStatement