gc: check in y.tab.[ch], yerr.h, builtin.c.

This enables builds on systems without Bison/yacc.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5622051
This commit is contained in:
Russ Cox 2012-02-03 10:53:31 -05:00
parent c739dd2299
commit d53cdd1775
9 changed files with 5188 additions and 26 deletions

View file

@ -23,7 +23,6 @@ _test
_testmain.go
build.out
test.out
y.tab.[ch]
doc/tmpltohtml
doc/codelab/wiki/*.bin
misc/cgo/life/run.out
@ -35,12 +34,9 @@ src/Make.inc
src/cmd/6a/6a
src/cmd/?l/enam.c
src/cmd/cc/y.output
src/cmd/gc/builtin.c
src/cmd/gc/mkbuiltin1
src/cmd/gc/opnames.h
src/cmd/gc/y.output
src/cmd/gc/y1.tab.c
src/cmd/gc/yerr.h
src/pkg/Make.deps
src/pkg/exp/norm/maketables
src/pkg/exp/norm/maketesttables

View file

@ -22,7 +22,7 @@ $(QUOTED_GOROOT)/lib/$(LIB): $(LIB)
$(LIB): $(OFILES)
$(HOST_AR) rsc $(LIB) $(OFILES)
CLEANFILES+=y.tab.[ch] y.output a.out $(LIB)
CLEANFILES+=a.out $(LIB)
clean:
rm -f *.$(HOST_O) $(CLEANFILES)
@ -30,7 +30,7 @@ clean:
nuke: clean
rm -f "$(GOROOT)/lib/$(LIB)"
y.tab.h: $(YFILES)
y.tab.h%: $(YFILES)
LANG=C LANGUAGE="en_US.UTF8" bison -v -y $(HOST_YFLAGS) $(YFILES)
y.tab.c: y.tab.h

View file

@ -12,9 +12,6 @@ HFILES=\
y.tab.h\
md5.h\
YFILES=\
go.y\
OFILES=\
align.$O\
bits.$O\
@ -44,7 +41,7 @@ OFILES=\
typecheck.$O\
unsafe.$O\
walk.$O\
y1.tab.$O\
y.tab.$O\
HOST_CFLAGS+=-DGOEXPERIMENT='"$(GOEXPERIMENT)"'
@ -53,24 +50,25 @@ include ../../Make.clib
install: $(LIB)
y1.tab.c: y.tab.c # make yystate global, yytname mutable
cat y.tab.c | sed '/ int yystate;/d; s/int yychar;/int yychar, yystate;/; s/static const char \*const yytname/const char *yytname/; s/char const \*yymsgp/char *yymsgp/' >y1.tab.c
yerr.h: bisonerrors go.errors y.tab.h # y.tab.h rule generates y.output too
awk -f bisonerrors y.output go.errors >yerr.h
subr.$O: yerr.h
builtin.c: builtin.c.boot
cp builtin.c.boot builtin.c
fmt.$O: opnames.h
opnames.h: mkopnames go.h
./mkopnames go.h >opnames.h
CLEANFILES+=*.[568] [568].out y1.tab.c yerr.h mkbuiltin1 builtin.c _builtin.c opnames.h
CLEANFILES+=*.[568] [568].out mkbuiltin1 _builtin.c opnames.h
mkbuiltin1: mkbuiltin1.$O
$(HOST_LD) -o $@ mkbuiltin1.$O -L"$(GOROOT)"/lib -lbio -l9 -lm $(HOST_LDFLAGS)
y.tab.h: go.y
bison -v -y -d go.y
# make yystate global, yytname mutable
cat y.tab.c | sed '/ int yystate;/d; s/int yychar;/int yychar, yystate;/; s/static const char \*const yytname/const char *yytname/; s/char const \*yymsgp/char *yymsgp/' >y1.tab.c
mv y1.tab.c y.tab.c
awk -f bisonerrors y.output go.errors >yerr.h
yerr.h: y.tab.h
test -f yerr.h && touch yerr.h

View file

@ -10,22 +10,21 @@
set -e
eval $(gomake --no-print-directory -f ../../Make.inc go-env)
eval $(go tool make --no-print-directory -f ../../Make.inc go-env)
if [ -z "$GC" ]; then
echo 'missing $GC - gomake failed?' 1>&2
exit 1
fi
gomake mkbuiltin1
go tool make mkbuiltin1
rm -f _builtin.c
for i in runtime unsafe
do
$GC -A $i.go
go tool $GC -A $i.go
O=$O ./mkbuiltin1 $i >>_builtin.c
done
# If _builtin.c has changed vs builtin.c.boot,
# check in the new change.
cmp -s _builtin.c builtin.c.boot || cp _builtin.c builtin.c.boot
mv _builtin.c builtin.c
cmp -s _builtin.c builtin.c || cp _builtin.c builtin.c
rm _builtin.c

View file

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
// Compile .go file, import data from .6 file, and generate C string version.
#include <u.h>

4927
src/cmd/gc/y.tab.c Normal file

File diff suppressed because it is too large Load diff

167
src/cmd/gc/y.tab.h Normal file
View file

@ -0,0 +1,167 @@
/* A Bison parser, made by GNU Bison 2.3. */
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
LLITERAL = 258,
LASOP = 259,
LBREAK = 260,
LCASE = 261,
LCHAN = 262,
LCOLAS = 263,
LCONST = 264,
LCONTINUE = 265,
LDDD = 266,
LDEFAULT = 267,
LDEFER = 268,
LELSE = 269,
LFALL = 270,
LFOR = 271,
LFUNC = 272,
LGO = 273,
LGOTO = 274,
LIF = 275,
LIMPORT = 276,
LINTERFACE = 277,
LMAP = 278,
LNAME = 279,
LPACKAGE = 280,
LRANGE = 281,
LRETURN = 282,
LSELECT = 283,
LSTRUCT = 284,
LSWITCH = 285,
LTYPE = 286,
LVAR = 287,
LANDAND = 288,
LANDNOT = 289,
LBODY = 290,
LCOMM = 291,
LDEC = 292,
LEQ = 293,
LGE = 294,
LGT = 295,
LIGNORE = 296,
LINC = 297,
LLE = 298,
LLSH = 299,
LLT = 300,
LNE = 301,
LOROR = 302,
LRSH = 303,
NotPackage = 304,
NotParen = 305,
PreferToRightParen = 306
};
#endif
/* Tokens. */
#define LLITERAL 258
#define LASOP 259
#define LBREAK 260
#define LCASE 261
#define LCHAN 262
#define LCOLAS 263
#define LCONST 264
#define LCONTINUE 265
#define LDDD 266
#define LDEFAULT 267
#define LDEFER 268
#define LELSE 269
#define LFALL 270
#define LFOR 271
#define LFUNC 272
#define LGO 273
#define LGOTO 274
#define LIF 275
#define LIMPORT 276
#define LINTERFACE 277
#define LMAP 278
#define LNAME 279
#define LPACKAGE 280
#define LRANGE 281
#define LRETURN 282
#define LSELECT 283
#define LSTRUCT 284
#define LSWITCH 285
#define LTYPE 286
#define LVAR 287
#define LANDAND 288
#define LANDNOT 289
#define LBODY 290
#define LCOMM 291
#define LDEC 292
#define LEQ 293
#define LGE 294
#define LGT 295
#define LIGNORE 296
#define LINC 297
#define LLE 298
#define LLSH 299
#define LLT 300
#define LNE 301
#define LOROR 302
#define LRSH 303
#define NotPackage 304
#define NotParen 305
#define PreferToRightParen 306
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 28 "go.y"
{
Node* node;
NodeList* list;
Type* type;
Sym* sym;
struct Val val;
int i;
}
/* Line 1529 of yacc.c. */
#line 160 "y.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;

73
src/cmd/gc/yerr.h Normal file
View file

@ -0,0 +1,73 @@
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Example-based syntax error messages.
// See bisonerrors, Makefile, go.y.
static struct {
int yystate;
int yychar;
char *msg;
} yymsg[] = {
// Each line of the form % token list
// is converted by bisonerrors into the yystate and yychar caused
// by that token list.
220, ',',
"unexpected comma during import block",
376, ';',
"unexpected semicolon or newline before {",
397, ';',
"unexpected semicolon or newline before {",
236, ';',
"unexpected semicolon or newline before {",
473, LBODY,
"unexpected semicolon or newline before {",
22, '{',
"unexpected semicolon or newline before {",
143, ';',
"unexpected semicolon or newline in type declaration",
37, '}',
"unexpected } in channel type",
37, ')',
"unexpected ) in channel type",
37, ',',
"unexpected comma in channel type",
436, LELSE,
"unexpected semicolon or newline before else",
256, ',',
"name list not allowed in interface type",
236, LVAR,
"var declaration not allowed in for initializer",
65, '{',
"unexpected { at end of statement",
375, '{',
"unexpected { at end of statement",
124, ';',
"argument to go/defer must be function call",
424, ';',
"need trailing comma before newline in composite literal",
111, LNAME,
"nested func not allowed",
614, ';',
"else must be followed by if or statement block"
};