ptal / oak

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

Recursive type analysis #61

Closed ptal closed 8 years ago

ptal commented 9 years ago

If recursive rules are calling each other we do not infer a unit type.

ptal commented 9 years ago

It is the desired behavior... This is related to the fact that we can not build recursive type by ourself. We must re-introduce the recursive type analysis in the typing module.

ptal commented 8 years ago

Actually, this is not true for all grammars, let consider this grammar:

r = "a" r
   / "b"

It actually leads to a bug because r is not well-typed, it has the type Tuple(vec[rule_id]) where rule_id is the type of r. We would like to allow this kind of rules and infer the type unit.

Therefore, we propose to infer unit type for recursive types by default and provide a warning informing that the unit type has been affected by default to r because it has a recursive type definition.