ptal / oak

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

Infer span information #13

Closed ptal closed 8 years ago

ptal commented 8 years ago

We can infer span information when needed by the user using the knowledge conveyed by the semantic rules.

Let's say we have an expression e > f, if the type signature of f is T -> U we can inspect the type T. If T = Span<T'> and if e = T' then we can conclude the semantic action expect the data to be englobed inside a span. We can recursively inspect the type of the semantic action and add span when needed along the way.

We thus need to rely on a type Span proper to Oak but the user is still allowed to convert Oak-span into its own version inside the semantic action.