import test from 'ava' ;

import { list , map } from '@aureooms/js-itertools' ;

import { grammar , ll1 } from '../../../src' ;

test( 'Dragon Book (2006) page 49' , t => {

	const start = '0';
	const eof = '$';

	const productions = [
		[ // right : 0 (start)
			[ 1 , '==' , 0 ] ,
			[ 1 ] ,
		] ,
		list( map( l => [ `=${l}` ] , 'abcdefghijklmnopqrstuvwxyz' ) ) , // letter : 1
	] ;

	const G = grammar.from( { start , eof , productions } ) ;

	t.false(ll1.is(G));

	//const table = compile(start, eof, G);

	//const tokens = tape.fromString('a=b=c');

	//const tree = parse(start, eof, G, table, tokens);

}) ;

test( 'Dragon Book (2006) page 258 exercise 4.6.6' , t => {

	const start = 'S';
	const eof = '$';

	const productions = {
		"S" : [
			[ "&S" , "&A" ] ,
			[ "&A" ]
		] ,
		"A" : [
			[ "=a" ]
		]
	} ;

	const G = grammar.from( { start , eof , productions } ) ;

	t.false(ll1.is(G));

}) ;

@@ -892,16 +892,376 @@
 1.is(G));%0A%0A%7D) ;%0A
+%0Atest( 'Dragon Book (2006) page 224 ... if the empty word is in FIRST(b), then FIRST(a) and FOLLOW(A) are disjoint sets ...' , t =%3E %7B%0A%0A%09const start = 'S';%0A%09const eof = '$';%0A%0A%09const productions = %7B%0A%09%09%22S%22 : %5B%0A%09%09%09%5B %22&A%22 , %22=x%22 %5D%0A%09%09%5D ,%0A%09%09%22A%22 : %5B%0A%09%09%09%5B %22=x%22 %5D ,%0A%09%09%09%5B %5D%0A%09%09%5D%0A%09%7D ;%0A%0A%09const G = grammar.from( %7B start , eof , productions %7D ) ;%0A%0A%09t.false(ll1.is(G));%0A%0A%7D) ;%0A

increase coverage of ll1.is