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

Improving Lesson 1.3 by mentioning longest match while scanning tokens #3618

Merged
merged 3 commits into from
Sep 5, 2023

Conversation

Robertorosmaninho
Copy link
Collaborator

Fixes #3539.

It makes more sense to me to add it to Lesson 1.3 instead of Lesson 1.4, as we're introducing Parsing in this lesson. But I'm open to suggestions to improve the text and where it should be! 😄

@Robertorosmaninho Robertorosmaninho self-assigned this Sep 4, 2023
@rv-jenkins rv-jenkins changed the base branch from master to develop September 4, 2023 20:54
@radumereuta
Copy link
Contributor

@dwightguth is more familiar with the K tutorial and native English speaker. I will let him give the final approval.

Copy link
Collaborator

@dwightguth dwightguth left a comment

Choose a reason for hiding this comment

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

approved but please make one minor change

The answer is that K uses Flex to generate a scanner for the grammar. Flex looks
for the longest possible match of a regular expression in the input. If there
are ambiguities between 2 or more regular expressions, it will pick the one with
the max precedence token. You can learn more about how Flex matching works
Copy link
Collaborator

Choose a reason for hiding this comment

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

"prec attribute", not "precedence token"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

@rv-jenkins rv-jenkins merged commit 24d2b08 into develop Sep 5, 2023
8 checks passed
@rv-jenkins rv-jenkins deleted the add-lex-erexplanation-to-tutorial branch September 5, 2023 19:43
@Baltoli Baltoli mentioned this pull request Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tutorial lesson 1.4 doesn't mention maximal-munch lexing
4 participants