ptal / oak

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

Range type for sequence of atoms #85

Closed ptal closed 3 years ago

ptal commented 8 years ago

A sequence of atoms has type Vec<char> where char is the underlying parsing atom. The problem is that we would actually prefer to have a value containing the beginning and the end of the stream range. Example: The expression ["0-9"]+ has type Vec<char> but semantic actions are sometimes more efficient if they directly work on the underlying str slice, in this case, building a vector is unnecessary.

Design

trait Span {
  type Output;
  fn span(&self) -> Self::Output;
}