Making src/core/ps_parser.js adhere to the style guide
This commit is contained in:
parent
01b23439a9
commit
2adcaf4f64
@ -38,8 +38,9 @@ var PostScriptParser = (function PostScriptParserClosure() {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
expect: function PostScriptParser_expect(type) {
|
expect: function PostScriptParser_expect(type) {
|
||||||
if (this.accept(type))
|
if (this.accept(type)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
error('Unexpected symbol: found ' + this.token.type + ' expected ' +
|
error('Unexpected symbol: found ' + this.token.type + ' expected ' +
|
||||||
type + '.');
|
type + '.');
|
||||||
},
|
},
|
||||||
@ -116,9 +117,9 @@ var PostScriptToken = (function PostScriptTokenClosure() {
|
|||||||
|
|
||||||
PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
|
PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
|
||||||
var opValue = opCache[op];
|
var opValue = opCache[op];
|
||||||
if (opValue)
|
if (opValue) {
|
||||||
return opValue;
|
return opValue;
|
||||||
|
}
|
||||||
return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
|
return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -167,8 +168,8 @@ var PostScriptLexer = (function PostScriptLexerClosure() {
|
|||||||
case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: // '0'-'4'
|
case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: // '0'-'4'
|
||||||
case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: // '5'-'9'
|
case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: // '5'-'9'
|
||||||
case 0x2B: case 0x2D: case 0x2E: // '+', '-', '.'
|
case 0x2B: case 0x2D: case 0x2E: // '+', '-', '.'
|
||||||
return new PostScriptToken(PostScriptTokenTypes.NUMBER,
|
return new PostScriptToken(PostScriptTokenTypes.NUMBER,
|
||||||
this.getNumber());
|
this.getNumber());
|
||||||
case 0x7B: // '{'
|
case 0x7B: // '{'
|
||||||
this.nextChar();
|
this.nextChar();
|
||||||
return PostScriptToken.LBRACE;
|
return PostScriptToken.LBRACE;
|
||||||
@ -179,7 +180,7 @@ var PostScriptLexer = (function PostScriptLexerClosure() {
|
|||||||
// operator
|
// operator
|
||||||
var str = String.fromCharCode(ch);
|
var str = String.fromCharCode(ch);
|
||||||
while ((ch = this.nextChar()) >= 0 && // and 'A'-'Z', 'a'-'z'
|
while ((ch = this.nextChar()) >= 0 && // and 'A'-'Z', 'a'-'z'
|
||||||
((ch >= 0x41 && ch <= 0x5A) || (ch >= 0x61 && ch <= 0x7A))) {
|
((ch >= 0x41 && ch <= 0x5A) || (ch >= 0x61 && ch <= 0x7A))) {
|
||||||
str += String.fromCharCode(ch);
|
str += String.fromCharCode(ch);
|
||||||
}
|
}
|
||||||
switch (str.toLowerCase()) {
|
switch (str.toLowerCase()) {
|
||||||
@ -196,15 +197,16 @@ var PostScriptLexer = (function PostScriptLexerClosure() {
|
|||||||
var str = String.fromCharCode(ch);
|
var str = String.fromCharCode(ch);
|
||||||
while ((ch = this.nextChar()) >= 0) {
|
while ((ch = this.nextChar()) >= 0) {
|
||||||
if ((ch >= 0x30 && ch <= 0x39) || // '0'-'9'
|
if ((ch >= 0x30 && ch <= 0x39) || // '0'-'9'
|
||||||
ch === 0x2D || ch === 0x2E) { // '-', '.'
|
ch === 0x2D || ch === 0x2E) { // '-', '.'
|
||||||
str += String.fromCharCode(ch);
|
str += String.fromCharCode(ch);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var value = parseFloat(str);
|
var value = parseFloat(str);
|
||||||
if (isNaN(value))
|
if (isNaN(value)) {
|
||||||
error('Invalid floating point number: ' + value);
|
error('Invalid floating point number: ' + value);
|
||||||
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user