mirror of
https://github.com/ParkerTenBroeck/automata.git
synced 2026-06-06 21:24:06 -04:00
fixed final state parsing for FA, made FA transitions more visually appealing, supported identifiers starting with a numeric character
This commit is contained in:
parent
4b83fe4759
commit
9dcef68d82
3 changed files with 5 additions and 5 deletions
|
|
@ -111,7 +111,7 @@ impl<'a> Fa<'a> {
|
|||
}
|
||||
}
|
||||
TL::Item(S("F", _), list) => {
|
||||
if final_states.is_empty() {
|
||||
if !final_states.is_empty() {
|
||||
ctx.emit_error("final states already set", span);
|
||||
}
|
||||
let Some(list) = list.expect_set(ctx) else {
|
||||
|
|
@ -124,7 +124,7 @@ impl<'a> Fa<'a> {
|
|||
if states.contains_key(&State(ident)) {
|
||||
if final_states
|
||||
.insert(State(ident), StateInfo { definition: item.1 })
|
||||
.is_none()
|
||||
.is_some()
|
||||
{
|
||||
ctx.emit_error("final state redefined", item.1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ impl<'a> Lexer<'a> {
|
|||
}
|
||||
|
||||
fn begin_ident(c: char) -> bool {
|
||||
c.is_alphabetic() || c == '_' || (!c.is_ascii() && !c.is_control() && !c.is_whitespace())
|
||||
c.is_alphanumeric() || c == '_' || (!c.is_ascii() && !c.is_control() && !c.is_whitespace())
|
||||
}
|
||||
|
||||
fn continue_ident(c: char) -> bool {
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ export function setAutomaton(auto: Machine) {
|
|||
font,
|
||||
from: to_from[0],
|
||||
to: to_from[1],
|
||||
label: transitions.map(i => i.repr).join("\n"),
|
||||
label: transitions.map(i => i.repr).join(auto.type=="fa"?",":"\n"),
|
||||
});
|
||||
} else {
|
||||
edges.add({
|
||||
|
|
@ -168,7 +168,7 @@ export function setAutomaton(auto: Machine) {
|
|||
font,
|
||||
from: to_from[0],
|
||||
to: to_from[1],
|
||||
label: transitions.map(i => i.repr).join("\n"),
|
||||
label: transitions.map(i => i.repr).join(auto.type=="fa"?",":"\n"),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue