Closed balupton closed 7 years ago
I tried the following:
# SyntaxError: Syntax error on line 1, column 4: Unexpected Code
x: ->
10
# SyntaxError: Syntax error on line 1, column 1: Unexpected Assign
f = -> 10
# SyntaxError: Syntax error on line 1, column 1: Unexpected Code
-> 10
Can you share the cson file where it ignores the function?
seems the error is on the bevry/cson side
{
inherit: 96
project: "2/2"-10-DocPad
amount: 3000
}
produces:
$ cson2json ./data-source/test.cson
{}
however:
$ node -e "console.log(require('cson-parser').parse(require('fs').readFileSync('./data-source/test.cson').toString()))"
/Users/balupton/Projects/accounting/bevry-crm/data/node_modules/cson-parser/lib/parse.js:214
throw new SyntaxError(syntaxErrorMessage(csNode, 'Unexpected ' + type));
^
SyntaxError: Syntax error on line 3, column 20: Unexpected IdentifierLiteral
at transformNode (/Users/balupton/Projects/accounting/bevry-crm/data/node_modules/cson-parser/lib/parse.js:214:13)
at Value (/Users/balupton/Projects/accounting/bevry-crm/data/node_modules/cson-parser/lib/parse.js:97:12)
at transformNode (/Users/balupton/Projects/accounting/bevry-crm/data/node_modules/cson-parser/lib/parse.js:216:12)
at Op (/Users/balupton/Projects/accounting/bevry-crm/data/node_modules/cson-parser/lib/parse.js:155:19)
at transformNode (/Users/balupton/Projects/accounting/bevry-crm/data/node_modules/cson-parser/lib/parse.js:216:12)
at addProperty (/Users/balupton/Projects/accounting/bevry-crm/data/node_modules/cson-parser/lib/parse.js:147:15)
at Array.reduce (native)
at Obj (/Users/balupton/Projects/accounting/bevry-crm/data/node_modules/cson-parser/lib/parse.js:140:28)
at transformNode (/Users/balupton/Projects/accounting/bevry-crm/data/node_modules/cson-parser/lib/parse.js:216:12)
at Value (/Users/balupton/Projects/accounting/bevry-crm/data/node_modules/cson-parser/lib/parse.js:97:12)
at transformNode (/Users/balupton/Projects/accounting/bevry-crm/data/node_modules/cson-parser/lib/parse.js:216:12)
at Block (/Users/balupton/Projects/accounting/bevry-crm/data/node_modules/cson-parser/lib/parse.js:94:12)
at transformNode (/Users/balupton/Projects/accounting/bevry-crm/data/node_modules/cson-parser/lib/parse.js:216:12)
at Object.parse (/Users/balupton/Projects/accounting/bevry-crm/data/node_modules/cson-parser/lib/parse.js:222:16)
at [eval]:1:36
at ContextifyScript.Script.runInThisContext (vm.js:26:33)
at Object.exports.runInThisContext (vm.js:79:17)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:571:32)
at Immediate.<anonymous> (bootstrap_node.js:383:29)
at runCallback (timers.js:651:20)
at tryOnImmediate (timers.js:624:5)
at processImmediate [as _immediateCallback] (timers.js:596:5)
moving over to https://github.com/bevry/cson/issues/78
Currently when a CSON file has a function in it, it just ignores the function and continues parsing. It would be nice if it quit parsing and returned/threw an error instead.