ptal / oak

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

Attemped out of bounds Tuple access #69

Closed Herdinger closed 9 years ago

Herdinger commented 9 years ago

When I compile following grammar I get an out of bounds error for define_to_directive: http://pastebin.com/HpihTNDF

The generated code shows that it tries to access element 2 and 3 of the tuple although the type signature has only two elements.

ptal commented 9 years ago

Hello! First of all, thank you for trying out my library, I'm really happy I got a user ;-)

I added these definitions in order to compile your file:

pub enum Directive {
  Decimal(String),
  Hex(String),
  Binary(String),
  Kilo(String),
  Literal(String),
  Define(String, Option<String>),
  Undefine(String),
  Include(String),
  Conditional(String, IfElse)
}

pub struct IfElse {
  pub ifBlock: Vec<Directive>,
  pub elseBlock: Vec<Directive>
}

For your interest, you can write an identifier with the rule identifier = !["0-9"] ["a-zA-Z0-9_"]+, therefore you can use stringify and remove stringify2.