| Total Complexity | 3 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | """ |
||
| 18 | class SDoc1Interpreter: |
||
| 19 | """ |
||
| 20 | Class for processing SDoc1 documents. |
||
| 21 | """ |
||
| 22 | |||
| 23 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 24 | def __init__(self, styled_output): |
||
| 25 | """ |
||
| 26 | Object constructor. |
||
| 27 | """ |
||
| 28 | |||
| 29 | self._styled_output = styled_output |
||
| 30 | """ |
||
| 31 | Styled output formatter. |
||
| 32 | |||
| 33 | :type: sdoc.style.SdocStyle.SdocStyle |
||
| 34 | """ |
||
| 35 | |||
| 36 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 37 | def process(self, infile, outfile): |
||
| 38 | """ |
||
| 39 | Processes a SDoc1 document. |
||
| 40 | |||
| 41 | :param str infile: The input filename with the SDoc1 document. |
||
| 42 | :param str outfile: The output filename with the SDoc2 document. |
||
| 43 | """ |
||
| 44 | in_stream = antlr4.FileStream(infile) |
||
| 45 | |||
| 46 | with open(outfile, 'wt') as out_stream: |
||
| 47 | lexer = sdoc1Lexer(in_stream) |
||
| 48 | tokens = antlr4.CommonTokenStream(lexer) |
||
| 49 | parser = sdoc1Parser(tokens) |
||
| 50 | tree = parser.sdoc() |
||
| 51 | |||
| 52 | visitor = SDoc1Visitor(self._styled_output, root_dir=os.path.dirname(os.path.realpath(infile))) |
||
| 53 | |||
| 54 | visitor.output = out_stream |
||
| 55 | visitor.visit(tree) |
||
| 56 | |||
| 57 | return visitor.errors |
||
| 58 | |||
| 60 |