NASA-PDS / pds3-product-tools

Library supporting the design/generation, validation and submission of PDS3 archival products.
https://nasa-pds.github.io/pds3-product-tools/
Apache License 2.0
0 stars 1 forks source link

Duplicate Errors (3) on NoViableAltException In Lexer #1

Open jordanpadams opened 5 years ago

jordanpadams commented 5 years ago

Certain types of bad input, such as unclosed sets, result in duplicate NoViableAltExceptions. My suspicion is that this has to do with how recovery occurs when there are no possible options for the input.

How To Repeat: Put an unclosed Set or Sequence in a label (ex. "IDENT = { 3, 4 5") Parse the label Note that 3 problems bubble up, "no viable alternative at input '{'..."

Recommended Fix: Tweak the recovery process to consume the remainder of the line and not try something else. Need to make sure that this is handled gracefully in multi-line statements such as an unclosed set that spans multiple lines. OR Begin an exhaustive process of explicitely identifying these error conditions as fall through options in the parser (see examples of unclosed quotes and bad value). The benefit of this would be that error messages can be more explicit (ex, unclosed set vs no viable alternative...). The downside is that this may be a great deal of work and there is no guarantee that you can cover every situation.

jordanpadams commented 5 years ago

The following can reproduce the aforementioned behavior:

PDS_VERSION_ID = PDS3

MRO:BARREL_BAFFLE_TEMPERATURE = (0.25 <degC>, 3.00 <degC>, 0.30 <degC>}

END

This produces the following errors:

ERROR line 17, 32: no viable alternative at input '('
ERROR line 17, 32: no viable alternative at input '('
ERROR line 17, 32: no viable alternative at input '('