MCPcopy Create free account
hub / github.com/apache/cloudstack / parser

Function parser

tools/ngui/static/js/lib/angular.js:6036–6409  ·  view source on GitHub ↗
(text, json, $filter, csp)

Source from the content-addressed store, hash-verified

6034/////////////////////////////////////////
6035
6036function parser(text, json, $filter, csp){
6037 var ZERO = valueFn(0),
6038 value,
6039 tokens = lex(text, csp),
6040 assignment = _assignment,
6041 functionCall = _functionCall,
6042 fieldAccess = _fieldAccess,
6043 objectIndex = _objectIndex,
6044 filterChain = _filterChain;
6045
6046 if(json){
6047 // The extra level of aliasing is here, just in case the lexer misses something, so that
6048 // we prevent any accidental execution in JSON.
6049 assignment = logicalOR;
6050 functionCall =
6051 fieldAccess =
6052 objectIndex =
6053 filterChain =
6054 function() { throwError("is not valid json", {text:text, index:0}); };
6055 value = primary();
6056 } else {
6057 value = statements();
6058 }
6059 if (tokens.length !== 0) {
6060 throwError("is an unexpected token", tokens[0]);
6061 }
6062 return value;
6063
6064 ///////////////////////////////////
6065 function throwError(msg, token) {
6066 throw Error("Syntax Error: Token '" + token.text +
6067 "' " + msg + " at column " +
6068 (token.index + 1) + " of the expression [" +
6069 text + "] starting at [" + text.substring(token.index) + "].");
6070 }
6071
6072 function peekToken() {
6073 if (tokens.length === 0)
6074 throw Error("Unexpected end of expression: " + text);
6075 return tokens[0];
6076 }
6077
6078 function peek(e1, e2, e3, e4) {
6079 if (tokens.length > 0) {
6080 var token = tokens[0];
6081 var t = token.text;
6082 if (t==e1 || t==e2 || t==e3 || t==e4 ||
6083 (!e1 && !e2 && !e3 && !e4)) {
6084 return token;
6085 }
6086 }
6087 return false;
6088 }
6089
6090 function expect(e1, e2, e3, e4){
6091 var token = peek(e1, e2, e3, e4);
6092 if (token) {
6093 if (json && !token.json) {

Callers 2

confluence_soap_parserFunction · 0.85
$ParseProviderFunction · 0.85

Calls 5

valueFnFunction · 0.85
lexFunction · 0.85
throwErrorFunction · 0.85
primaryFunction · 0.85
statementsFunction · 0.85

Tested by

no test coverage detected