diff options
| author | Misko Hevery | 2011-01-19 15:42:11 -0800 |
|---|---|---|
| committer | Misko Hevery | 2011-01-24 14:23:51 -0800 |
| commit | c2f2587a79aeb77aad66f081cf924a79348a698e (patch) | |
| tree | 8f5aa4cc6e7189befb834388b2102d1eda88a975 /src/parser.js | |
| parent | 5d0d34ae72a9ca47f1b2dabda60711ad16ee9313 (diff) | |
| download | angular.js-c2f2587a79aeb77aad66f081cf924a79348a698e.tar.bz2 | |
fixed example rendering, add tests for it.
Diffstat (limited to 'src/parser.js')
| -rw-r--r-- | src/parser.js | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/parser.js b/src/parser.js index ac62fb97..f2ca7a80 100644 --- a/src/parser.js +++ b/src/parser.js @@ -49,8 +49,8 @@ function lex(text, parseStringsForObjects){ } } else if (is('(){}[].,;:')) { tokens.push({ - index:index, - text:ch, + index:index, + text:ch, json:(was(':[,') && is('{[')) || is('}]:,') }); if (is('{[')) json.unshift(ch); @@ -108,8 +108,8 @@ function lex(text, parseStringsForObjects){ end = end || index; throw Error("Lexer Error: " + error + " at column" + (isDefined(start) ? - "s " + start + "-" + index + " [" + text.substring(start, end) + "]" : - " " + end) + + "s " + start + "-" + index + " [" + text.substring(start, end) + "]" : + " " + end) + " in expression [" + text + "]."); } @@ -157,8 +157,8 @@ function lex(text, parseStringsForObjects){ } fn = OPERATORS[ident]; tokens.push({ - index:start, - text:ident, + index:start, + text:ident, json: fn, fn:fn||extend(getterFn(ident), { assign:function(self, value){ @@ -167,7 +167,7 @@ function lex(text, parseStringsForObjects){ }) }); } - + function readString(quote) { var start = index; index++; @@ -217,25 +217,25 @@ function lex(text, parseStringsForObjects){ function parser(text, json){ var ZERO = valueFn(0), tokens = lex(text, json), - assignment = _assignment, + assignment = _assignment, assignable = logicalOR, - functionCall = _functionCall, - fieldAccess = _fieldAccess, - objectIndex = _objectIndex, - filterChain = _filterChain, - functionIdent = _functionIdent, + functionCall = _functionCall, + fieldAccess = _fieldAccess, + objectIndex = _objectIndex, + filterChain = _filterChain, + functionIdent = _functionIdent, pipeFunction = _pipeFunction; if(json){ - // The extra level of aliasing is here, just in case the lexer misses something, so that + // The extra level of aliasing is here, just in case the lexer misses something, so that // we prevent any accidental execution in JSON. assignment = logicalOR; - functionCall = - fieldAccess = - objectIndex = + functionCall = + fieldAccess = + objectIndex = assignable = - filterChain = - functionIdent = - pipeFunction = + filterChain = + functionIdent = + pipeFunction = function (){ throwError("is not valid json", {text:text, index:0}); }; } return { @@ -368,7 +368,7 @@ function parser(text, json){ argFns.push(expression()); } else { return valueFn({ - format:invokeFn(formatter.format), + format:invokeFn(formatter.format), parse:invokeFn(formatter.parse) }); } |
