Skip to content

[lexer] in token position counting end boundary should be excluded #456

Closed

Description

@croraf

For example if you have JS code

let a = 5;

One of the tokens the lexer will output it will say: Token: Identifier "a", start position: 5, end position: 5

Instead it should say ... end position: 6

Activity

  1. added
    A-Bug
    on Jun 4, 2020
  2. Razican commented on Jun 6, 2020

    @Razican
    Member

    If I understand the title right, if the boundary should be excluded, then 5 is correct, right? 6 would also include the boundary.

    So, in that example, the 5th token is the a token. The first position where that token appears is the 5, and the last position where that token appears is the 5 too.

    For let for example, the first position where it appears is 1, and the last one is 3.

  3. croraf commented on Jun 6, 2020

    @croraf
    ContributorAuthor

    No. The right boundary should be excluded meaning that if the right boundary is 5, the character at position 5 is not part of the token.

    So for let you will have boundaries 1 and 4, including characters at position 1, 2 and 3. Excluding the character at position 4.

  4. Razican commented on Jun 6, 2020

    @Razican
    Member

    No. The right boundary should be excluded meaning that if the right boundary is 5, the character at position 5 is not part of the token.

    So for let you will have boundaries 1 and 4, including characters at position 1, 2 and 3. Excluding the character at position 4.

    So, then, for a, boundaries should be 5 and 6, with the 6 excluded, right?

  5. croraf commented on Jun 6, 2020

    @croraf
    ContributorAuthor

    Yes

  6. Razican commented on Jun 6, 2020

    @Razican
    Member

    Yes

    Sorry, then I don't understand the bug. The span is set correctly, from position 5 to position 5, right?

  7. yovoslav commented on Jun 13, 2020

    @yovoslav
    Contributor

    Yes

    Sorry, then I don't understand the bug. The span is set correctly, from position 5 to position 5, right?

    I think the issue is that the end boundary should be exclusive, e.g. in the example a's span is [5, 5], when it should be [5, 6).

  8. Lan2u commented on Jun 17, 2020

    @Lan2u

    This will be fixed as part of #486.

  9. linked a pull request that will close this issueNew lexer #559on Jul 26, 2020
  10. added this to the v0.10.0 milestone on Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-Bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions