Skip to content

Commit

Permalink
Fix parsing of &'a mut T in type grammar
Browse files Browse the repository at this point in the history
Fixes #304
  • Loading branch information
kevinmehall committed Jul 16, 2022
1 parent 056b5ca commit 24482eb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 38 deletions.
74 changes: 37 additions & 37 deletions peg-macros/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1236,45 +1236,45 @@ pub mod peg {
let __choice_res =
match ::peg::ParseLiteral::parse_string_literal(__input, __pos, "&") {
::peg::RuleResult::Matched(__pos, __val) => {
let __seq_res =
match match ::peg::ParseLiteral::parse_string_literal(
__input, __pos, "mut",
) {
::peg::RuleResult::Matched(__pos, __val) => {
::peg::RuleResult::Matched(__pos, __val)
}
::peg::RuleResult::Failed => {
__err_state.mark_failure(__pos, "\"mut\"");
::peg::RuleResult::Failed
}
} {
::peg::RuleResult::Matched(__newpos, _) => {
::peg::RuleResult::Matched(__newpos, ())
}
::peg::RuleResult::Failed => {
::peg::RuleResult::Matched(__pos, ())
}
};
let __seq_res = match match __parse_LIFETIME(
__input,
__state,
__err_state,
__pos,
) {
::peg::RuleResult::Matched(pos, _) => {
::peg::RuleResult::Matched(pos, ())
}
::peg::RuleResult::Failed => ::peg::RuleResult::Failed,
} {
::peg::RuleResult::Matched(__newpos, _) => {
::peg::RuleResult::Matched(__newpos, ())
}
::peg::RuleResult::Failed => {
::peg::RuleResult::Matched(__pos, ())
}
};
match __seq_res {
::peg::RuleResult::Matched(__pos, _) => {
let __seq_res = match match __parse_LIFETIME(
__input,
__state,
__err_state,
__pos,
) {
::peg::RuleResult::Matched(pos, _) => {
::peg::RuleResult::Matched(pos, ())
}
::peg::RuleResult::Failed => ::peg::RuleResult::Failed,
} {
::peg::RuleResult::Matched(__newpos, _) => {
::peg::RuleResult::Matched(__newpos, ())
}
::peg::RuleResult::Failed => {
::peg::RuleResult::Matched(__pos, ())
}
};
let __seq_res =
match match ::peg::ParseLiteral::parse_string_literal(
__input, __pos, "mut",
) {
::peg::RuleResult::Matched(__pos, __val) => {
::peg::RuleResult::Matched(__pos, __val)
}
::peg::RuleResult::Failed => {
__err_state.mark_failure(__pos, "\"mut\"");
::peg::RuleResult::Failed
}
} {
::peg::RuleResult::Matched(__newpos, _) => {
::peg::RuleResult::Matched(__newpos, ())
}
::peg::RuleResult::Failed => {
::peg::RuleResult::Matched(__pos, ())
}
};
match __seq_res {
::peg::RuleResult::Matched(__pos, _) => {
let __seq_res = match __parse_rust_type(
Expand Down
2 changes: 1 addition & 1 deletion peg-macros/grammar.rustpeg
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ rule rust_path()

rule rust_type()
= BRACKET_GROUP()
/ "&" "mut"? LIFETIME()? rust_type()
/ "&" LIFETIME()? "mut"? rust_type()
/ "dyn" rust_type()
/ "impl" rust_type()
/ "(" rust_type() ** "," ")"
Expand Down
1 change: 1 addition & 0 deletions tests/run-pass/rule_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ peg::parser!( grammar ra() for str {
pub rule use_complex_args() = complex_args(u32::max(5, 10), [1,1,3,5,8,13].iter().cloned().find(|x| { x % 2 == 0 }))

pub rule lt_arg<'a>() = ""
pub rule lt_arg_mut<'a>(x: &'a mut ()) = ""
pub rule ty_arg<T>(x: &T) = ""
pub rule ty_arg_bound<T: Copy>(x: T) = ""
pub rule ty_arg_bound2<'a, T: std::marker::Copy + ?Sized + 'a>(x: T) = ""
Expand Down

0 comments on commit 24482eb

Please sign in to comment.