Browse Source

bump pegjs. Fix #1199.

Herbert Vojčík 9 years ago
parent
commit
76f25c9f6d
5 changed files with 343 additions and 282 deletions
  1. 1 1
      package.json
  2. 31 0
      src/Compiler-AST.js
  3. 4 0
      src/Compiler-AST.st
  4. 287 261
      support/parser.js
  5. 20 20
      support/parser.pegjs

+ 1 - 1
package.json

@@ -34,7 +34,7 @@
     "grunt-contrib-jshint": "^0.11.0",
     "grunt-contrib-requirejs": "^0.4.4",
     "grunt-execute": "^0.2.1",
-    "pegjs": "^0.8.0",
+    "pegjs": "^0.9.0",
     "requirejs": "^2.1.15"
   }
 }

+ 31 - 0
src/Compiler-AST.js

@@ -421,6 +421,37 @@ messageSends: []
 }),
 $globals.Node);
 
+$core.addMethod(
+$core.method({
+selector: "location:",
+protocol: 'accessing',
+fn: function (aLocation){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $3,$2,$1;
+$3=$recv(aLocation)._start();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["start"]=1;
+//>>excludeEnd("ctx");
+$2=$recv($3)._line();
+$1=$recv($2).__at($recv($recv(aLocation)._start())._column());
+self._position_($1);
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"location:",{aLocation:aLocation},$globals.Node)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aLocation"],
+source: "location: aLocation\x0a\x09self position: aLocation start line @ aLocation start column",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["position:", "@", "line", "start", "column"]
+}),
+$globals.Node);
+
 $core.addMethod(
 $core.method({
 selector: "method",

+ 4 - 0
src/Compiler-AST.st

@@ -26,6 +26,10 @@ allNodes
 	^ allNodes
 !
 
+location: aLocation
+	self position: aLocation start line @ aLocation start column
+!
+
 method
 	^ self parent ifNotNil: [ :node | node method ]
 !

File diff suppressed because it is too large
+ 287 - 261
support/parser.js


+ 20 - 20
support/parser.pegjs

@@ -10,14 +10,14 @@ selector      = first:[a-zA-Z] others:[a-zA-Z0-9\:]* {return first + others.join
 className      = first:[A-Z] others:[a-zA-Z0-9]* {return first + others.join("");}
 string         = "'" val:(("''" {return "'";} / [^'])*) "'" {
                      return $globals.ValueNode._new()
-                            ._position_((line()).__at(column()))
+                            ._location_(location())
                             ._source_(text())
                             ._value_(val.join(""));
                  }
 character      = "$" char:. 
                   {
                       return $globals.ValueNode._new()
-                             ._position_((line()).__at(column()))
+                             ._location_(location())
                              ._source_(text())
                              ._value_(char);
                   }
@@ -25,13 +25,13 @@ symbol         = "#" rest:bareSymbol {return rest;}
 bareSymbol         = val:(selector / binarySelector / node:string {return node._value();})
                   {
                       return $globals.ValueNode._new()
-                             ._position_((line()).__at(column()))
+                             ._location_(location())
                              ._source_(text())
                              ._value_(val);
                   }
 number         = n:(numberExp / hex / float / integer) {
                      return $globals.ValueNode._new()
-                            ._position_((line()).__at(column()))
+                            ._location_(location())
                             ._source_(text())
                             ._value_(n);
                  }
@@ -42,12 +42,12 @@ integer        = neg:"-"? digits:[0-9]+ {return (parseInt((neg || '') + digits.j
 
 literalArray   = "#(" rest:wsLiteralArrayContents ws ")" {
     return rest
-        ._position_((line()).__at(column()))
+        ._location_(location())
         ._source_(text());
 }
 bareLiteralArray   = "(" rest:wsLiteralArrayContents ws ")" {
     return rest
-        ._position_((line()).__at(column()))
+        ._location_(location())
         ._source_(text());
 }
 
@@ -58,13 +58,13 @@ wsLiteralArrayContents   = lits:(ws lit:literalArrayElement {return lit._value()
                  }
 dynamicArray   = "{" ws expressions:expressions? maybeDotsWs "}" {
                      return $globals.DynamicArrayNode._new()
-                            ._position_((line()).__at(column()))
+                            ._location_(location())
                             ._source_(text())
                             ._nodes_(expressions || []);
                  }
 dynamicDictionary = "#{" ws expressions:associations? maybeDotsWs  "}" {
                         return $globals.DynamicDictionaryNode._new()
-                               ._position_((line()).__at(column()))
+                               ._location_(location())
                                ._source_(text())
                                ._nodes_(expressions || []);
                     }
@@ -73,7 +73,7 @@ pseudoVariable = val:(
                  / 'false' {return false;}
                  / 'nil' {return nil;}) {
                        return $globals.ValueNode._new()
-                              ._position_((line()).__at(column()))
+                              ._location_(location())
                               ._source_(text())
                               ._value_(val);
                    }
@@ -84,7 +84,7 @@ literal        = runtimeLiteral / parseTimeLiteral
 
 variable       = identifier:identifier {
                      return $globals.VariableNode._new()
-                            ._position_((line()).__at(column()))
+                            ._location_(location())
                             ._source_(text())
                             ._value_(identifier);
                  }
@@ -113,7 +113,7 @@ expressions    = first:expression others:wsExpressionsRest* { return [first].con
 
 assignment     = variable:variable ws ':=' ws expression:expression {
                      return $globals.AssignmentNode._new()
-                            ._position_((line()).__at(column()))
+                            ._location_(location())
                             ._source_(text())
                             ._left_(variable)
                             ._right_(expression);
@@ -121,7 +121,7 @@ assignment     = variable:variable ws ':=' ws expression:expression {
 
 ret            = '^' ws expression:expression {
                      return $globals.ReturnNode._new()
-                            ._position_((line()).__at(column()))
+                            ._location_(location())
                             ._source_(text())
                             ._nodes_([expression]);
                  }
@@ -146,7 +146,7 @@ wsSequenceWs       = (ws js:jsSequence ws { return js; }) / wsStSequenceWs
 
 wsStSequenceWs    = ws temps:temps? maybeDotsWs statements:statementsWs? {
                      return $globals.SequenceNode._new()
-                            ._position_((line()).__at(column()))
+                            ._location_(location())
                             ._source_(text())
                             ._temps_(temps || [])
                             ._nodes_(statements || []);
@@ -156,7 +156,7 @@ jsSequence     = jsStatement
 
 block          = '[' params:wsBlockParamList? sequence:wsSequenceWs? ']' {
                      return $globals.BlockNode._new()
-                            ._position_((line()).__at(column()))
+                            ._location_(location())
                             ._source_(text())
                             ._parameters_(params || [])
                             ._nodes_([sequence._asBlockSequenceNode()]);
@@ -168,7 +168,7 @@ operand        = literal / reference / subexpression
 
 wsUnaryMessage   = ws selector:unarySelector !":" {
                      return $globals.SendNode._new()
-                            ._position_((line()).__at(column()))
+                            ._location_(location())
                             ._source_(text())
                             ._selector_(selector);
                  }
@@ -193,7 +193,7 @@ unarySend      = receiver:operand tail:wsUnaryTail? {
 
 wsBinaryMessage  = ws selector:binarySelector ws arg:unarySend {
                      return $globals.SendNode._new()
-                            ._position_((line()).__at(column()))
+                            ._location_(location())
                             ._source_(text())
                             ._selector_(selector)
                             ._arguments_([arg]);
@@ -226,7 +226,7 @@ wsKeywordMessage = pairs:(ws key:keyword ws arg:binarySend {return {key:key, arg
                           args.push(pairs[i].arg);
                       }
                       return $globals.SendNode._new()
-                             ._position_((line()).__at(column()))
+                             ._location_(location())
                              ._source_(text())
                              ._selector_(selector)
                              ._arguments_(args);
@@ -246,21 +246,21 @@ wsMessage        = wsBinaryMessage / wsUnaryMessage / wsKeywordMessage
 cascade        = send:keywordSend & { return send._isSendNode(); } messages:(ws ";" mess:wsMessage {return mess;})+ {
                      messages.unshift(send);
                      return $globals.CascadeNode._new()
-                            ._position_((line()).__at(column()))
+                            ._location_(location())
                             ._source_(text())
                             ._nodes_(messages);
                  }
 
 jsStatement    = "<" val:((">>" {return ">";} / [^>])*) ">" {
                      return $globals.JSStatementNode._new()
-                            ._position_((line()).__at(column()))
+                            ._location_(location())
                             ._source_(val.join(""))
                  }
 
 
 method         = pattern:(wsKeywordPattern / wsBinaryPattern / wsUnaryPattern) sequence:wsSequenceWs? {
                       return $globals.MethodNode._new()
-                             ._position_((line()).__at(column()))
+                             ._location_(location())
                              ._source_(text())
                              ._selector_(pattern[0])
                              ._arguments_(pattern[1])

Some files were not shown because too many files changed in this diff