(code)
| 11029 | |
| 11030 | // Parser starts |
| 11031 | function parseProcessing(code) { |
| 11032 | var globalMembers = getGlobalMembers(); |
| 11033 | |
| 11034 | function splitToAtoms(code) { |
| 11035 | var atoms = []; |
| 11036 | var items = code.split(/([\{\[\(\)\]\}])/); |
| 11037 | var result = items[0]; |
| 11038 | |
| 11039 | var stack = []; |
| 11040 | for(var i=1; i < items.length; i += 2) { |
| 11041 | var item = items[i]; |
| 11042 | if(item === '[' || item === '{' || item === '(') { |
| 11043 | stack.push(result); result = item; |
| 11044 | } else if(item === ']' || item === '}' || item === ')') { |
| 11045 | var kind = item === '}' ? 'A' : item === ')' ? 'B' : 'C'; |
| 11046 | var index = atoms.length; atoms.push(result + item); |
| 11047 | result = stack.pop() + '"' + kind + (index + 1) + '"'; |
| 11048 | } |
| 11049 | result += items[i + 1]; |
| 11050 | } |
| 11051 | atoms.unshift(result); |
| 11052 | return atoms; |
| 11053 | } |
| 11054 | |
| 11055 | function injectStrings(code, strings) { |
| 11056 | return code.replace(/'(\d+)'/g, function(all, index) { |
| 11057 | var val = strings[index]; |
| 11058 | if(val.charAt(0) === "/") { |
| 11059 | return val; |
| 11060 | } else { |
| 11061 | return (/^'((?:[^'\\\n])|(?:\\.[0-9A-Fa-f]*))'$/).test(val) ? "(new processing.Character(" + val + "))" : val; |
| 11062 | } |
| 11063 | }); |
| 11064 | } |
| 11065 | |
| 11066 | function trimSpaces(string) { |
| 11067 | var m1 = /^\s*/.exec(string), result; |
| 11068 | if(m1[0].length === string.length) { |
| 11069 | result = {left: m1[0], middle: "", right: ""}; |
| 11070 | } else { |
| 11071 | var m2 = /\s*$/.exec(string); |
| 11072 | result = {left: m1[0], middle: string.substring(m1[0].length, m2.index), right: m2[0]}; |
| 11073 | } |
| 11074 | result.untrim = function(t) { return this.left + t + this.right; }; |
| 11075 | return result; |
| 11076 | } |
| 11077 | |
| 11078 | function trim(string) { |
| 11079 | return string.replace(/^\s+/,'').replace(/\s+$/,''); |
| 11080 | } |
| 11081 | |
| 11082 | function appendToLookupTable(table, array) { |
| 11083 | for(var i=0,l=array.length;i<l;++i) { |
| 11084 | table[array[i]] = null; |
| 11085 | } |
| 11086 | return table; |
| 11087 | } |
| 11088 |
no test coverage detected