groupon / cson-parser

Simple & safe CSON parser
BSD 3-Clause "New" or "Revised" License
132 stars 27 forks source link

Bug: empty object and block commenting #54

Open aaarichter opened 8 years ago

aaarichter commented 8 years ago

There is some sort of bug in the parser when an empty object is set inside a single cson file

works: empty object normal comment

# test
{}

empty object without block comment

{}

top level object is not empty

###
# test
###
EN: {}

fails:

###
# test
###
{}

Console output

SyntaxError: Syntax error on line 1, column 1: One top level value expected
  at nodeTransforms.Block (/node_modules/cson-parser/lib/parse.js:82:15)
  at transformNode (/node_modules/cson-parser/lib/parse.js:207:12)
  at Object.parse (/node_modules/cson-parser/lib/parse.js:213:12)
aaarichter commented 8 years ago

The problem seems to be happening in the coffee-script's lexter.tokenizer( ) function at https://github.com/jashkenas/coffeescript/blob/65c35e05a18bef4e302e6fd29c5d0783dd0b8363/src/coffee-script.coffee#L58

I found a workaround that passes the parser:

{
###
# test
###
}