ptal / oak

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

Testing attribute, for testing the library and compile-time error. #29

Open ptal opened 10 years ago

ptal commented 10 years ago

We want to add static analysis, before that, we should be able to test our grammar:

peg!(
  grammar arith;

  // The rule 'le' is not reachable.
  #![test(warn(unreachable_rule(le))]

  comparison = lt / le
  lt = "<" spacing
  le = "<=" spacing
ptal commented 8 years ago

We will keep this kind of test simple in a first time because we don't know how the Rust procedural macros will evolve and what kind of support they could offer later. We propose the following:

#![compile(error, UnreachableRule)]

error can be replaced by warning or note or help. This follows the error level in rustc_errors::Level.

It can also tests for parse errors, therefore we force global attribute to be declared in the beginning.

ptal commented 3 years ago

See if trybuild is suited for this task.