aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/material-parser.js
diff options
context:
space:
mode:
authorEric Guzman2012-04-05 18:42:40 -0700
committerEric Guzman2012-04-05 18:42:40 -0700
commit8ff9dde2053e41d85bb27d9c91808a30e551a138 (patch)
tree8eec67d632d82d3052ed470096eda13fd50a55c8 /js/lib/rdge/materials/material-parser.js
parent4631d54ffb4942378835689e9f5d70ed95610822 (diff)
parent7656b6eac7aec59697c6cddbe2a507fe9e4aa187 (diff)
downloadninja-8ff9dde2053e41d85bb27d9c91808a30e551a138.tar.gz
Merge branch 'refs/heads/master' into CSSPanelUpdates
Diffstat (limited to 'js/lib/rdge/materials/material-parser.js')
-rwxr-xr-xjs/lib/rdge/materials/material-parser.js81
1 files changed, 40 insertions, 41 deletions
diff --git a/js/lib/rdge/materials/material-parser.js b/js/lib/rdge/materials/material-parser.js
index b334c05d..c078c3af 100755
--- a/js/lib/rdge/materials/material-parser.js
+++ b/js/lib/rdge/materials/material-parser.js
@@ -4,66 +4,65 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */ 5</copyright> */
6 6
7var MaterialParser = function MaterialParser( theStr ) { 7var MaterialParser = function MaterialParser(theStr) {
8 8
9 this._strBuffer = theStr; 9 this._strBuffer = theStr;
10 10
11 this.nextValue = function( prop, endKeyArg, advanceBufferArg ) { 11 this.nextValue = function (prop, endKeyArg, advanceBufferArg) {
12 if (!this._strBuffer) return; 12 if (!this._strBuffer) return;
13 13
14 // make the 2 & 3rd argument optional. default is to advance the string 14 // make the 2 & 3rd argument optional. default is to advance the string
15 var endKey = "\n", advanceBuffer = true; 15 var endKey = "\n", advanceBuffer = true;
16 if (endKeyArg) { 16 if (endKeyArg) {
17 endKey = endKeyArg; 17 endKey = endKeyArg;
18 } 18 }
19 19
20 if (advanceBufferArg) { 20 if (advanceBufferArg) {
21 advanceBuffer = advanceBufferArg; 21 advanceBuffer = advanceBufferArg;
22 } 22 }
23 23
24 var iStart = this._strBuffer.indexOf( prop ); 24 var iStart = this._strBuffer.indexOf(prop);
25 if (iStart < 0) return; 25 if (iStart < 0) return;
26 26
27 var iEnd = this._strBuffer.indexOf( endKey, iStart ); 27 var iEnd = this._strBuffer.indexOf(endKey, iStart);
28 if (iEnd < 0) throw new Error( "property " + prop + " improperly terminated: " + this._strBuffer); 28 if (iEnd < 0) throw new Error("property " + prop + " improperly terminated: " + this._strBuffer);
29 29
30 iStart += prop.length; 30 iStart += prop.length;
31 var nChars = iEnd - iStart; 31 var nChars = iEnd - iStart;
32 var rtnStr = this._strBuffer.substr( iStart, nChars ); 32 var rtnStr = this._strBuffer.substr(iStart, nChars);
33 33
34 if (advanceBuffer) { 34 if (advanceBuffer) {
35 this._strBuffer = this._strBuffer.substr( iEnd + endKey.length ); 35 this._strBuffer = this._strBuffer.substr(iEnd + endKey.length);
36 } 36 }
37 37
38 return rtnStr; 38 return rtnStr;
39 }; 39 };
40 40
41 this.nextToken = function() { 41 this.nextToken = function () {
42 if (!this._strBuffer) return; 42 if (!this._strBuffer) return;
43 43
44 // find the limits 44 // find the limits
45 var index = this._strBuffer.search( /\S/ ); // first non-whitespace character 45 var index = this._strBuffer.search(/\S/); // first non-whitespace character
46 if (index > 0) this._strBuffer = this._strBuffer.slice(index); 46 if (index > 0) this._strBuffer = this._strBuffer.slice(index);
47 index = this._strBuffer.search( /\s/ ); // first whitespace character marking the end of the token 47 index = this._strBuffer.search(/\s/); // first whitespace character marking the end of the token
48 48
49 var token; 49 var token;
50 if (index > 0) { 50 if (index > 0) {
51 token = this._strBuffer.slice(0, index); 51 token = this._strBuffer.slice(0, index);
52 this._strBuffer = this._strBuffer.slice( index ); 52 this._strBuffer = this._strBuffer.slice(index);
53 } 53 }
54 54
55 return token; 55 return token;
56 }; 56 };
57 57
58 this.advancePastToken = function( token ) { 58 this.advancePastToken = function (token) {
59 var index = this._strBuffer.indexOf( token ); 59 var index = this._strBuffer.indexOf(token);
60 if (index < 0) { 60 if (index < 0) {
61 console.log( "could not find token: " + token + " in string: " + this._strBuffer ); 61 console.log("could not find token: " + token + " in string: " + this._strBuffer);
62 } else { 62 } else {
63 this._strBuffer = this._strBuffer.substr( index + token.length ); 63 this._strBuffer = this._strBuffer.substr(index + token.length);
64 } 64 }
65 } 65 };
66
67}; 66};
68 67
69if (typeof exports === "object") { 68if (typeof exports === "object") {