Module make_parser

Module make_parser 

Source
Expand description

Makefile parsing and purification

§Makefile Parser and Purification

This module provides parsing, AST representation, and purification for GNU Makefiles.

§Features

  • Parse GNU Makefiles to AST
  • Purify Makefiles for determinism and idempotency
  • Generate safe, reproducible Makefiles
  • Property-based testing for all transformations

§Safety Note

Makefile parser uses unwrap() and indexing on checked invariants (validated syntax, regex captures). Positions and splits are validated before access for performance in hot paths. Some parser functions are placeholders during development.

§Usage

use bashrs::make_parser::{parse_makefile, generate_purified_makefile};

let makefile = r#"
.PHONY: test
test:
    cargo test
"#;

let ast = parse_makefile(makefile).unwrap();
let purified = generate_purified_makefile(&ast);

Re-exports§

pub use ast::MakeAst;
pub use ast::MakeItem;
pub use ast::MakeMetadata;
pub use error::MakeParseError;
pub use error::SourceLocation;
pub use generators::generate_purified_makefile;
pub use parser::extract_function_calls;
pub use parser::parse_makefile;
pub use purify::purify_makefile;
pub use purify::PurificationResult;
pub use test_generator::MakefileTestGenerator;
pub use test_generator::MakefileTestGeneratorOptions;

Modules§

ast
AST (Abstract Syntax Tree) for GNU Makefiles
error
Enhanced error types for Makefile parser
generators
Code generators for Makefile AST
lexer
Lexer for Makefiles
parser
Makefile parser
purify
semantic
Semantic analysis for Makefile AST
test_generator
Test Generation for Purified Makefiles