예제 #1
0
def parse_html(path):
    trie.empty()
    edge_list.clear()
    parser = Parser()
    html_paths = get_html_files(path)
    begin_time = time.time()
    for file in html_paths:
        print('Parsing file -- ' + file)
        links, words = parser.parse(file)
        for word in words:
            trie.add_word(word, file)
        for link in links:
            edge_list.append((file, link))
    if html_paths:
        print("Direktorijum parsiran za %s sekundi" % (time.time() - begin_time))
예제 #2
0
def test_parser():
    path = os.path.dirname(os.path.abspath(__file__)) + '/'
    fn_in = path + 'bubble_sort.txt'
    fs = FileSystem(file_name=fn_in)
    af = AsciiFilter(file_system=fs)
    ac = AsciiClassifier(ascii_filter=af)
    lc = LexicalClassifier(ascii_classifier=ac)
    lr = LexicalReclassifier(lexical_classifier=lc)
    pr = Parser(lexical_reclassifier=lr)
    fs = None
    af = None
    ac = None
    lc = None
    lr = None

    assert pr.parse()
예제 #3
0
 def setUp(self):
     raw = Opener.open_file('1')
     self.kakuro = Parser.parse(raw)
예제 #4
0
if DEBUG:
    test_id = '14'  # Redni broj test primera [01-15]
    path_root = './'
    args = {}
    args['src'] = f'{path_root}{test_id}/src.pas'  # Izvorna PAS datoteka
    args['gen'] = f'{path_root}{test_id}/gen.c'  # Generisana C datoteka
else:
    import argparse

    arg_parser = argparse.ArgumentParser()
    arg_parser.add_argument('src')  # Izvorna PAS datoteka
    arg_parser.add_argument('gen')  # Generisana C datoteka
    args = vars(arg_parser.parse_args())

with open(args['src'], 'r') as source:
    text = source.read()
    lexer = Lexer(text)
    tokens = lexer.lex()
    parser = Parser(tokens)
    ast = parser.parse()
    # grapher = Grapher(ast)
    # grapher.graph()
    symbolizer = Symbolizer(ast)
    symbolizer.symbolize()
    generator = Generator(ast)
    generator.generate(args['gen'])
    runner = Runner(ast)
    runner.run()

# ACINONYX - END
예제 #5
0
 def setUp(self):
     raw = Opener.open_file('..\\modules\\fields\\1')
     self.kakuro = Parser.parse(raw)