1 ########################################################################
3 # This software is part of the ast package #
4 # Copyright (c) 1986-2009 AT&T Intellectual Property #
5 # and is licensed under the #
6 # Common Public License, Version 1.0 #
7 # by AT&T Intellectual Property #
9 # A copy of the License is available at #
10 # http://www.opensource.org/licenses/cpl1.0.txt #
11 # (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
13 # Information and Software Systems Research #
17 # Glenn Fowler <gsf@research.att.com> #
19 ########################################################################
22 # AT&T Bell Laboratories
24 # @(#)gentab (gsf@research.att.com) 07/17/94
28 # %flags [ prefix=<prefix> ] [ index=<index> ] [ init=<init> ]
30 # %keyword <name> [ prefix=<prefix> ] [ index=<index> ] [ init=<init> ] [ first=<id> ] [ last=<id> ]
32 # %sequence [ prefix=<prefix> ] [ index=<index> ] [ init=<init> ]
35 case `(typeset -u s=a n=0; ((n=n+1)); print $s$n) 2>/dev/null` in
38 typeset
-i counter err_line
69 ksh
) ((err_line
=err_line
+1)) ;;
70 *) err_line
=`expr $err_line + 1` ;;
96 %flags|
%keywords|
%sequence
)
99 ksh
) ((n
=counter-1
)) ;;
100 *) n
=`expr $counter - 1` ;;
102 echo "#define $prefix$last $n"
116 elif test $define = 1
122 ?
*) eval $index=$counter ;;
135 "") echo "$command: ${err_file}line $err_line: $type table name omitted" >&2
142 then echo "$name"'[] ='
161 *) eval value
=\$
$index
164 [0123456789]*) counter
=$value ;;
168 case $define:$first in
169 1:?
*) echo "#define $prefix$first $counter" ;;
172 %*) echo "$command: ${err_file}line $err_line: $1: unknown keyword" >&2
180 ksh
) ID
=${1#[!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]} ;;
181 *) ID
=`echo $1 | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | sed 's/^[^ABCDEFGHIJKLMNOPQRSTUVWXYZ_]//'` ;;
184 %flags
) if test $define = 1
185 then case $counter in
186 32) echo "$command: ${err_file}line $err_line: warning: $1: too many flag bits" >&2 ;;
187 1[56789]|
[23][0123456789]) long
=L
;;
190 echo "#define $prefix$ID (1$long<<$counter)"
195 then echo "#define $prefix$ID $counter"
198 then echo " \"$1\", $prefix$ID,"
203 then echo "#define $prefix$ID $counter"
208 ksh
) ((counter
=counter
+1)) ;;
209 *) counter
=`expr $counter + 1` ;;
218 case $define:$last in
220 ksh
) ((n
=counter-1
)) ;;
221 *) n
=`expr $counter - 1` ;;
223 echo "#define $prefix$last $n"