Conditions | 1 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | import os |
||
10 | def __init__(self, language: str, coalang_path=None): |
||
11 | """ |
||
12 | Creates a new LanguageDefinition object from file. |
||
13 | |||
14 | A Language Definition holds constants which may help parsing the |
||
15 | language. If you want to write a bear you'll probably want to use those |
||
16 | definitions to keep your bear independent of the semantics of each |
||
17 | language. |
||
18 | |||
19 | :param language: The actual language (e.g. C++). |
||
20 | :param coalang_path: Path to directory with coalang language |
||
21 | definition files. This replaces the default |
||
22 | path if given. |
||
23 | :raises FileNotFoundError: Raised when no definition is available for |
||
24 | the given language. |
||
25 | """ |
||
26 | SectionCreatable.__init__(self) |
||
27 | self.language = language.lower() |
||
28 | |||
29 | coalang_file = os.path.join( |
||
30 | coalang_path or Constants.language_definitions, |
||
31 | self.language + ".coalang") |
||
32 | |||
33 | self.lang_dict = ConfParser().parse(coalang_file)["default"] |
||
34 | |||
40 |