mirror of
https://github.com/ParkerTenBroeck/automata.git
synced 2026-06-06 21:24:06 -04:00
fixed TM example and compiler error
This commit is contained in:
parent
7cfd6c1fcd
commit
b26abc1cfc
2 changed files with 16 additions and 8 deletions
|
|
@ -413,6 +413,13 @@ impl<'a, 'b> TmCompiler<'a, 'b> {
|
||||||
.emit_error("transition state not defined as state", to_state.1);
|
.emit_error("transition state not defined as state", to_state.1);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
if !self.symbols.contains_key(&Symbol(to_tape.0)) {
|
||||||
|
self.ctx.emit_error(
|
||||||
|
"transition tape symbol not defined as tape symbol",
|
||||||
|
to_tape.1,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
let entry: &mut _ = self
|
let entry: &mut _ = self
|
||||||
.transitions
|
.transitions
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ d(q1, b, B) = { (q1, epsilon) }`,
|
||||||
),
|
),
|
||||||
|
|
||||||
new Example("TM", "a^nb^n",
|
new Example("TM", "a^nb^n",
|
||||||
`// accepts all strings on {a,b}+ of the form anbn
|
`// accepts all strings on {a,b}+ of the form a^n^bn
|
||||||
|
|
||||||
type = TM
|
type = TM
|
||||||
Q = { q0, q1, q2, q3, q4 } // set of internal states
|
Q = { q0, q1, q2, q3, q4 } // set of internal states
|
||||||
|
|
@ -378,18 +378,19 @@ T = { a, b, X, Y, B } // tape alphabet
|
||||||
B = B // the blank symbol (tape initializer symbol)
|
B = B // the blank symbol (tape initializer symbol)
|
||||||
q0 = q0 // initial state
|
q0 = q0 // initial state
|
||||||
|
|
||||||
d(q0,a)=(q1,x,R)
|
d(q0,a)=(q1,X,R)
|
||||||
d(q1,a)=(q1,a,R)
|
d(q1,a)=(q1,a,R)
|
||||||
d(q1,Y)=(q1,y,R)
|
d(q1,Y)=(q1,Y,R)
|
||||||
d(q1,b)=(q2,y,L)
|
d(q1,b)=(q2,Y,L)
|
||||||
|
|
||||||
d(q2,Y)=(q2,y,L)
|
d(q2,Y)=(q2,Y,L)
|
||||||
d(q2,a)=(q2,a,L)
|
d(q2,a)=(q2,a,L)
|
||||||
d(q2,X)=(q0,x,R)
|
d(q2,X)=(q0,X,R)
|
||||||
|
|
||||||
d(q0,Y)=(q3,y,R)
|
d(q0,Y)=(q3,Y,R)
|
||||||
d(q3,Y)=(q3,y,R)
|
d(q3,Y)=(q3,Y,R)
|
||||||
d(q3,B)=(q4,B,R)
|
d(q3,B)=(q4,B,R)
|
||||||
|
|
||||||
`),
|
`),
|
||||||
|
|
||||||
// new Example("CFG", "definition",
|
// new Example("CFG", "definition",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue