#!/bin/sh
# yyacc - yacc wrapper
#
# Allows tokens to be written as `literal` and then automatically
# substituted with #defined tokens.
#
# Usage:
# yyacc file.y filetab.h file.yy
#
# inputs:
# file.yy yacc grammar with ` literals
#
# outputs:
# file.y yacc grammar
# filetab.h array of string <-> token mappings
#
# 03-13-93 - Documented and p moved in sed command (for some reason,
# s/x/y/p doesn't work).
# 10-12-93 - Take basename as second argument.
# 12-31-96 - reversed order of args to be compatible with GenFile rule
# 03/19/02 (seiwald) - suffix symbols with _t to avoid conflicts
#
outy=${1?}
outh=${2?}
in=${3?}
out=`basename $in .yy`
T=/tmp/yy$$
trap 'rm -f $T.*' 0
sed '
: 1
/`/{
h
s/[^`]*`\([^`]*\)`.*/\1/
p
g
s/[^`]*`[^`]*`//
b 1
}
d
' $in | sort -u | sed '
h
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
s/:/_COLON/
s/!/_BANG/
s/&&/_AMPERAMPER/
s/&/_AMPER/
s/+/_PLUS/
s/||/_BARBAR/
s/|/_BAR/
s/;/_SEMIC/
s/-/_MINUS/
s/</_LANGLE/
s/>/_RANGLE/
s/\./_PERIOD/
s/?/_QUESTION/
s/=/_EQUALS/
s/,/_COMMA/
s/\[/_LBRACKET/
s/]/_RBRACKET/
s/{/_LBRACE/
s/}/_RBRACE/
s/(/_LPAREN/
s/)/_RPAREN/
s/.*/&_t/
G
s/\n/ /
' > $T.1
sed '
s:^\(.*\) \(.*\)$:s/`\2`/\1/g:
s:\.:\\.:g
s:\[:\\[:g
' $T.1 > $T.s
rm -f $outy $outh
(
sed 's:^\(.*\) \(.*\)$:%token \1:' $T.1
sed -f $T.s $in
) > $outy
(
sed 's:^\(.*\) \(.*\)$: { "\2", \1 },:' $T.1
) > $outh
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #4 | 3183 | Craig Mcpheeters | Integration of my jam mainline branch into my work branch. | ||
| #3 | 1606 | Craig Mcpheeters |
Integration from my modified jam mainline. This is all the mainline changes into my work branch. |
||
| #2 | 785 | Craig Mcpheeters |
Integration from //guest/craig_mcpheeters/jam/src/... This work area now contains both the Alias|Wavefront changes, and the latest integrations from the mainline. There are some changes in this area which shouldn't be merged back into the mainline. As I merge this branch back into my jam/src/... branch, I'll leave out a few of the changes. |
||
| #1 | 777 | Craig Mcpheeters |
Branch of my jam/src/... area. This new area establishes the integration base for the copy of Jam which has all the changes. |
||
| //guest/craig_mcpheeters/jam/src/yyacc | |||||
| #2 | 617 | Craig Mcpheeters | Integration from mainline as of @3 | ||
| #1 | 616 | Craig Mcpheeters | Integration from Jam mainline, as of @2 | ||