Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow use of rust keywords as pest rules (#750)
* 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. * 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 * `fmt` & Revert removal of `validate_rust_keywords` * Remove unused `Span` import * 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.
- Loading branch information
Showing
3 changed files
with
41 additions
and
40 deletions.
There are no files selected for viewing
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
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
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