Use parser class parsing DBC-files.
@@ -80,7 +80,9 @@ DBC_FMT = (
)
-def _tokenize(string):
+class Parser(textparser.Parser):
+
+ def tokenize(self, string):
keywords = set([
'BA_',
'BA_DEF_',
@@ -175,8 +177,7 @@ def _tokenize(string):
return tokens
-
-def _create_grammar():
+ def grammar(self):
version = Sequence('VERSION', 'STRING')
ns = Sequence('NS_', ':', ZeroOrMore(Any(), Sequence(Any(), ':')))
@@ -1089,8 +1090,7 @@ def load_string(string, strict=True):
return None
- grammar = _create_grammar()
- tokens = textparser.parse(string, _tokenize, grammar)
+ tokens = Parser().parse(string)
comments = _load_comments(tokens)
definitions = _load_attribute_definitions(tokens)
