Skip to content

Parser fails if the last line is a comment #102

@movermeyer

Description

@movermeyer

The grammar fails to parse files where the last line is a comment.

Example:

foo: "1"
bar: "2"
#DO NOT CHANGE ANY OF THE ABOVE SETTINGS!

Gives the exception:

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    config = ConfigFactory.parse_string(input)
  File "/<redacted>/pyhocon/config_parser.py", line 90, in parse_string
    return ConfigParser().parse(content, basedir, resolve)
  File "/<redacted>/pyhocon/config_parser.py", line 273, in parse
    config = config_expr.parseString(content, parseAll=True)[0]
  File "/<redacted>/env/lib/python2.7/site-packages/pyparsing.py", line 1617, in parseString
    raise exc
pyparsing.ParseSyntaxException: No match found for Suppress:(W:(
)) (at char 1), (line:1, col:2)

The HOCON spec does not say this isn't allowed, so it should parse correctly as a comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions