Theory Compose_Tests
theory Compose_Tests
imports TIGER_Grammar.LR_Prec_Parse Parser_Check
begin
section ‹Composition by reference›
text ‹A grammar may use a nonterminal ‹a.X› of an earlier grammar ‹a›. The productions
of ‹a› reachable from ‹X› are copied under the names ‹a.Y›, so the new grammar is
closed and goes through the same definitions as any other. With ‹(relation)› on both,
‹b.a_X_iff› links the copied relation to the original one.›
fun toks :: ‹nat ⇒ 'tok list ⇒ ('tok, unit) token list› where
‹toks i [] = []›
| ‹toks i (x # xs) = ⦇tok = x, span = span.make 0 i i 1 []⦈ # toks (Suc (Suc i)) xs›