diff --git a/lab5/input.txt b/lab5/input.txt index 34ca0bd..e1d5ed5 100644 --- a/lab5/input.txt +++ b/lab5/input.txt @@ -1,5 +1,4 @@ -S -> aQ&Rb -S -> a -S -> b -Q -> Sb -R -> aS \ No newline at end of file +S->SSS +S->SS +S->bbS +S->bb \ No newline at end of file diff --git a/lab5/src/lr0/LR0Fms.dart b/lab5/src/lr0/LR0Fms.dart index 6a164cb..b2d239e 100644 --- a/lab5/src/lr0/LR0Fms.dart +++ b/lab5/src/lr0/LR0Fms.dart @@ -56,14 +56,13 @@ class LR0FMS extends FSM { super.states.add(first); super.startStates.add(first); - super.transactions.add( - Transaction.ivan(getStateByIndex(0), first, _grammar.startNonTerminal)); load_rules(first, _grammar.startNonTerminal); } void buildDFA() { // Начальное состояние соответвует G+ - пополненной грамматике create_super_zero_state(); + create_first_state(); while (true) { @@ -73,7 +72,7 @@ class LR0FMS extends FSM { try { shift(getStateByIndex(i)); } catch (e) { - print(e); + // print(e); } } int n_l = super.states.length; diff --git a/lab5/src/state_machine/FSM.dart b/lab5/src/state_machine/FSM.dart index e9bc3e9..3c25505 100644 --- a/lab5/src/state_machine/FSM.dart +++ b/lab5/src/state_machine/FSM.dart @@ -37,7 +37,8 @@ class FSM { void DumpToDOT(String path) { String res = ""; - for (var state in this.states) { + for (var state + in this.states.where((element) => getStateIndex(element) != -1)) { String shape = "circle"; if (finalStates.contains(state)) { shape = "doublecircle";