File: run

package info (click to toggle)
bisonc%2B%2B 6.09.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,984 kB
  • sloc: cpp: 9,375; ansic: 1,505; fortran: 1,134; makefile: 1,062; sh: 526; yacc: 84; lex: 60
file content (230 lines) | stat: -rwxr-xr-x 5,456 bytes parent folder | download
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/bin/bash

    # Modifiy the COMMAND variable to your taste, if your shell isn't
    # mentioned.  By specifying your COMMAND-shell last it will be used;
COMMAND="/usr/bin/tcsh -f"
#COMMAND=/bin/bash

    # Assuming bisonc++ is in your computer's search-path. If not, define
    # BISONCPP as the full path to bisconc++:
#BISONCPP=/home/frank/git/bisonc++/src/bisonc++/tmp/bin/binary
BISONCPP=bisonc++

    # UNCOMMENT the following variables if you want to run the examples from
    # the source distribution's documentation/regression directory rather than
    # from bisonc++ documentation's `regression' subdirectory.
SKEL=../../../../skeletons
BISONCPP="../../../../tmp/bin/binary -S ${SKEL}"

example()
{
    let EXAMPLE=${EXAMPLE}+1

    orgdir=`pwd`

    echo 
    echo Running example $1

    case $2 in
        ("go")
        ;;
        (*)
            return 0
        ;;
    esac

    cd $1
    cwd=`pwd`

    echo --------------------------------
    echo
    cat doc
    echo
    echo '(waiting for the compilation to complete ...)'
    echo --------------------------------
    
    cd parser
    echo $BISONCPP --construction $3 grammar

    $BISONCPP --construction --debug $3 grammar
    [ -e /usr/bin/bison -a -e bgram ] && bison -v bgram

    echo    
    if [ -s ../demo.cc ] 
    then
        cd ../scanner
        flexc++  lexer
        cd ..
        g++ $ICMAKE_CPPSTD -Wall -o demo *.cc */*.cc
        echo "ENTERING A SHELL: \`demo' runs the program, use \`exit' to return"
        echo "      (the grammar analysis is in the \`parser' subdirectory)"
    else    
        echo "ENTERING A SHELL: Inspect the results, use \`exit' to return"
    fi

    echo "bison's output is in \`bgram.output', bisonc++'s output in \`grammar.output'"
    echo
    $COMMAND

    cd $cwd

        # the doc-test is a safequard agains accidentally removing files

    [ -s doc ]                      &&  \
    find ./ -type f                     \
        \(                              \
            -name Parser*h      -or     \
            -name parserbase.h  -or     \
            -name scannerbase.h         \
        \)                              \
        -exec rm '{}' ';'           &&  \
    find ./ -type f                     \
        -not -regex '.*/_.*'            \
        -not -name doc                  \
        -not -name demo.cc              \
        -not -name bgram                \
        -not -name grammar              \
        -not -regex '.*/*h'             \
        -not -regex '.*/dallas.*'       \
        -not -name input                \
        -not -name lexer                \
        -exec rm '{}' ';'

    cd $orgdir
    tput clear
}

readRUN()
{
    read RUN
    if [ "$RUN" == "" ] 
    then 
        RUN=go
    else
        RUN=skip
        tput clear
    fi
}

tput clear

echo "
    This script feeds several grammars to bisonc++. Some grammars allow you to
execute a little demo-program. Some examples do not have demo programs. All
grammars are also fed to bison \(if existing\), producing their output on a file
\`bgram.output' Bisonc++'s output is provided in the file \`grammar.output'

    From the various test/parser directories, bisonc++ should be accessible as

$BISONCPP

    If that's not true for you, consider changing the BISONCPP variable in
this script.

    With each example, hitting a plain Enter creates the parser and optionally
builds the demo-program

    Note that bison always defines one additional state compared with
bisonc++. Bison accepts its input in a separate state, whereas bisonc++
accepts when <EOF> is seen in combination with the reduction of the
the augmented grammar rule G* -> G . Bisonc++ will not execute an action here,
but that should be ok, since the grammar specification does not make G* -> G
visible, so no action can be associated with its reduction anyway.

[press Enter to continue]
"

read RUN
tput clear
echo


EXAMPLE=1
PRE="Enter x to skip; a plain Enter to run; ^c to end this script"

echo $EXAMPLE: AHO Example 4.42, p. 231
echo $PRE
readRUN
example aho4.42 $RUN

echo $EXAMPLE: two R/R conflicts
echo $PRE
readRUN
example rr2 $RUN

echo $EXAMPLE: the dangling-else conflict
echo $PRE
readRUN
example danglingelse $RUN

echo $EXAMPLE: S/R and R/R conflicts
echo $PRE
readRUN
example conflicts $RUN

echo $EXAMPLE: not derivable sentence
echo $PRE
readRUN
example nosentence $RUN

echo $EXAMPLE: a reduced icmake V 7.00 grammar
echo $PRE
readRUN
example icmake1 $RUN

echo $EXAMPLE: the full icmake V 7.00 grammar
echo $PRE
readRUN
example icmake2 $RUN

echo $EXAMPLE: using an error-production
echo $PRE
readRUN
example error $RUN

echo "$EXAMPLE: Simple ;-separated list of numbers and error recovery"
echo $PRE
readRUN
example naive $RUN

echo $EXAMPLE: adding two integral values
echo $PRE
readRUN
example simplecalc $RUN

echo $EXAMPLE: using the location stack
echo $PRE
readRUN
example location $RUN

echo $EXAMPLE: the man-page calculator
echo $PRE
readRUN
example calculator $RUN

echo $EXAMPLE: a calculator from the C++ Annotations
echo $PRE
readRUN
example annotations $RUN

echo $EXAMPLE: an extensive calculator supporting functions
echo $PRE
readRUN
example fun $RUN

echo $EXAMPLE: an example of polymorphic semantic values
echo $PRE
readRUN
example polymorphic $RUN --insert-stype

echo $EXAMPLE: a grammar in which reduces precede shifts
echo $PRE
readRUN
example mandayam $RUN


tput clear

echo "
    END OF SCRIPT
"