Skip to content
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

feat: build src/plcc/scanner/matcher.py #4

Open
7 tasks
StoneyJackson opened this issue Feb 1, 2025 · 4 comments · May be fixed by #22
Open
7 tasks

feat: build src/plcc/scanner/matcher.py #4

StoneyJackson opened this issue Feb 1, 2025 · 4 comments · May be fixed by #22
Assignees

Comments

@StoneyJackson
Copy link
Member

StoneyJackson commented Feb 1, 2025

Algorithm: Identify the specification rule to apply

  1. Identify rules that match a non-empty sequence of characters from the start of the unscanned input.
  2. If no such rule exists, return a LexError.
  3. If the matching rule that appears first is a skip rule, then return a Skip.
  4. Otherwise, from the matching rules, remove all skip rules, leaving only token rules.
  5. From the matching token rules, identify rules with the longest match.
  6. From the rules with the longest match, identify the rule that appears first in the lexical specification.
  7. Return this first, longest-match, Token.

Notes:
Rules do not match across newline characters.

@StoneyJackson StoneyJackson mentioned this issue Feb 1, 2025
5 tasks
@StoneyJackson StoneyJackson changed the title Build src/plcc/scanner/matcher.py feat: build src/plcc/scanner/matcher.py Feb 1, 2025
@StoneyJackson StoneyJackson transferred this issue from ourPLCC/plcc-reorg Feb 6, 2025
@StoneyJackson
Copy link
Member Author

@TheDragonApple I've created the new repository https://github.com/ourPLCC/plcc-ng and moved this issue to it. So please work on it in this new repo. I'll archive plcc-reorg soon.

@StoneyJackson StoneyJackson moved this from Ready to In progress in plcc-ng Feb 6, 2025
@TheDragonApple TheDragonApple linked a pull request Feb 7, 2025 that will close this issue
@StoneyJackson
Copy link
Member Author

StoneyJackson commented Feb 8, 2025

@TheDragonApple I added a class diagram to #9 that is relevant to this component.
Define all the data structures in that diagram that you need.

@StoneyJackson
Copy link
Member Author

This is probably your "entry point" function.

def match(lexSpec, line, index):
    '''
    Try to match a Token or Skip at index in line.text.
    Return the matched Token or Skip, or LexError if none matches.
    '''

Hope this helps.

@StoneyJackson
Copy link
Member Author

I just noticed that you have a PR and it's going well. So feel free to ignore me! :)

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

Successfully merging a pull request may close this issue.

2 participants