Skip to content
Browse files

[clarinet] bug after string

  • Loading branch information...
1 parent 412f105 commit 7a6285e5f76848c0eca1adeb880faec2eeb968a2 @dscape committed Dec 17, 2011
Showing with 13 additions and 9 deletions.
  1. +9 −7 clarinet.js
  2. +4 −2 test/clarinet.js
View
16 clarinet.js
@@ -1,8 +1,8 @@
;(function (clarinet) {
// non node-js needs to set clarinet debug on root
var env = process && process.env ? process.env : window
- , fastlist = FastList ||
- (typeof require === 'function' && require('fastlist')) ||
+ , fastlist = //FastList ||
+ //(typeof require === 'function' && require('fastlist')) ||
Array
;
@@ -276,24 +276,24 @@
case S.CLOSE_OBJECT:
if (is(whitespace, c)) continue;
if(c===':') {
- parser.stack.unshift(S.CLOSE_OBJECT);
+ parser.stack.push(S.CLOSE_OBJECT);
closeValue(parser, 'onopenobject');
parser.state = S.VALUE;
} else if (c==='}') {
emitNode(parser, 'oncloseobject');
- parser.state = parser.stack.shift() || S.VALUE;
+ parser.state = parser.stack.pop() || S.VALUE;
} else error(parser, 'Bad object');
continue;
case S.CLOSE_ARRAY:
if (is(whitespace, c)) continue;
if(c===',') {
- parser.stack.unshift(S.CLOSE_ARRAY);
+ parser.stack.push(S.CLOSE_ARRAY);
closeValue (parser, 'onvalue');
parser.state = S.VALUE;
} else if (c===']') {
emitNode(parser, 'onclosearray');
- parser.state = parser.stack.shift() || S.VALUE;
+ parser.state = parser.stack.pop() || S.VALUE;
} else error(parser, 'Bad array');
continue;
@@ -309,6 +309,8 @@
parser.state = S.STRING;
} else if(c === '{') {
parser.state = S.OPEN_OBJECT;
+ } else if(c === '[') {
+ parser.state = S.OPEN_ARRAY;
} else {
error(parser, "Bad value");
}
@@ -317,7 +319,7 @@
case S.STRING:
// end of string
if (p !== '\\' && c === '"') {
- parser.state = parser.stack.shift() || S.VALUE;
+ parser.state = parser.stack.pop() || S.VALUE;
} else {
parser.textNode += c;
}
View
6 test/clarinet.js
@@ -68,6 +68,7 @@ var seps = [undefined, /\t|\n|\r| /, '']
, ['ready' , undefined]
]
}
+ // two keys
};
function generic(key,sep) {
@@ -98,7 +99,8 @@ function generic(key,sep) {
describe('clarinet', function(){
describe('#generic', function() {
- for (var key in docs) {
+ key = 'nested_array'
+ //for (var key in docs) {
if (docs.hasOwnProperty(key)) {
// undefined means no split
// /\t|\n|\r| / means on whitespace
@@ -109,6 +111,6 @@ describe('clarinet', function(){
generic(key,sep));
}
}
- }
+ //}
});
});

0 comments on commit 7a6285e

Please sign in to comment.
Something went wrong with that request. Please try again.