summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2023-11-16 00:16:37 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2023-11-16 00:16:37 (GMT)
commita72a72f7640424385f293b28c63ef55f720fcfed (patch)
treec5c36d672d9e05a8fbc8728a44d026342e995e8d /tools
parent025b364871c7a78ac03652dc6e47ee29e38199a0 (diff)
Clean the Python script converting the ROST grammar.
Diffstat (limited to 'tools')
-rw-r--r--tools/fuzzing/rost/convert.py13
1 files 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(' "<char>": [ ["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>": [ [ "<id>", "<id>", "<id>", "<idx>" ] ],' % name.lower())
+ print(' "<id>": [ ["a"], ["b"], ["c"], ["d"], ["e"], ["f"], ["g"], ["h"], ["i"], ["j"], ["k"], ["l"] ],')
+ print(' "<idx>": [ ["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