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

docs: Add a chapter on start states to the book #468

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

ratmice
Copy link
Collaborator

@ratmice ratmice commented Aug 24, 2024

Despite the fact that I am the terriblest writer, here is a rough draft for a chapter on start states.

I still need to test the code examples and stuff so marking as draft, but would appreciate any feedback.

The following explains the syntax and semantics of Start States in lrlex.<br>
A working example can be found in the repository at [lrpar/examples/start_states](https://github.com/softdevteam/grmtools/tree/master/lrpar/examples/start_states)

# Motivation
Copy link
Member

Choose a reason for hiding this comment

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

Minor comment: # is really only for the top-level comment in an MD file (so the file should probably start with the line # Start states) and then these comments should be ##.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should be fixed in 3fad471


# Motivation

Start states are a feature from lex which can be used to add a bit of context sensitivity to lexical analysis.
Copy link
Member

Choose a reason for hiding this comment

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

"which can be used for context sensitive lexing" maybe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should be fixed in d182e4a

Additionally the lexer has a stack of states, and matching rules perform actions which modify the stack.

# The INITIAL start state
By default unless specified otherwise all lex rules are members of the *INITIAL* start state.
Copy link
Member

Choose a reason for hiding this comment

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

Can drop "By default"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should be fixed in d182e4a

<INITIAL>[\t \n]+ ;
```

Being equivalent to the lex file below with no start states specified.
Copy link
Member

Choose a reason for hiding this comment

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

s/equivalent to/This is/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should be fixed in d182e4a

<Excl>=# <-Excl>;
```

# Start state operators
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this section should come earlier and be called something like "Differences from POSiX lex"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I moved this one section higher, Which I believe does make sense because the section higher had start state operators in it, and the section renaming did seem appropriate too.

Should be fixed in aaaa782

@ltratt
Copy link
Member

ltratt commented Aug 26, 2024

This all looks good, and worth merging now. Can you line wrap to the same length as the other md files (I think 100 chars) and force push?

@ratmice
Copy link
Collaborator Author

ratmice commented Aug 26, 2024

Will try and do so later today, as well as going through and running all the code snippets.

@ratmice ratmice marked this pull request as ready for review August 26, 2024 19:30
@ratmice
Copy link
Collaborator Author

ratmice commented Aug 26, 2024

Because I made some additional changes (changed the link format so it would fit on 100 char lines), I was hesitant to squash/force push.

I tested all the complete examples containing e.g. those containing %% and fixed the one error I found.
Also removed a line that was no longer relevant.

I am happy with this now, and feel like it's ready for a squash.

@ltratt
Copy link
Member

ltratt commented Aug 26, 2024

LGTM! Please squash.

@ratmice
Copy link
Collaborator Author

ratmice commented Aug 26, 2024

Squashed.

@ltratt ltratt added this pull request to the merge queue Aug 26, 2024
Merged via the queue into softdevteam:master with commit a79beeb Aug 26, 2024
2 checks passed
@ratmice ratmice deleted the start_states_chapter branch August 26, 2024 20:26
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.

2 participants