# first column is the text to parse # second is the expected output # third is the names of the components. test_table = [ [" |y> " , "|y>" , "naked ket"], [" 3|z> " , "3.000|z>" , "int-coeff ket"], [" 3.1415|pi>" , "3.142|pi>" , "float-coeff ket"], ["|a> + 7|b>" , "|a> + 7.000|b>" , "literal superposition"], ["name|x>" , "|name-x>" , "op ket"], ["name 2|x> + name|y>" , "2.000|name-x> + |name-y>" , "op int ket + op ket"], ["name (|x> + 7|y>)" , "|name-x> + 7.000|name-y>" , "op (literal superposition)"], ["op name|x>" , "|op-name-x>" , "multi-op, ket"], ["op op |x>" , "|op-op-x>" , "multi-op, ket"], ["op^2 |x>" , "|op-op-x>" , "multi-op, ket"], ["union(|a> + |b>,|c> + |d> + |e>)" , "|a> + |b> + |c> + |d> + |e>" , "union(literal superposition,literal superposition)"], ["union(name|x>,op^2|x>)" , "|name-x> + |op-op-x>" , "union(op ket, op ket)"], ["union(2|a> + 7|b>,1.42 op|x>)" , "2.000|a> + 7.000|b> + 1.420|op-x>" , "union(literal sp, float op ket)"], ["mult[7] name|x>" , "7.000|name-x>" , "mult[] op ket"], ["7 name|x>" , "7.000|name-x>" , "int op ket"], ["op 5.2 name |x>" , "5.200|op-name-x>" , "op float op ket"], ["name 3.142 |x>" , "3.142|name-x>" , "op float ket"], ["junk |x>" , "|>" , "junk ket"], ["junk op |x>" , "|>" , "junk op ket"], ["op junk |x>" , "|>" , "op junk ket"], ["fish|x> + |a> + |b>" , "|fish-x> + |a> + |b>" , "op ket + ket + ket"], ["fish |x> + (|a> + |b>)" , "|fish-x> + |a> + |b>" , "op ket + (ket + ket)"], ["fish |y> + (|c>)" , "|fish-y> + |c>" , "op ket + (ket)"], ["(|c>) + fish|x>" , "|c> + |fish-x>" , "(ket) + op ket"], ["(|a>)" , "|a>" , "(ket)"], ["(|a> + |b>)" , "|a> + |b>" , "(ket + ket)"], ["2.7(|a> + |b>)" , "2.700|a> + 2.700|b>" , "float (ket + ket)"], ["op (|x> + |y>)" , "|op-x> + |op-y>" , "op (ket + ket)"], ["junk (|x> + |y>)" , "|>" , "junk (ket + ket)"], ["range (|n: 5>,|n: 8>)" , "|n: 5> + |n: 6> + |n: 7> + |n: 8>" , "range(ket,ket)"], ["simm(|a>+|b>,|b>+|c>+|d>)|simm>" , "0.333|simm>" , "simm(literal-sp,literal-sp) ket"], ["simm(|a>+|b>,|b>) 3|simm>" , "1.500|simm>" , "simm(literal-sp,literal-sp) int ket"], ["mult(2|a> + 3|b>,5|b> + 7|a>)" , "14.000|a> + 15.000|b>" , "mult(literal-sp,literal-sp)"], ["5.2 mult(2|a> + 3|b>,5|b> + 7|a>)", "72.800|a> + 78.000|b>" , "float mult(literal-sp,literal-sp)"], ["union(|a> + |b>,fish(|x> + |y>))" , "|a> + |b> + |fish-x> + |fish-y>" , "union(literal-sp,op(ket + ket))"], ["union(|a>+|b>,7.2 fish(|x>+|y>))" , "|a> + |b> + 7.200|fish-x> + 7.200|fish-y>" , "union(literal-sp,float op(ket + ket))"], ["junk(|a> + |b>,|c>)" , "|>" , "junk(literal-sp,ket)"], ["junk(|a>,|b>)" , "|>" , "junk(ket,ket)"], ["union(|a>,|b>,|c>)" , "|a> + |b> + |c>" , "union(ket,ket,ket)"], ["union(|a>+|b>,|c>,|d>+|e>)" , "|a> + |b> + |c> + |d> + |e>" , "union(literal-sp,ket,literal-sp)"], ["sp(|a> + |b> + |c>)" , "|sp> + |a> + |b> + |c>" , "sp(literal-sp)"], ["(|a>,|b>)" , "" , "(ket,ket)"], ["arithmetic(|n: 3>,|+>,|n: 5>)" , "|n: 8>" , "arithmetic(ket,|+>,ket)"], ["|a> + (|b>)" , "|a> + |b>" , "ket + (ket)"], ["ket-simm(|a>+|b>,|b>+|c>+|d>)" , "0.333|simm>" , "ket-simm(literal-sp,literal-sp)"], ["7 algebra(|a>+2| >,|^>,2| >)+3| >", "7.000|a*a> + 28.000|a> + 31.000| >" , "int algebra(literal-sp,|^>,ket) + ket"], ["algebra(|a>,|^>,|3>) + algebra(|b>,|^>,|2>)", "" , "algebra(ket,ket,ket) + algebra(ket,ket,ket)"], ["arithmetic(to-km|km: 9>,|+>,to-km|miles: 1>)", "|km: 10.609>" , "arithmetic(op-ket,ket,op-ket)"], ]