Loading test_cfl_cfg.py +6 −7 Original line number Original line Diff line number Diff line from lib.common import Nonterminal, Terminal, Eps from lib.common import Nonterminal, Terminal, Eps from lib.parsing import Parser import lib.parser import lib.cfl as cfl import lib.cfl as cfl from copy import deepcopy from copy import deepcopy Loading Loading @@ -149,8 +149,7 @@ def test_equal(): def test_parser(): def test_parser(): parser = Parser() pg0 = lib.parser.cfg("S -> aA | ε | aBC | <foo>C; " pg0 = parser.str_to_cfg("S -> aA | ε | aBC | <foo>C; " "A -> a; " "A -> a; " "B -> b; " "B -> b; " "C -> c\n" "C -> c\n" Loading test_reg.py +3 −6 Original line number Original line Diff line number Diff line from lib.parsing import Parser import lib.parser from lib.dfa import DFA from lib.dfa import DFA def is_can(dfa: str) -> bool: def is_can(dfa: str) -> bool: parser = Parser() return parse(dfa).is_canonical() return parse(dfa).is_canonical() def parse(dfa: str) -> DFA: def parse(dfa: str) -> DFA: parser = Parser() return lib.parser.dfa(dfa) return parser.str_to_dfa(dfa) def to_str(dfa: DFA) -> str: def to_str(dfa: DFA) -> str: parser = Parser() return lib.parser.dfa_to_str(dfa) return parser.dfa_to_str(dfa) def test_can() -> None: def test_can() -> None: ex1 = "init=1 (1,a)=1 (1,b)=2 (2,b)=1 (2,a)=1 final={2}" ex1 = "init=1 (1,a)=1 (1,b)=2 (2,b)=1 (2,a)=1 final={2}" Loading Loading
test_cfl_cfg.py +6 −7 Original line number Original line Diff line number Diff line from lib.common import Nonterminal, Terminal, Eps from lib.common import Nonterminal, Terminal, Eps from lib.parsing import Parser import lib.parser import lib.cfl as cfl import lib.cfl as cfl from copy import deepcopy from copy import deepcopy Loading Loading @@ -149,8 +149,7 @@ def test_equal(): def test_parser(): def test_parser(): parser = Parser() pg0 = lib.parser.cfg("S -> aA | ε | aBC | <foo>C; " pg0 = parser.str_to_cfg("S -> aA | ε | aBC | <foo>C; " "A -> a; " "A -> a; " "B -> b; " "B -> b; " "C -> c\n" "C -> c\n" Loading
test_reg.py +3 −6 Original line number Original line Diff line number Diff line from lib.parsing import Parser import lib.parser from lib.dfa import DFA from lib.dfa import DFA def is_can(dfa: str) -> bool: def is_can(dfa: str) -> bool: parser = Parser() return parse(dfa).is_canonical() return parse(dfa).is_canonical() def parse(dfa: str) -> DFA: def parse(dfa: str) -> DFA: parser = Parser() return lib.parser.dfa(dfa) return parser.str_to_dfa(dfa) def to_str(dfa: DFA) -> str: def to_str(dfa: DFA) -> str: parser = Parser() return lib.parser.dfa_to_str(dfa) return parser.dfa_to_str(dfa) def test_can() -> None: def test_can() -> None: ex1 = "init=1 (1,a)=1 (1,b)=2 (2,b)=1 (2,a)=1 final={2}" ex1 = "init=1 (1,a)=1 (1,b)=2 (2,b)=1 (2,a)=1 final={2}" Loading