use std::cmp;
use lalrpop_util::ParseError;
use quickcheck::{Arbitrary, Gen};
use rand::Rng;
use super::lexer;
use super::grammar;
use super::component::{Component, components_merge};
// We put each type of token in its own struct, which contains exactly
// one element, a String (e.g., 'Foo(String)').
macro_rules! token {
( $name:ident, $g:ident, $arbitrary:block ) => {
#[derive(Debug, Clone)]
#[allow(non_camel_case_types)]
struct $name(String);
impl $name {
fn to_string(self) -> String {
self.0.to_string()
}
}
impl Arbitrary for $name {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
let $g = g;
// eprintln!("{} -> generating...", stringify!($name));
let r = $arbitrary;
// eprintln!("{} <- {:?}", stringify!($name), r);
$name(r.to_string())
}
}
};
( $name:ident, $g:ident, $arbitrary:block, $self:ident, $shrink:block ) => {
#[derive(Debug, Clone)]
#[allow(non_camel_case_types)]
struct $name(String);
impl $name {
fn to_string(self) -> String {
self.0.to_string()
}
}
impl Arbitrary for $name {