ptal / oak

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

Special rule for tokens to handle spacing #28

Closed ptal closed 8 years ago

ptal commented 10 years ago

It's cumbersome to treat the spacing inside the grammar.

peg!(
  grammar ntcc;

  comparison = le / neq / lt / ge / gt / eq
  spacing = [" \n\t"]*

  tokens(spacing) {
     lt = "<"
     le = "<="
     gt = ">"
     ge = ">="
     eq = "=="
     neq = "<>"
  }
)

"tokens" is a special keyword parametrized by a separator applied before and after each tokens.

ptal commented 8 years ago

This will be handle in a different way. Due to #80 we will be able to directly match on a token stream. For now, we close this because it does not seem the "right" way anymore.