SemGuS-git / Semgus-Parser

Library and tool for parsing SemGuS specifications
MIT License
4 stars 1 forks source link

Comment as last element of list confuses reader #23

Closed kjcjohnson closed 3 years ago

kjcjohnson commented 3 years ago

The current reader implementation gets baffled by a list where the final "element" is a comment. E.g.:

(list 1 2 3
  ; only a comment here
) ; <-- closing parenthesis here

The problem is in ReadDelimitedList:

  1. After reading 3, it consumes whitespace
  2. The next character it sees is ;, which is not whitespace, so it recursively calls Read to get the next S-expression
  3. Read calls ReadImpl, which returns NothingSentinel (as it was a comment), but then immediately tries to read another (real) token from the stream
  4. ReadImpl now reads the closing parenthesis, which signals an error

Maybe the fix is just to have ReadDelimitedList call ReadImpl instead of Read, and handle the NothingSentinel itself?

kjcjohnson commented 3 years ago

@WileyCorning - heads up if you're implementing anything with the S-expression parser. I'll fix this "soon", but it's easy to work around in the meantime (just remove the comment).