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

Allow use of rust keywords as pest rules #750

Merged
merged 5 commits into from Dec 14, 2022
Merged

Allow use of rust keywords as pest rules #750

merged 5 commits into from Dec 14, 2022

Commits on Dec 13, 2022

  1. Allow use of rust keywords as rule names

    This prefixes all non-builtin rules with r# to allow for use of rust keywords as pest rules.
    
    This refactors code to use format_ident! rather than Ident::new (with format! internally in some cases), as it does the same thing internally. Span is defined to fallback to Span::call_site() in case of being given a non-ident, so there shouldn't be any issues.
    
    Updated generate_complete test case and removed the rust keyword restriction from the validator.
    DvvCz committed Dec 13, 2022
    Copy the full SHA
    d17e5a2 View commit details
    Browse the repository at this point in the history
  2. Test fixes and missed simplifications

    * Updated tests that use identifiers to escape them with `r#`
    
    * Changed the previously added `generate_complete` `r#if` test to ensure using an identifier as an expression is properly emitted
    
    * Removed some redundant Ident::new() inside of `format_ident!` calls
    DvvCz committed Dec 13, 2022
    Copy the full SHA
    c8d05c1 View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    1553429 View commit details
    Browse the repository at this point in the history
  4. Remove unused Span import

    DvvCz committed Dec 13, 2022
    Copy the full SHA
    1399483 View commit details
    Browse the repository at this point in the history

Commits on Dec 14, 2022

  1. Fix whitespace/comment issue

    `generate_rule` was checking the name after formatting for whether it was `WHITESPACE` or `COMMENT`.
    
    Re-imported proc_macro2::Span for tests since they still use it.
    DvvCz committed Dec 14, 2022
    Copy the full SHA
    dbbbe8a View commit details
    Browse the repository at this point in the history