mirror of https://github.com/golang/go.git
Significant parser cleanup:
- commented public interface - much better and very precise error messages - much better tracing output - many more checks (still permits more than just syntactically legal programs, but much more is checked that can be checked w/o semantic information) - updated with respect to updated AST - general cleanup throughout Parser almost ready for move into lib/go. R=r OCL=26853 CL=26855
This commit is contained in:
parent
7cba8e6f72
commit
75a5d6cd2d
|
|
@ -97,11 +97,11 @@ func Compile(src_file string, flags *Flags) (*ast.Package, ErrorList) {
|
|||
var scanner scanner.Scanner;
|
||||
scanner.Init(src, &err, true);
|
||||
|
||||
pflags := uint(0);
|
||||
mode := uint(0);
|
||||
if flags.Verbose {
|
||||
pflags |= parser.Trace;
|
||||
mode |= parser.Trace;
|
||||
}
|
||||
prog, nerrs := parser.Parse(&scanner, &err, parser.ParseEntirePackage, pflags);
|
||||
prog, nerrs := parser.Parse(&scanner, &err, mode);
|
||||
|
||||
if err.errors.Len() == 0 {
|
||||
TypeChecker.CheckProgram(&err, prog);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -591,6 +591,15 @@ func (P *Printer) DoBinaryExpr(x *ast.BinaryExpr) {
|
|||
}
|
||||
|
||||
|
||||
func (P *Printer) DoKeyValueExpr(x *ast.KeyValueExpr) {
|
||||
P.Expr(x.Key);
|
||||
P.separator = blank;
|
||||
P.Token(x.Colon, token.COLON);
|
||||
P.separator = blank;
|
||||
P.Expr(x.Value);
|
||||
}
|
||||
|
||||
|
||||
func (P *Printer) DoStarExpr(x *ast.StarExpr) {
|
||||
P.Token(x.Pos(), token.MUL);
|
||||
P.Expr(x.X);
|
||||
|
|
@ -721,9 +730,14 @@ func (P *Printer) DoEllipsis(x *ast.Ellipsis) {
|
|||
|
||||
func (P *Printer) DoArrayType(x *ast.ArrayType) {
|
||||
P.Token(x.Pos(), token.LBRACK);
|
||||
if x.Len != nil {
|
||||
P.Expr(x.Len);
|
||||
}
|
||||
P.Expr(x.Len);
|
||||
P.Token(nopos, token.RBRACK);
|
||||
P.Expr(x.Elt);
|
||||
}
|
||||
|
||||
|
||||
func (P *Printer) DoSliceType(x *ast.SliceType) {
|
||||
P.Token(x.Pos(), token.LBRACK);
|
||||
P.Token(nopos, token.RBRACK);
|
||||
P.Expr(x.Elt);
|
||||
}
|
||||
|
|
@ -751,11 +765,6 @@ func (P *Printer) DoInterfaceType(x *ast.InterfaceType) {
|
|||
}
|
||||
|
||||
|
||||
func (P *Printer) DoSliceType(x *ast.SliceType) {
|
||||
unimplemented();
|
||||
}
|
||||
|
||||
|
||||
func (P *Printer) DoMapType(x *ast.MapType) {
|
||||
P.Token(x.Pos(), token.MAP);
|
||||
P.separator = blank;
|
||||
|
|
|
|||
Loading…
Reference in New Issue