| Conditions | 1 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | import os |
||
| 9 | def __init__(self, language_family: str, language: str): |
||
| 10 | """ |
||
| 11 | Creates a new LanguageDefinition object from file. |
||
| 12 | |||
| 13 | A Language Definition holds constants which may help parsing the |
||
| 14 | language. If you want to write a bear you'll probably want to use those |
||
| 15 | definitions to keep your bear independent of the semantics of each |
||
| 16 | language. |
||
| 17 | |||
| 18 | :param language_family: The language family. E.g. C for C++ and C |
||
| 19 | and C# and so on. |
||
| 20 | :param language: The actual language (e.g. C++). |
||
| 21 | :raises FileNotFoundError: Raised when no definition is available for |
||
| 22 | the given family. |
||
| 23 | :raises KeyError: Raised when no definition is available for |
||
| 24 | the given language. |
||
| 25 | """ |
||
| 26 | SectionCreatable.__init__(self) |
||
| 27 | self.language = language.lower() |
||
| 28 | filename = os.path.join(Constants.language_definitions, |
||
| 29 | language_family.lower() + ".coalang") |
||
| 30 | self.lang_dict = ConfParser().parse(filename)[language.lower()] |
||
| 31 | |||
| 34 |