-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Actually parse sed scripts #424
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AtkinsSJ
force-pushed
the
sed
branch
3 times, most recently
from
May 31, 2024 14:19
831cc4e
to
d230460
Compare
I've found this useful for stubbing out parts of a grammar during development.
The counterpart of stringOf(), it reads characters until it matches its parameter.
Let's organise this a bit.
This is ported over from an old forgotten branch I'd deleted, then thankfully managed to dig up again. 😅 Instead of making GroupCommand contain child commands, use a flat array for commands and implement groups as GroupStartCommand and GroupEndCommand. This makes it much simpler to iterate the commands list in order to jump to labels. Then implement those labels and the commands that use them: b, t, and T. Also add the s SubstituteCommand, and combine the code for the q and Q commands.
Some shell apps care about what order the arguments appear in. When `parseArgs()` is called with `tokens: true`, it produces this `tokens` array which represents all the command line options and arguments, in order, which is useful for these more advanced cases.
Sed is now finally able to actually run scripts, instead of ignoring all input and running a hard-coded test script!
These make more sense combined into one Command which is controlled by constructor parameters: - b, t and T - d and D - g and G - h and H - p and P
I think this is ready now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Finally,
sed
is actually useful! 🎉In the end, I did manage to parse things like the
s
andy
commands using the grammar DSL instead of a custom Parser class for them. Fors
it's about half as much code, too. Pretty nice! Thought that's not including the code for theDelimiterParser
.