Skip to content

Commit

Permalink
Add declaration_start parameter to DeclarationParser parse_value (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchevobbe authored Feb 21, 2025
1 parent 008a91c commit 5e477ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/rules_and_declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub trait DeclarationParser<'i> {
&mut self,
name: CowRcStr<'i>,
input: &mut Parser<'i, 't>,
_declaration_start: &ParserState,
) -> Result<Self::Declaration, ParseError<'i, Self::Error>> {
Err(input.new_error(BasicParseErrorKind::UnexpectedToken(Token::Ident(name))))
}
Expand Down Expand Up @@ -279,7 +280,7 @@ where
error_behavior,
|input| {
input.expect_colon()?;
parser.parse_value(name, input)
parser.parse_value(name, input, &start)
},
)
};
Expand Down Expand Up @@ -408,12 +409,13 @@ pub fn parse_one_declaration<'i, 't, P, E>(
where
P: DeclarationParser<'i, Error = E>,
{
let start = input.state();
let start_position = input.position();
input
.parse_entirely(|input| {
let name = input.expect_ident()?.clone();
input.expect_colon()?;
parser.parse_value(name, input)
parser.parse_value(name, input, &start)
})
.map_err(|e| (e, input.slice_from(start_position)))
}
Expand Down
1 change: 1 addition & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ impl<'i> DeclarationParser<'i> for JsonParser {
&mut self,
name: CowRcStr<'i>,
input: &mut Parser<'i, 't>,
_declaration_start: &ParserState,
) -> Result<Value, ParseError<'i, ()>> {
let mut value = vec![];
let mut important = false;
Expand Down

0 comments on commit 5e477ab

Please sign in to comment.