ptal / oak

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

Semantic comparison of type in sum combinator #73

Closed ptal closed 8 years ago

ptal commented 8 years ago

Issue #39 was closed but the solution is not very satisfying though correct enough for now. We want to provide a type analysis of the sum branches to enforce them to be identical. We could let the Rust compiler do that but it generates unclear error message from the generated code.

A problem is to compare the result of semantic action, they are of type syntax::ast::Ty but I do not really know how we can semantically compare them with the function of the Rust compiler. However, for now, return type of semantic action is always a "ground type", which means that it is not parametrized by a generic type. This implies that a syntactic comparison, i.e. comparing the string produced by ty_to_string should give correct result for now. We must think here how to interface with the Rust typing system to be able to semantically compare two types.