summaryrefslogtreecommitdiff
path: root/tools/fuzzing/rost/gen-dict.sh
blob: dfebc0a26dd25bc9f2f12f31dd3d569bc0f1cfed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

TOP_DIR="$SCRIPT_DIR/../../.."
OUTPUT="$SCRIPT_DIR/rost.dict"


echo > "$OUTPUT"


echo "# Syntax core keywords" >> "$OUTPUT"

cat "$TOP_DIR/src/analysis/scan/grammar.y" | \
    grep '%token.*".*' | grep -o -E '"[^"]+"' | sort >> "$OUTPUT"


echo >> "$OUTPUT"
echo "# Modifiers" >> "$OUTPUT"

"$TOP_DIR/src/rost" --dump-modifiers | sort | sed -e 's/^/"/' -e 's/$/"/' >> "$OUTPUT"


echo >> "$OUTPUT"
echo "# Namespace" >> "$OUTPUT"

"$TOP_DIR/src/rost" --dump-namespaces | sort | sed -e 's/^/"/' -e 's/$/"/' >> "$OUTPUT"


echo >> "$OUTPUT"
echo "# Identifiers" >> "$OUTPUT"

for t in "$" "#" "@" "!" "~" ;
do
    echo "\"${t}a0\"" >> "$OUTPUT"
    echo "\"${t}a1\"" >> "$OUTPUT"
    echo "\"${t}b\"" >> "$OUTPUT"
    echo "\"${t}c\"" >> "$OUTPUT"
    echo "\"${t}a*\"" >> "$OUTPUT"
    echo "\"${t}*\"" >> "$OUTPUT"
    echo "\"${t}\"" >> "$OUTPUT"

done


echo >> "$OUTPUT"
echo "# Numbers" >> "$OUTPUT"

for i in $( seq 0 32 );
do
    echo -$(( 2 ** i - 1 )) ;
    echo -$(( 2 ** i )) ;
    echo -$(( 2 ** i + 1 )) ;

    echo $(( 2 ** i - 1 )) ;
    echo $(( 2 ** i )) ;
    echo $(( 2 ** i + 1 )) ;

done | sort | uniq | sort -n >> "$OUTPUT"


echo >> "$OUTPUT"
echo "# Misc" >> "$OUTPUT"

echo "\"kb\"" >> "$OUTPUT"
echo "\"mb\"" >> "$OUTPUT"
echo "\"gb\"" >> "$OUTPUT"

echo "\"a0\"" >> "$OUTPUT"
echo "\"a1\"" >> "$OUTPUT"
echo "\"b\"" >> "$OUTPUT"
echo "\"c\"" >> "$OUTPUT"

echo "\"\\\"abcdef\\\"\"" >> "$OUTPUT"
echo "\"\\\"azerty\\\"\"" >> "$OUTPUT"
echo "\"\\\"qwertyqwerty\\\"\"" >> "$OUTPUT"
echo "\"??\"" >> "$OUTPUT"
echo "\"0?\"" >> "$OUTPUT"
echo "\"?a\"" >> "$OUTPUT"

echo >> "$OUTPUT"