1*47105Sbostic#!/bin/sh - 2*47105Sbostic# 3*47105Sbostic# Copyright (c) 1991 The Regents of the University of California. 4*47105Sbostic# All rights reserved. 5*47105Sbostic# 6*47105Sbostic# This code is derived from software contributed to Berkeley by 7*47105Sbostic# Kenneth Almquist. 8*47105Sbostic# 9*47105Sbostic# %sccs.include.redist.sh% 10*47105Sbostic# 11*47105Sbostic# @(#)mktokens 5.1 (Berkeley) 03/07/91 12*47105Sbostic 13*47105Sbostic# The following is a list of tokens. The second column is nonzero if the 14*47105Sbostic# token marks the end of a list. The third column is the name to print in 15*47105Sbostic# error messages. 16*47105Sbostic 17*47105Sbosticcat > /tmp/ka$$ <<\! 18*47105SbosticTEOF 1 end of file 19*47105SbosticTNL 0 newline 20*47105SbosticTSEMI 0 ";" 21*47105SbosticTBACKGND 0 "&" 22*47105SbosticTAND 0 "&&" 23*47105SbosticTOR 0 "||" 24*47105SbosticTPIPE 0 "|" 25*47105SbosticTLP 0 "(" 26*47105SbosticTRP 1 ")" 27*47105SbosticTENDCASE 1 ";;" 28*47105SbosticTENDBQUOTE 1 "`" 29*47105SbosticTREDIR 0 redirection 30*47105SbosticTWORD 0 word 31*47105SbosticTIF 0 "if" 32*47105SbosticTTHEN 1 "then" 33*47105SbosticTELSE 1 "else" 34*47105SbosticTELIF 1 "elif" 35*47105SbosticTFI 1 "fi" 36*47105SbosticTWHILE 0 "while" 37*47105SbosticTUNTIL 0 "until" 38*47105SbosticTFOR 0 "for" 39*47105SbosticTDO 1 "do" 40*47105SbosticTDONE 1 "done" 41*47105SbosticTBEGIN 0 "{" 42*47105SbosticTEND 1 "}" 43*47105SbosticTCASE 0 "case" 44*47105SbosticTESAC 1 "esac" 45*47105Sbostic! 46*47105Sbosticnl=`wc -l /tmp/ka$$` 47*47105Sbosticexec > token.def 48*47105Sbosticawk '{print "#define " $1 " " NR-1}' /tmp/ka$$ 49*47105Sbosticecho ' 50*47105Sbostic/* Array indicating which tokens mark the end of a list */ 51*47105Sbosticconst char tokendlist[] = {' 52*47105Sbosticawk '{print "\t" $2 ","}' /tmp/ka$$ 53*47105Sbosticecho '}; 54*47105Sbostic 55*47105Sbosticchar *const tokname[] = {' 56*47105Sbosticsed -e 's/"/\\"/g' \ 57*47105Sbostic -e 's/[^ ]*[ ][ ]*[^ ]*[ ][ ]*\(.*\)/ "\1",/' \ 58*47105Sbostic /tmp/ka$$ 59*47105Sbosticecho '}; 60*47105Sbostic' 61*47105Sbosticsed 's/"//g' /tmp/ka$$ | awk ' 62*47105Sbostic/TIF/{print "#define KWDOFFSET " NR-1; print ""; print "char *const parsekwd[] = {"} 63*47105Sbostic/TIF/,/neverfound/{print " \"" $3 "\","}' 64*47105Sbosticecho ' 0 65*47105Sbostic};' 66*47105Sbostic 67*47105Sbosticrm /tmp/ka$$ 68