Skip to content

Parsing an empty string causes System.ArgumentOutOfRange exception in 3.7.4 #596

Description

@cadmaticpgustafsson

Hello,

Parsing an empty string using the example parser from https://github.com/b3b00/csly/wiki/getting-started causes a System.ArgumentOutOfRange exception to be thrown in version 3.7.4. This is different from version 3.7.3 where where an error message is returned instead: "Unexpected end of stream. Expecting INT".

I guess the correct behavior is the one in 3.7.3, or was this change intended? This problem can be easily reproduced in the example "ExpressionParser", by changing the input string to be an empty string, and then upgrading the project to 3.7.4 or newer. I've also attached the example I tested with, it's just the expression parser. Running it from visual studio or command line will cause the exception to happen.

ParserTest.zip

Here's the call stack in case that tells you something immediately:

   at System.ThrowHelper.ThrowArgumentOutOfRange_IndexMustBeLessException()
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at sly.parser.ParseError.GetContextualMessage(String fullSource, Int32 line, Int32 column, String message)
   at sly.parser.UnexpectedTokenSyntaxError`1.GetContextualMessage(String fullSource)
   at sly.parser.ParseError.SetContextualErrorMessage(String fullSource)
   at sly.parser.Parser`2.<>c__DisplayClass29_0.<ParseWithContext>b__0(ParseError error)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at sly.parser.Parser`2.ParseWithContext(String source, Object context, String startingNonTerminal)
   at sly.parser.Parser`2.Parse(String source, String startingNonTerminal)
   at Program.<Main>$(String[] args) in C:\Users\pgustafsson\source\repos\ParserTest\ParserTest\Program.cs:line 17

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions