Parser breaks on errant whitespace
jnovack opened this issue · 1 comments
jnovack commented
The following section fails.
1: ePDU2DeviceStatusRoleType OBJECT-TYPE
2: SYNTAX INTEGER {
3: standalone (1),
4: host (2) ,
5: slave (3)
6: }
7: ACCESS read-only
8: STATUS mandatory
9: DESCRIPTION
10: "Get this oid shows the role the PDU played on Daisy Chain Group.
11: The PDU as a Host can access whole ePDU2 content, and the PDU be standalone
12: or a Slave can access itself instead."
13: ::= {ePDU2DeviceStatusEntry 17}
The issue is the errant space on line 4 after the closing paren, which does not trip smilint
, but breaks the parser.
undefined:9881
throw peg$buildStructuredError(
^
SyntaxError: Expected "}" but "," found.
at peg$buildStructuredError (eval at compile (/Users/jnovack/Source/powerstat/node_modules/pegjs/lib/compiler/index.js:67:29), <anonymous>:874:14)
at Object.peg$parse [as parse] (eval at compile (/Users/jnovack/Source/powerstat/node_modules/pegjs/lib/compiler/index.js:67:29), <anonymous>:9881:13)
at asn2json.parse (/Users/jnovack/Source/powerstat/node_modules/asn2json/asn2json.js:14:23)
at Object.<anonymous> (/Users/jnovack/Source/powerstat/asn2json.js:4:16)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
PrimeEuler commented
The pegjs grammar file ( asn1.pegjs ) needs updated to handle the optional whitespace in the numbered list. Change
NamedNumberList = "{" _ a:NamedNumber b:("," _ c:NamedNumber{return c})* _ "}" { return [a].concat(b).clean(null,true) };
to
NamedNumberList = "{" _ a:NamedNumber b:(_"," _ c:NamedNumber{return c})* _ "}" { return [a].concat(b).clean(null,true) };
I'll push the update this weekend after testing.