PrismarineJS / node-mojangson

A mojangson parser written in node.js
17 stars 9 forks source link

Parse error when parsing trailing comma array example #2

Closed deathcap closed 8 years ago

deathcap commented 8 years ago

The readme says this mojangson is valid:

array and object can have trailing comma (example : [5,4,3,] and {"a":5,"b":6,})

but it fails to parse:

> mojangson.parse('[5,4,3,]')
Error parsing text '[5,4,3,]'
Error: Parse error on line 1:
[5,4,3,]
-------^
Expecting 'LEFTC', 'POSITIVE_INTEGER', 'STRING', 'STRINGWITHOUTQUOTE', 'TRUE', 'FALSE', 'NULL', 'FLOAT', 'FLOATSUFFIX', 'LEFTP', got 'RIGHTC'
    at Object.parseError (node-mojangson/grammar.js:148:15)
    at Object.parse (grammar.js:213:22)
    at Object.module.exports.parse (/index.js:5:19)
    at repl:1:11
    at REPLServer.defaultEval (repl.js:248:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:412:12)
    at emitOne (events.js:82:20)
    at REPLServer.emit (events.js:169:7)

the trailing comma object ({"a":5,"b":6,}) example parses ok