aboutsummaryrefslogtreecommitdiffstats
path: root/src/Parser.js
diff options
context:
space:
mode:
authorMisko Hevery2010-08-18 16:23:12 -0700
committerMisko Hevery2010-08-18 17:26:33 -0700
commit5ddd8d958686c5075b6c58b700f19b4bdea90e1d (patch)
treef43da0153fb41244425c00fc728a17028671ce03 /src/Parser.js
parent1087270c95f6bbafd3715c9a5eecdafac79c9daa (diff)
downloadangular.js-5ddd8d958686c5075b6c58b700f19b4bdea90e1d.tar.bz2
stringify names for better compression, remove dead functions, removed underscore.js compatibility
Diffstat (limited to 'src/Parser.js')
-rw-r--r--src/Parser.js87
1 files changed, 6 insertions, 81 deletions
diff --git a/src/Parser.js b/src/Parser.js
index 5eb75713..bec1b13a 100644
--- a/src/Parser.js
+++ b/src/Parser.js
@@ -7,10 +7,10 @@ function Lexer(text, parsStrings){
}
Lexer.OPERATORS = {
- 'null':function(self){return null;},
+ 'null':function(self){return _null;},
'true':function(self){return true;},
'false':function(self){return false;},
- 'undefined':noop,
+ $undefined:noop,
'+':function(self, a,b){return (isDefined(a)?a:0)+(isDefined(b)?b:0);},
'-':function(self, a,b){return (isDefined(a)?a:0)-(isDefined(b)?b:0);},
'*':function(self, a,b){return a*b;},
@@ -490,7 +490,7 @@ Parser.prototype = {
if (instance)
instance = instance[key];
}
- if (typeof instance != 'function') {
+ if (typeof instance != $function) {
throw "Function '" + token.text + "' at column '" +
(token.index+1) + "' in '" + this.text + "' is not defined.";
}
@@ -507,10 +507,6 @@ Parser.prototype = {
primary = this.arrayDeclaration();
} else if (this.expect('{')) {
primary = this.object();
- } else if (this.expect('{:')) {
- primary = this.closure(false);
- } else if (this.expect('{(')) {
- primary = this.closure(true);
} else {
var token = this.expect();
primary = token.fn;
@@ -533,32 +529,6 @@ Parser.prototype = {
return primary;
},
- closure: function(hasArgs) {
- var args = [];
- if (hasArgs) {
- if (!this.expect(')')) {
- args.push(this.expect().text);
- while(this.expect(',')) {
- args.push(this.expect().text);
- }
- this.consume(')');
- }
- this.consume(":");
- }
- var statements = this.statements();
- this.consume("}");
- return function(self) {
- return function($){
- var scope = createScope(self);
- scope['$'] = $;
- for ( var i = 0; i < args.length; i++) {
- setter(scope, args[i], arguments[i]);
- }
- return statements(scope);
- };
- };
- },
-
fieldAccess: function(object) {
var field = this.expect().text;
var getter = getterFn(field);
@@ -581,7 +551,7 @@ Parser.prototype = {
return function (self){
var o = obj(self);
var i = indexFn(self);
- return (o) ? o[i] : undefined;
+ return (o) ? o[i] : _undefined;
};
}
},
@@ -601,8 +571,8 @@ Parser.prototype = {
}
var fnPtr = fn(self) || noop;
// IE stupidity!
- return fnPtr.apply ?
- fnPtr.apply(self, args) :
+ return fnPtr.apply ?
+ fnPtr.apply(self, args) :
fnPtr(args[0], args[1], args[2], args[3], args[4]);
};
},
@@ -648,51 +618,6 @@ Parser.prototype = {
};
},
- entityDeclaration: function () {
- var decl = [];
- while(this.hasTokens()) {
- decl.push(this.entityDecl());
- if (!this.expect(';')) {
- this.assertAllConsumed();
- }
- }
- return function (self){
- var code = "";
- for ( var i = 0; i < decl.length; i++) {
- code += decl[i](self);
- }
- return code;
- };
- },
-
- entityDecl: function () {
- var entity = this.expect().text;
- var instance;
- var defaults;
- if (this.expect('=')) {
- instance = entity;
- entity = this.expect().text;
- }
- if (this.expect(':')) {
- defaults = this.primary()(null);
- }
- return function(self) {
- var Entity = self.datastore.entity(entity, defaults);
- setter(self, entity, Entity);
- if (instance) {
- var document = Entity();
- document['$$anchor'] = instance;
- setter(self, instance, document);
- return "$anchor." + instance + ":{" +
- instance + "=" + entity + ".load($anchor." + instance + ");" +
- instance + ".$$anchor=" + angular['String']['quote'](instance) + ";" +
- "};";
- } else {
- return "";
- }
- };
- },
-
watch: function () {
var decl = [];
while(this.hasTokens()) {