SDoc2Interpreter.process()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 19
Code Lines 10

Duplication

Lines 19
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 10
dl 19
loc 19
ccs 10
cts 10
cp 1
rs 9.9
c 0
b 0
f 0
cc 1
nop 2
crap 1
1 1
import antlr4
2 1
from cleo.io.io import IO
3
4 1
from sdoc import sdoc2
5 1
from sdoc.antlr.sdoc2Lexer import sdoc2Lexer
6 1
from sdoc.antlr.sdoc2Parser import sdoc2Parser
7 1
from sdoc.sdoc2.SDoc2Visitor import SDoc2Visitor
8
9
10 1 View Code Duplication
class SDoc2Interpreter:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11
    """
12
    Class for processing SDoc1 documents.
13
    """
14
15
    # ------------------------------------------------------------------------------------------------------------------
16 1
    def __init__(self, io: IO):
17
        """
18
        Object constructor.
19
        """
20
21 1
        self._io: IO = io
22 1
        """
23
        Styled output formatter.
24
        """
25
26
    # ------------------------------------------------------------------------------------------------------------------
27 1
    def process(self, infile: str) -> int:
28
        """
29
        Processes a SDoc1 document and returns the error count.
30
31
        :param str infile: The input filename with the SDoc2 document.
32
        """
33 1
        in_stream = antlr4.FileStream(infile, 'utf-8')
34
35 1
        lexer = sdoc2Lexer(in_stream)
36 1
        tokens = antlr4.CommonTokenStream(lexer)
37 1
        parser = sdoc2Parser(tokens)
38 1
        tree = parser.sdoc()
39 1
        visitor = SDoc2Visitor(infile, self._io)
40
41 1
        visitor.visit(tree)
42
43 1
        sdoc2.node_store.prepare_content_tree()
44
45 1
        return visitor.errors
46
47
# ----------------------------------------------------------------------------------------------------------------------
48