-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
388e86d
commit 10e9fee
Showing
7 changed files
with
123 additions
and
104 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ env_logger.workspace = true | |
log.workspace = true | ||
pest = "2.7.5" | ||
pest_derive = "2.7.5" | ||
serde.workspace = true |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,32 @@ | ||
use introspect::Introspect; | ||
use pest_derive::Parser; | ||
|
||
#[cfg(test)] | ||
mod tests; | ||
|
||
#[derive(Debug, Parser)] | ||
#[derive(Debug, Introspect, Parser)] | ||
#[grammar = "v1/wdl.pest"] | ||
pub struct Parser; | ||
|
||
/// Gets a rule by name. | ||
/// | ||
/// # Examples | ||
/// | ||
/// ``` | ||
/// use wdl_grammar as wdl; | ||
/// | ||
/// let rule = wdl::v1::get_rule("document"); | ||
/// assert!(matches!(rule, Some(_))); | ||
/// | ||
/// let rule = wdl::v1::get_rule("foo-bar-baz-rule"); | ||
/// assert!(!matches!(rule, Some(_))); | ||
/// ``` | ||
pub fn get_rule(rule: &str) -> Option<Rule> { | ||
for candidate in Rule::all_rules() { | ||
if format!("{:?}", candidate) == rule { | ||
return Some(*candidate) | ||
} | ||
} | ||
|
||
None | ||
} |