Skip to content

Add Tokenizer::tokenize_with_location() API #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from

Conversation

segoon
Copy link

@segoon segoon commented Jan 8, 2021

  • add TokenWithLocation to track Token location
  • implement Tokenizer::tokenize_with_location() -> Result<Vec<TokenWithLocation>, ..>
  • refactor line/column tracking to alter current position along with peekable.next() (the old approach with duplicate position tracking was error-prone and contained a bug in multiline word parsing, see the test)
  • eliminate String copying for Tokenizer, use &'a str instead
  • minor TokenizerError column fixes, now it shows the missing symbol position and not the expected token start location

@coveralls
Copy link

coveralls commented Jan 8, 2021

Pull Request Test Coverage Report for Build 472821192

  • 140 of 147 (95.24%) changed or added relevant lines in 1 file are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.05%) to 92.028%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/tokenizer.rs 140 147 95.24%
Files with Coverage Reduction New Missed Lines %
src/tokenizer.rs 3 91.68%
Totals Coverage Status
Change from base Build 469532238: -0.05%
Covered Lines: 4883
Relevant Lines: 5306

💛 - Coveralls

@@ -253,6 +253,31 @@ impl fmt::Display for Whitespace {
}
}

/// Location in input string
#[derive(Debug, PartialEq, Clone)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be copy as well, as it is just a struct with u64,u64

@Dandandan
Copy link
Contributor

This looks really cool @segoon . Could you fix the conflicts?

@alamb
Copy link
Contributor

alamb commented Aug 20, 2021

Hi @segoon -- sorry for the delay in review. I am going to help out now with this repo and we are working to clear the backlog. Is this PR still something you would like to work on to help contribute?

@alamb
Copy link
Contributor

alamb commented Sep 9, 2021

I am closing what look like stale PRs in this repo; I apologize in advance if this is a mistake -- please feel free to reopen if you want to keep working on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants