2 releases
0.1.1 | Aug 12, 2022 |
---|---|
0.1.0 | Aug 9, 2022 |
#1132 in Programming languages
7KB
54 lines
Generates molt argument parsers.
Usage:
use molt_argparse::molt_argparse;
#[molt_argparse("{netlist} port_pin_list -period -name -comment:_ignored_comment -add")]
fn sdc_create_clock(
netlist: &mut NetlistDatabase,
port_pin_list: Vec<i32>, period: f32, name: String, _ignored_comment: Option<String>, add: bool
) -> i32 {
port_pin_list.len() as i32
}
Tips:
- Braces enclosed parameter indicates the context to parse:
{netlist}
. There can be at most 1 such declaration, and it must be the first in declarations (but not necessarily in func arglist). - Identifiers indicate the corresponding function arguments:
port_pin_list
, in the order that they would appear. - Dash-started ones indicate key-value arguments
-period
, with option to rename it:-comment:_ignored_comment
. If the value type is bool, it become a presence-or-not flag with no value followed. - All types must be compatible with molt's Value parsing/unparsing mechanism. The floating-type, integer-type, and boolean type are processed through corresponding
molt::as_*
, and all other types go throughmolt::as_other
.Vec<xx>
types are automatically parsed in a way likeMoltList
. - If any item is declared as
Option<SomeType>
in the function arguments, it would become optional. If not so, it is by default mandatory. - The return value definition can be any plain type or vector type, or
Option<>
types with None indicating error. There's no way to specify error status yet -- it is recommended to use some last_error mechanism.
Dependencies
~3MB
~59K SLoC