aboutsummaryrefslogtreecommitdiffstats
path: root/extra-tools/dumper.sh
blob: 668913dc6a75a7dbf1a03b61df38198c496a403c (plain) (blame)
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
#!/bin/bash

INPUT="./testFuncs1.c"
OUTPUT="./dump"
OPTIONS="--"
RUN="1"

while [[ $# -gt 0 ]]
do
	passarg="$1"

	case $passarg in
		-i|--input)
		INPUT="$2"
		shift
		;;
		-o|--output)
		OUTPUT="$2"
		shift
		;;
		-op|--options)
		OPTIONS="$2"
		shift
		;;
		-h|--help)
		echo "the script simply dumps the AST of the input."
		echo "-i|--input 	the input file full path."
		echo "-o|--output 	the output fule full path."
		echo "-op|--options 	extra options to pass to clang"
		echo "-h|--help 	prints out the help."
		RUN="0"
		;;
		*)
		echo $1 is not a valid argument...
		RUN="0"
		shift
	esac
	shift
done

if [[ "$RUN" == "1" ]]; then
	"clang" -Xclang -ast-dump -fsyntax-only "$INPUT" "$OPTIONS" > "$OUTPUT"

fi