147105Sbostic#!/bin/sh - 247105Sbostic# 3*60708Sbostic# Copyright (c) 1991, 1993 4*60708Sbostic# The Regents of the University of California. All rights reserved. 547105Sbostic# 647105Sbostic# This code is derived from software contributed to Berkeley by 747105Sbostic# Kenneth Almquist. 847105Sbostic# 947105Sbostic# %sccs.include.redist.sh% 1047105Sbostic# 11*60708Sbostic# @(#)mktokens 8.1 (Berkeley) 05/31/93 1247105Sbostic 1347105Sbostic# The following is a list of tokens. The second column is nonzero if the 1447105Sbostic# token marks the end of a list. The third column is the name to print in 1547105Sbostic# error messages. 1647105Sbostic 1747105Sbosticcat > /tmp/ka$$ <<\! 1847105SbosticTEOF 1 end of file 1947105SbosticTNL 0 newline 2047105SbosticTSEMI 0 ";" 2147105SbosticTBACKGND 0 "&" 2247105SbosticTAND 0 "&&" 2347105SbosticTOR 0 "||" 2447105SbosticTPIPE 0 "|" 2547105SbosticTLP 0 "(" 2647105SbosticTRP 1 ")" 2747105SbosticTENDCASE 1 ";;" 2847105SbosticTENDBQUOTE 1 "`" 2947105SbosticTREDIR 0 redirection 3047105SbosticTWORD 0 word 3147105SbosticTIF 0 "if" 3247105SbosticTTHEN 1 "then" 3347105SbosticTELSE 1 "else" 3447105SbosticTELIF 1 "elif" 3547105SbosticTFI 1 "fi" 3647105SbosticTWHILE 0 "while" 3747105SbosticTUNTIL 0 "until" 3847105SbosticTFOR 0 "for" 3947105SbosticTDO 1 "do" 4047105SbosticTDONE 1 "done" 4147105SbosticTBEGIN 0 "{" 4247105SbosticTEND 1 "}" 4347105SbosticTCASE 0 "case" 4447105SbosticTESAC 1 "esac" 4553176SmarcTNOT 0 "!" 4647105Sbostic! 4747105Sbosticnl=`wc -l /tmp/ka$$` 4847105Sbosticexec > token.def 4947105Sbosticawk '{print "#define " $1 " " NR-1}' /tmp/ka$$ 5047105Sbosticecho ' 5147105Sbostic/* Array indicating which tokens mark the end of a list */ 5247105Sbosticconst char tokendlist[] = {' 5347105Sbosticawk '{print "\t" $2 ","}' /tmp/ka$$ 5447105Sbosticecho '}; 5547105Sbostic 5647105Sbosticchar *const tokname[] = {' 5747105Sbosticsed -e 's/"/\\"/g' \ 5847105Sbostic -e 's/[^ ]*[ ][ ]*[^ ]*[ ][ ]*\(.*\)/ "\1",/' \ 5947105Sbostic /tmp/ka$$ 6047105Sbosticecho '}; 6147105Sbostic' 6247105Sbosticsed 's/"//g' /tmp/ka$$ | awk ' 6347105Sbostic/TIF/{print "#define KWDOFFSET " NR-1; print ""; print "char *const parsekwd[] = {"} 6447105Sbostic/TIF/,/neverfound/{print " \"" $3 "\","}' 6547105Sbosticecho ' 0 6647105Sbostic};' 6747105Sbostic 6847105Sbosticrm /tmp/ka$$ 69