peginator_codegen 0.7.0

Buildscript support for peginator (a PEG parser generator)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Copyright (C) 2022, Alex Badics
// This file is part of peginator
// Licensed under the MIT license. See LICENSE file in the project root for details.

use super::{BUILD_TIME, VERSION};

pub fn generate_source_header(grammar: &str) -> String {
    let crc32 = crc::Crc::<u32>::new(&crc::CRC_32_ISO_HDLC).checksum(grammar.as_bytes());

    format!(
        "// This file was generated by Peginator v{VERSION} built at {BUILD_TIME}\n\
         // CRC-32/ISO-HDLC of the grammar file: {crc32:08x}\n\
         // Any changes to it will be lost on regeneration\n",
    )
}