Skip to content

add documentation for PUSH_LITERAL#58

Merged
tomtau merged 2 commits intopest-parser:masterfrom
yshavit:push_literal
Mar 25, 2025
Merged

add documentation for PUSH_LITERAL#58
tomtau merged 2 commits intopest-parser:masterfrom
yshavit:push_literal

Conversation

@yshavit
Copy link
Contributor

@yshavit yshavit commented Mar 24, 2025

See pest-parser/pest#1092

Summary by CodeRabbit

  • New Features

    • Introduced a new grammar keyword, PUSH_LITERAL, that allows literal text to be added to a stack during parsing. This enhancement increases flexibility when matching paired delimiters.
  • Documentation

    • Updated the documentation with examples demonstrating the use of PUSH_LITERAL for improved grammar definitions and clarified the functionality of the DROP keyword.

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2025

Walkthrough

The changes introduce the PUSH_LITERAL keyword to the pest grammar syntax, which accepts a literal string as an argument, matches without consuming input, and pushes the string onto the stack. The documentation has been updated to include examples of using PUSH_LITERAL for handling expressions with various delimiters, while maintaining existing functionalities like PUSH, DROP, and PEEK.

Changes

File Change Summary
src/grammars/syntax.md Introduced new keyword PUSH_LITERAL which takes a literal string, always matches (non-consuming), and pushes its argument onto the stack; added examples demonstrating its use with matching open and closing delimiters.

Sequence Diagram(s)

sequenceDiagram
    participant P as Parser
    participant G as Grammar Engine
    participant S as Stack
    
    P->>G: Process input with rule containing PUSH_LITERAL("literal")
    G->>S: Push "literal" onto the stack (non-consuming match)
    S-->>G: Acknowledgement of push
    G-->>P: Continue parsing without consuming input
Loading

Poem

Oh, what a delightful twist in code today,
I hopped through grammar fields in a joyful way.
PUSH_LITERAL brings a magic, literal touch,
Adding stack finesse without altering much.
With whiskers twitching and a heart so light,
This rabbit celebrates changes with pure delight!
🐇💕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6420250 and ca92534.

📒 Files selected for processing (1)
  • src/grammars/syntax.md (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/grammars/syntax.md

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@@ -452,8 +452,8 @@ pest_derive = { version = "2.7", features = ["grammar-extras"] }
## The stack (WIP)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe, it doesn't need to be marked WIP if it's completed with these docs: https://github.com/pest-parser/pest/blob/master/pest/src/lib.rs#L266 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, PEEK especially has fairly intricate behavior with its ranges. I'm not sure how much this book is meant to be a high/mid-level tutorial, vs down in the details; put another way, I'm not sure what the distinction is been the book and the libs.rs docs, and how one decides what information goes where.

Copy link
Contributor

Choose a reason for hiding this comment

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

this "syntax" section tries to be an overview, so it'd be good to at least mention it; the specific high/mid-level tutorial could be added later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added some more text about the various operators, and updated the title to remove the "WIP" tag. (Note that that also causes the URL anchor text to change.)

@tomtau tomtau merged commit f76c9bb into pest-parser:master Mar 25, 2025
@yshavit yshavit deleted the push_literal branch March 25, 2025 06:42
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