PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/work/generate_visitors.sh

http://github.com/tybor/Liberty
Shell | 88 lines | 64 code | 10 blank | 14 comment | 7 complexity | 7dec8ee9ee85f623933817d6bfccaa6d MD5 | raw file
 1#!/usr/bin/env bash
 2
 3# This file is part of Liberty Eiffel.
 4#
 5# Liberty Eiffel is free software: you can redistribute it and/or modify
 6# it under the terms of the GNU General Public License as published by
 7# the Free Software Foundation, version 3 of the License.
 8#
 9# Liberty Eiffel is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with Liberty Eiffel.  If not, see <http://www.gnu.org/licenses/>.
16
17cd ${0%/*}
18p=$(pwd)
19p=${p%/*}
20
21cd $p/src/tools/semantics/code/visitors
22
23rm -f *.e *.bak
24
25for type in ASSERTION ENTITY EXPRESSION FEATURE INSTRUCTION; do
26    what=$(echo $type | tr '[A-Z]' '[a-z]')
27    dir=${what}s
28    test $dir == "entitys" && dir=entities
29
30    visitor=liberty_${what}_visitor.e
31
32    echo Generating ${dir}
33
34    cat > $visitor <<EOF
35-- This file is part of Liberty Eiffel.
36--
37-- Liberty Eiffel is free software: you can redistribute it and/or modify
38-- it under the terms of the GNU General Public License as published by
39-- the Free Software Foundation, version 3 of the License.
40--
41-- Liberty Eiffel is distributed in the hope that it will be useful,
42-- but WITHOUT ANY WARRANTY; without even the implied warranty of
43-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
44-- GNU General Public License for more details.
45--
46-- You should have received a copy of the GNU General Public License
47-- along with Liberty Eiffel.  If not, see <http://www.gnu.org/licenses/>.
48--
49deferred class LIBERTY_${type}_VISITOR
50inherit
51EOF
52    for f in ../${dir}/*.e; do
53	if ! grep -q 'deferred class' $f; then
54	    f=${f##*/}; f=${f%.e}
55	    c=$(echo $f | tr '[a-z]' '[A-Z]')
56	    g=${f}_visitor
57	    v=$(echo $g | tr '[a-z]' '[A-Z]')
58	    cat > ${g}.e <<EOF
59-- This file is part of Liberty Eiffel.
60--
61-- Liberty Eiffel is free software: you can redistribute it and/or modify
62-- it under the terms of the GNU General Public License as published by
63-- the Free Software Foundation, version 3 of the License.
64--
65-- Liberty Eiffel is distributed in the hope that it will be useful,
66-- but WITHOUT ANY WARRANTY; without even the implied warranty of
67-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
68-- GNU General Public License for more details.
69--
70-- You should have received a copy of the GNU General Public License
71-- along with Liberty Eiffel.  If not, see <http://www.gnu.org/licenses/>.
72--
73deferred class $v
74inherit VISITOR
75feature {$c}
76   visit_$f (v: $c) is deferred end
77end
78EOF
79	    se pretty ${g}.e
80	    echo $v >> $visitor
81	fi
82    done
83    echo end >> $visitor
84
85    se pretty $visitor
86done
87
88rm -f *.bak