-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcreate.sh
More file actions
executable file
·43 lines (33 loc) · 845 Bytes
/
Copy pathcreate.sh
File metadata and controls
executable file
·43 lines (33 loc) · 845 Bytes
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
#/bin/bash
if [ -z "$1" ] || [ -z "$2" ]
then
echo "Usage: ./create.sh <gramar> <namespace>"
echo "Example: ./create.sh JavaScript Parsing"
exit
fi
output_dir="output"
test_dir="test"
grammar=$1
namespace=$2
mkdir -p $output_dir
cp template/grammar.yy $output_dir/${grammar}.yy
cp template/scanner.l $output_dir/${grammar}.l
cp template/Reader.h $output_dir/${grammar}Reader.h
cp template/Reader.cpp $output_dir/${grammar}Reader.cpp
cp template/Scanner.h $output_dir/${grammar}Scanner.h
cp template/main.cpp $output_dir/main.cpp
cp template/Makefile $output_dir/Makefile
cp template/export.sh $output_dir
cd $output_dir
for file in *
do
if [ -d $file ]
then
continue
fi
sed -i "s/<grammar>/$grammar/g" $file
sed -i "s/<namespace>/$namespace/g" $file
done
mkdir -p $test_dir
mv main.cpp $test_dir
mv Makefile $test_dir