1
0
mirror of https://github.com/golang/go synced 2024-10-05 00:21:21 -06:00
go/src/cmd/gc/go.errors
Russ Cox 2a01d72878 gc: improved syntax errors
* example-based syntax errors (go.errors)

* enable bison's more specific errors
  and translate grammar token names into
  tokens like ++

* test cases

R=ken2, r, ken3
CC=golang-dev
https://golang.org/cl/194085
2010-01-26 23:13:22 -08:00

47 lines
1.5 KiB
Plaintext

// 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.
% loadsys package LIMPORT '(' LLITERAL import_package import_there ','
"unexpected , during import block",
% loadsys package imports LFUNC LNAME '(' ')' '{' LIF if_header ';'
"unexpected ; or newline before {",
% loadsys package imports LFUNC LNAME '(' ')' '{' LSWITCH if_header ';'
"unexpected ; or newline before {",
% loadsys package imports LFUNC LNAME '(' ')' '{' LFOR for_header ';'
"unexpected ; or newline before {",
% loadsys package imports LFUNC LNAME '(' ')' '{' LFOR ';' LBODY
"unexpected ; or newline before {",
% loadsys package imports LFUNC LNAME '(' ')' ';' '{'
"unexpected ; or newline before {",
% loadsys package imports LTYPE LNAME ';'
"unexpected ; or newline in type declaration",
% loadsys package imports LFUNC LNAME '(' ')' '{' if_stmt ';' LELSE
"unexpected ; or newline before else",
% loadsys package imports LTYPE LNAME LINTERFACE '{' LNAME ',' LNAME
"name list not allowed in interface type",
% loadsys package imports LFUNC LNAME '(' ')' '{' LFOR LVAR LNAME '=' LNAME
"var declaration not allowed in for initializer",
};