summaryrefslogtreecommitdiff
path: root/src/cmd/gc/go.errors
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-01-26 23:13:22 -0800
committerRuss Cox <rsc@golang.org>2010-01-26 23:13:22 -0800
commitda0f154cecf72a30fb2412aa018803208e80dde3 (patch)
tree1535ebe4c0e90e048e14683b415f114c7471341a /src/cmd/gc/go.errors
parent2ccb4107adca6819d7765672f49d7de7d2024736 (diff)
downloadgolang-da0f154cecf72a30fb2412aa018803208e80dde3.tar.gz
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 http://codereview.appspot.com/194085
Diffstat (limited to 'src/cmd/gc/go.errors')
-rw-r--r--src/cmd/gc/go.errors46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/cmd/gc/go.errors b/src/cmd/gc/go.errors
new file mode 100644
index 000000000..215f28c5a
--- /dev/null
+++ b/src/cmd/gc/go.errors
@@ -0,0 +1,46 @@
+// 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",
+};