Commit 3b77ae67 authored by Vladimír Štill's avatar Vladimír Štill
Browse files

evalweb: Adapt to changes in lib

parent e3567716
from flask import Blueprint, render_template, request
from flask_wtf import FlaskForm # type: ignore
from wtforms import RadioField # type: ignore
from lib.parsing import ParsingError
from lib.parser import ParsingError
from evalweb.web_checker import WebChecker, Language, CompositeException
from evalweb.examples import examples, convert_examples
from typing import Optional
......
from typing import Dict, Tuple
from lib.parsing import Parser
from lib import parser
parser = Parser()
examples: Dict[Tuple[str, str], Tuple[str, str]] = {}
convert_examples: Dict[str, str] = {}
......@@ -18,16 +17,16 @@ teacher_forms = [('DFA', teacher_dfa),
('REG', student_reg)]
student_forms = [('DFA', student_dfa),
('TOT', parser.dfa_to_str(parser.str_to_dfa(student_dfa)
('TOT', parser.dfa_to_str(parser.dfa(student_dfa)
.total())),
('MIN', parser.dfa_to_str(parser.str_to_dfa(student_dfa)
('MIN', parser.dfa_to_str(parser.dfa(student_dfa)
.minimize())),
('CAN', parser.dfa_to_str(parser.str_to_dfa(student_dfa)
('CAN', parser.dfa_to_str(parser.dfa(student_dfa)
.total().canonize())),
('MIC', parser.dfa_to_str(parser.str_to_dfa(student_dfa)
('MIC', parser.dfa_to_str(parser.dfa(student_dfa)
.minimize().canonize())),
('EFA', student_efa),
('NFA', parser.nfa_to_str(parser.str_to_nfa(student_efa)
('NFA', parser.nfa_to_str(parser.nfa(student_efa)
.eliminate_epsilon())),
('GRA', student_gra),
('REG', student_reg)]
......
import lib.reg as reg
from lib.parsing import Parser, ParsingError
from lib import reg, parser
from lib.parser import ParsingError
from lib.checker import transform, dfa_transform, nfa_transform, check_task, \
check_alphabets
from typing import List, Optional
......@@ -19,7 +19,6 @@ class Language: # contains information about formalism and its language
self.string = string
self.task = task
parser = Parser()
dfa = dfa_transform(self.string, self.task)
self.minimal = parser.dfa_to_str(dfa.minimize().canonize())
......@@ -45,7 +44,6 @@ class Language: # contains information about formalism and its language
def gen_is_task(self, task: str) -> str:
teacher = "NFA" if self.task == "EFA" else self.task
parser = Parser()
assert self.dfa is not None
dfa = parser.dfa_to_str(self.dfa.canonize())
return f"{teacher}-{task}:{dfa}"
......@@ -127,7 +125,6 @@ class WebChecker:
student_string=self.student_string)
def convert(self, student_type: str) -> str:
parser = Parser()
if self.task in {"DFA", "TOT", "MIN", "CAN", "MIC"}:
dfa = dfa_transform(self.student_string, student_type)
# avoid confusion by making the automaton total if the input
......@@ -220,7 +217,6 @@ class WebChecker:
return picture # name of static image file to show in feedback
def language(self, dfa: reg.DFA) -> Language:
parser = Parser()
return Language(parser.dfa_to_str(dfa))
def DFA_lines(self, str_: str) -> None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment