Skip to content

Commit 1eb079a

Browse files
committed
fix(provers): migrate parsers to the nom 8 API
Dependabot #204 bumped nom 7.1.3 -> 8.0.0 (a breaking major) without migrating the parser code, leaving cargo build red on main with 16 E0618/E0282 errors. nom 8 returns Parser structs from alt/opt/many0/ separated_list0 (you call .parse(input), not the value as a function) and removed the tuple combinator (plain tuples now implement Parser). Migrate provers/{agda,idris2,lean}.rs: import nom::Parser, route the 16 combinator call-sites through .parse(input), and replace tuple((a,b,c)) with (a,b,c). Verified: cargo build debug+release clean; cargo test --lib = 1174 passed, 0 failed (601 provers tests incl. the three migrated parsers). https://claude.ai/code/session_01UAqDQaMwpUqWHUSZekGZWv
1 parent 27466d0 commit 1eb079a

3 files changed

Lines changed: 23 additions & 19 deletions

File tree

src/rust/provers/agda.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use nom::{
1515
bytes::complete::{tag, take_until, take_while},
1616
character::complete::{alpha1, multispace0, multispace1, space0, space1},
1717
multi::many0,
18-
IResult,
18+
IResult, Parser,
1919
};
2020
use std::collections::HashMap;
2121
use std::path::PathBuf;
@@ -496,7 +496,7 @@ fn ws(input: &str) -> IResult<&str, ()> {
496496
}
497497

498498
fn identifier(input: &str) -> IResult<&str, String> {
499-
let (input, first) = alt((alpha1, tag("_")))(input)?;
499+
let (input, first) = alt((alpha1, tag("_"))).parse(input)?;
500500
let (input, rest) =
501501
take_while(|c: char| c.is_alphanumeric() || c == '_' || c == '-' || c == '\'')(input)?;
502502
Ok((input, format!("{}{}", first, rest)))
@@ -544,7 +544,7 @@ fn parse_postulate(input: &str) -> IResult<&str, AgdaDecl> {
544544
}
545545

546546
fn parse_import(input: &str) -> IResult<&str, AgdaDecl> {
547-
let (input, _) = alt((tag("import"), tag("open import")))(input)?;
547+
let (input, _) = alt((tag("import"), tag("open import"))).parse(input)?;
548548
let (input, _) = space1(input)?;
549549
let (input, module) = take_until("\n")(input)?;
550550
Ok((
@@ -562,11 +562,12 @@ fn parse_decl(input: &str) -> IResult<&str, AgdaDecl> {
562562
parse_postulate,
563563
parse_import,
564564
parse_type_sig,
565-
))(input)
565+
))
566+
.parse(input)
566567
}
567568

568569
fn parse_module(input: &str) -> IResult<&str, Vec<AgdaDecl>> {
569-
many0(parse_decl)(input)
570+
many0(parse_decl).parse(input)
570571
}
571572

572573
#[cfg(test)]

src/rust/provers/idris2.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use nom::{
1818
combinator::opt,
1919
multi::{many0, separated_list0},
2020
sequence::preceded,
21-
IResult,
21+
IResult, Parser,
2222
};
2323
use std::collections::HashMap;
2424
use std::path::PathBuf;
@@ -1012,14 +1012,14 @@ fn block_comment(input: &str) -> IResult<&str, ()> {
10121012
}
10131013

10141014
fn identifier(input: &str) -> IResult<&str, String> {
1015-
let (input, first) = alt((alpha1, tag("_")))(input)?;
1015+
let (input, first) = alt((alpha1, tag("_"))).parse(input)?;
10161016
let (input, rest) =
10171017
take_while(|c: char| c.is_alphanumeric() || c == '_' || c == '\'' || c == '?')(input)?;
10181018
Ok((input, format!("{}{}", first, rest)))
10191019
}
10201020

10211021
fn qualified_name(input: &str) -> IResult<&str, String> {
1022-
let (input, parts) = separated_list0(tag("."), identifier)(input)?;
1022+
let (input, parts) = separated_list0(tag("."), identifier).parse(input)?;
10231023
Ok((input, parts.join(".")))
10241024
}
10251025

@@ -1033,7 +1033,7 @@ fn parse_module_decl(input: &str) -> IResult<&str, Idris2Decl> {
10331033

10341034
fn parse_import(input: &str) -> IResult<&str, Idris2Decl> {
10351035
let (input, _) = ws(input)?;
1036-
let (input, public) = opt(preceded(tag("public"), space1))(input)?;
1036+
let (input, public) = opt(preceded(tag("public"), space1)).parse(input)?;
10371037
let (input, _) = tag("import")(input)?;
10381038
let (input, _) = space1(input)?;
10391039
let (input, module) = qualified_name(input)?;
@@ -1081,7 +1081,7 @@ fn parse_data(input: &str) -> IResult<&str, Idris2Decl> {
10811081

10821082
// Parse type parameters (simplified)
10831083
let (input, _) = take_while(|c| c != '=' && c != '\n')(input)?;
1084-
let (input, _) = opt(tag("="))(input)?;
1084+
let (input, _) = opt(tag("=")).parse(input)?;
10851085

10861086
// Parse constructors (simplified - just capture until next declaration)
10871087
let (input, _) = take_while(|c| c != '\n')(input)?;
@@ -1162,11 +1162,12 @@ fn parse_decl(input: &str) -> IResult<&str, Idris2Decl> {
11621162
parse_interface,
11631163
parse_implementation,
11641164
parse_type_sig,
1165-
))(input)
1165+
))
1166+
.parse(input)
11661167
}
11671168

11681169
fn parse_module(input: &str) -> IResult<&str, Vec<Idris2Decl>> {
1169-
many0(parse_decl)(input)
1170+
many0(parse_decl).parse(input)
11701171
}
11711172

11721173
// ============================================================================

src/rust/provers/lean.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use nom::{
2121
bytes::complete::{tag, take_while},
2222
character::complete::{alpha1, multispace0, space1},
2323
combinator::opt,
24-
sequence::{preceded, terminated, tuple},
25-
IResult,
24+
sequence::{preceded, terminated},
25+
IResult, Parser,
2626
};
2727
use std::collections::HashMap;
2828
use std::path::PathBuf;
@@ -829,7 +829,7 @@ fn skip_whitespace_and_comments(input: &str) -> &str {
829829
/// Parse an identifier
830830
fn parse_identifier(input: &str) -> IResult<&str, String> {
831831
let (input, _) = multispace0(input)?;
832-
let (input, first) = alt((alpha1, tag("_")))(input)?;
832+
let (input, first) = alt((alpha1, tag("_"))).parse(input)?;
833833
let (input, rest) = take_while(|c: char| c.is_alphanumeric() || c == '_' || c == '\'')(input)?;
834834
Ok((input, format!("{}{}", first, rest)))
835835
}
@@ -877,7 +877,8 @@ fn parse_declaration(input: &str) -> IResult<&str, LeanDeclaration> {
877877
parse_inductive_decl,
878878
parse_structure_decl,
879879
parse_instance_decl,
880-
))(input)
880+
))
881+
.parse(input)
881882
}
882883

883884
/// Parse a theorem declaration
@@ -897,9 +898,10 @@ fn parse_theorem_decl(input: &str) -> IResult<&str, LeanDeclaration> {
897898

898899
// Parse optional proof
899900
let (input, value) = opt(preceded(
900-
tuple((multispace0, tag(":="), multispace0)),
901+
(multispace0, tag(":="), multispace0),
901902
parse_proof_body,
902-
))(input)?;
903+
))
904+
.parse(input)?;
903905

904906
Ok((
905907
input,
@@ -1026,7 +1028,7 @@ fn parse_instance_decl(input: &str) -> IResult<&str, LeanDeclaration> {
10261028
let (input, _) = multispace0(input)?;
10271029

10281030
// Optional name
1029-
let (input, name) = opt(terminated(parse_identifier, multispace0))(input)?;
1031+
let (input, name) = opt(terminated(parse_identifier, multispace0)).parse(input)?;
10301032

10311033
let (input, _) = tag(":")(input)?;
10321034
let (input, ty) = parse_type_expr(input)?;

0 commit comments

Comments
 (0)