ptal / oak

A typed parser generator embedded in Rust code for Parsing Expression Grammars
Apache License 2.0
142 stars 14 forks source link

`unit_type` attribute #31

Closed ptal closed 9 years ago

ptal commented 10 years ago

Add a unit_type attribute meaning that the rule should have the type (). It do not propagate in higher rule like invisible_type.

rule = rule2?
#[unit_type]
rule2 = "test" rule2

rule has type Option<()>, if we used invisible_type it would have the type ().

ptal commented 9 years ago

Is it not the default behavior?

ptal commented 9 years ago

The default should be "inline". #[unit_type] is only useful to change the type of a rule to unit if this one doesn't have the unit type. This is part of the postponing of automatic AST generation.