mktokens revision 98463
11556Srgrimes#!/bin/sh - 21556Srgrimes# 31556Srgrimes# Copyright (c) 1991, 1993 41556Srgrimes# The Regents of the University of California. All rights reserved. 51556Srgrimes# 61556Srgrimes# This code is derived from software contributed to Berkeley by 71556Srgrimes# Kenneth Almquist. 81556Srgrimes# 91556Srgrimes# Redistribution and use in source and binary forms, with or without 101556Srgrimes# modification, are permitted provided that the following conditions 111556Srgrimes# are met: 121556Srgrimes# 1. Redistributions of source code must retain the above copyright 131556Srgrimes# notice, this list of conditions and the following disclaimer. 141556Srgrimes# 2. Redistributions in binary form must reproduce the above copyright 151556Srgrimes# notice, this list of conditions and the following disclaimer in the 161556Srgrimes# documentation and/or other materials provided with the distribution. 171556Srgrimes# 3. All advertising materials mentioning features or use of this software 181556Srgrimes# must display the following acknowledgement: 191556Srgrimes# This product includes software developed by the University of 201556Srgrimes# California, Berkeley and its contributors. 211556Srgrimes# 4. Neither the name of the University nor the names of its contributors 221556Srgrimes# may be used to endorse or promote products derived from this software 231556Srgrimes# without specific prior written permission. 241556Srgrimes# 251556Srgrimes# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 261556Srgrimes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 271556Srgrimes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 281556Srgrimes# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 291556Srgrimes# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 301556Srgrimes# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 311556Srgrimes# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 321556Srgrimes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 331556Srgrimes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 341556Srgrimes# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 351556Srgrimes# SUCH DAMAGE. 361556Srgrimes# 371556Srgrimes# @(#)mktokens 8.1 (Berkeley) 5/31/93 3850471Speter# $FreeBSD: head/bin/sh/mktokens 98463 2002-06-20 05:20:50Z jmallett $ 391556Srgrimes 401556Srgrimes# The following is a list of tokens. The second column is nonzero if the 411556Srgrimes# token marks the end of a list. The third column is the name to print in 421556Srgrimes# error messages. 431556Srgrimes 4469029Skristemp=`/usr/bin/mktemp -t ka` 4569029Skriscat > $temp <<\! 461556SrgrimesTEOF 1 end of file 471556SrgrimesTNL 0 newline 481556SrgrimesTSEMI 0 ";" 491556SrgrimesTBACKGND 0 "&" 501556SrgrimesTAND 0 "&&" 511556SrgrimesTOR 0 "||" 521556SrgrimesTPIPE 0 "|" 531556SrgrimesTLP 0 "(" 541556SrgrimesTRP 1 ")" 551556SrgrimesTENDCASE 1 ";;" 561556SrgrimesTENDBQUOTE 1 "`" 571556SrgrimesTREDIR 0 redirection 581556SrgrimesTWORD 0 word 591556SrgrimesTIF 0 "if" 601556SrgrimesTTHEN 1 "then" 611556SrgrimesTELSE 1 "else" 621556SrgrimesTELIF 1 "elif" 631556SrgrimesTFI 1 "fi" 641556SrgrimesTWHILE 0 "while" 651556SrgrimesTUNTIL 0 "until" 661556SrgrimesTFOR 0 "for" 671556SrgrimesTDO 1 "do" 681556SrgrimesTDONE 1 "done" 691556SrgrimesTBEGIN 0 "{" 701556SrgrimesTEND 1 "}" 711556SrgrimesTCASE 0 "case" 721556SrgrimesTESAC 1 "esac" 731556SrgrimesTNOT 0 "!" 741556Srgrimes! 7569029Skrisnl=`wc -l $temp` 7617987Speterexec > token.h 7769029Skrisawk '{print "#define " $1 " " NR-1}' $temp 781556Srgrimesecho ' 791556Srgrimes/* Array indicating which tokens mark the end of a list */ 801556Srgrimesconst char tokendlist[] = {' 8169029Skrisawk '{print "\t" $2 ","}' $temp 821556Srgrimesecho '}; 831556Srgrimes 8498463Sjmallettconst char *const tokname[] = {' 851556Srgrimessed -e 's/"/\\"/g' \ 861556Srgrimes -e 's/[^ ]*[ ][ ]*[^ ]*[ ][ ]*\(.*\)/ "\1",/' \ 8769029Skris $temp 881556Srgrimesecho '}; 891556Srgrimes' 9069029Skrissed 's/"//g' $temp | awk ' 9198463Sjmallett/TIF/{print "#define KWDOFFSET " NR-1; print ""; print "const char *const parsekwd[] = {"} 921556Srgrimes/TIF/,/neverfound/{print " \"" $3 "\","}' 931556Srgrimesecho ' 0 941556Srgrimes};' 951556Srgrimes 9669029Skrisrm $temp 97