From a72a72f7640424385f293b28c63ef55f720fcfed Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Thu, 16 Nov 2023 01:16:37 +0100 Subject: Clean the Python script converting the ROST grammar. --- tools/fuzzing/rost/convert.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/fuzzing/rost/convert.py b/tools/fuzzing/rost/convert.py index 116dee6..b0ed90c 100644 --- a/tools/fuzzing/rost/convert.py +++ b/tools/fuzzing/rost/convert.py @@ -11,6 +11,14 @@ def define_PLAIN_TEXT(name, last): print(' "": [ ["0"], ["1"], ["2"], ["3"], ["4"], ["5"], ["6"], ["7"], ["8"], ["9"], ["A"], ["B"], ["C"], ["D"], ["E"], ["F"] ]%s' % (',' if not(last) else '')) +def define_IDENTIFIER(name, last): + """Create definition for the RULE_IDENTIFIER token.""" + + print(' "<%s>": [ [ "", "", "", "" ] ],' % name.lower()) + print(' "": [ ["a"], ["b"], ["c"], ["d"], ["e"], ["f"], ["g"], ["h"], ["i"], ["j"], ["k"], ["l"] ],') + print(' "": [ ["0"], ["1"], ["2"], ["3"], ["4"], ["5"], ["6"], ["7"], ["8"], ["9"] ]%s' % (',' if not(last) else '')) + + def define_SIGNED_INTEGER(name, last): """Create definition for the SIGNED_INTEGER token.""" @@ -105,7 +113,7 @@ def define_GB(name, last): __lexer_tokens = { 'PLAIN_TEXT': define_PLAIN_TEXT, 'ESCAPED_TEXT': define_PLAIN_TEXT, - 'RULE_IDENTIFIER': define_PLAIN_TEXT, + 'RULE_IDENTIFIER': define_IDENTIFIER, 'INFO_KEY': define_PLAIN_TEXT, 'SIGNED_INTEGER': define_SIGNED_INTEGER, 'UNSIGNED_INTEGER': define_UNSIGNED_INTEGER, @@ -131,7 +139,6 @@ __lexer_tokens = { 'KB': define_KB, 'MB': define_MB, 'GB': define_GB, - 'STRING': define_PLAIN_TEXT, } @@ -378,7 +385,7 @@ def output_rules(tree): for k, v in tree.items(): - print(' "<%s>": [ ' % k, end='') + print(' "<%s>": [' % k, end='') first = True -- cgit v0.11.2-87-g4458