Skip to content

IntStream's size's documentation includes EOF but it shouldn't based on implementation #4783

Open
@asztrikx

Description

@asztrikx

This affects multiple targets but for example in C# target:

IIntstream defines Size in documentation as the length of stream + 1 (EOF):
Returns the total number of symbols in the stream, including a single EOF

However for example BaseInputCharStream defines Size as n

where n is set to input's size only e.g. in AntlrInputStream

this.n = input.Length;

I tested this with the following code:

var input = "test";
var lexer = new ExampleLexer(new AntlrInputStream(input));
var expected = input.Length + 1;
var got = lexer.InputStream.Size; // IIntstream
Trace.Assert(expected == got, $"Expected: {expected}, got: {got}");
	// Expected: 5, got: 4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions