diff --git a/usr/gri/pretty/ast.go b/usr/gri/pretty/ast.go index a890913123e..29d183391ed 100644 --- a/usr/gri/pretty/ast.go +++ b/usr/gri/pretty/ast.go @@ -54,23 +54,23 @@ export func KindStr(kind int) string { export type Object struct { - id int; // unique id + Id int; // unique id - pos int; // source position (< 0 if unknown position) - kind int; // object kind - ident string; - typ *Type; // nil for packages - pnolev int; // >= 0: package no., <= 0: function nesting level, 0: global level + Pos int; // source position (< 0 if unknown position) + Kind int; // object kind + Ident string; + Typ *Type; // nil for packages + Pnolev int; // >= 0: package no., <= 0: function nesting level, 0: global level // attached values - block *array.Array; end int; // stats for function literals; end of block pos + Block *array.Array; End int; // stats for function literals; end of block pos } func (obj *Object) IsExported() bool { - switch obj.kind { + switch obj.Kind { case NONE /* FUNC for now */, CONST, TYPE, VAR, FUNC: - ch, size := utf8.DecodeRuneInString(obj.ident, 0); + ch, size := utf8.DecodeRuneInString(obj.Ident, 0); return unicode.IsUpper(ch); } return false; @@ -78,18 +78,18 @@ func (obj *Object) IsExported() bool { export var Universe_void_typ *Type // initialized by Universe to Universe.void_typ -var ObjectId int; +var objectId int; export func NewObject(pos, kind int, ident string) *Object { obj := new(Object); - obj.id = ObjectId; - ObjectId++; + obj.Id = objectId; + objectId++; - obj.pos = pos; - obj.kind = kind; - obj.ident = ident; - obj.typ = Universe_void_typ; - obj.pnolev = 0; + obj.Pos = pos; + obj.Kind = kind; + obj.Ident = ident; + obj.Typ = Universe_void_typ; + obj.Pnolev = 0; return obj; } @@ -133,23 +133,23 @@ func (scope *Scope) Lookup(ident string) *Object { } -func (scope *Scope) Add(obj* Object) { - scope.entries[obj.ident] = obj; +func (scope *Scope) add(obj* Object) { + scope.entries[obj.Ident] = obj; } func (scope *Scope) Insert(obj *Object) { - if scope.LookupLocal(obj.ident) != nil { + if scope.LookupLocal(obj.Ident) != nil { panic("obj already inserted"); } - scope.Add(obj); + scope.add(obj); } func (scope *Scope) InsertImport(obj *Object) *Object { - p := scope.LookupLocal(obj.ident); + p := scope.LookupLocal(obj.Ident); if p == nil { - scope.Add(obj); + scope.add(obj); p = obj; } return p; @@ -169,8 +169,8 @@ func (scope *Scope) Print() { // All nodes have a source position and and token. export type Node struct { - pos int; // source position (< 0 => unknown position) - tok int; // identifying token + Pos int; // source position (< 0 => unknown position) + Tok int; // identifying token } @@ -179,8 +179,8 @@ export type Node struct { export type Expr struct { Node; - x, y *Expr; // binary (x, y) and unary (y) expressions - obj *Object; + X, Y *Expr; // binary (X, Y) and unary (Y) expressions + Obj *Object; } @@ -189,7 +189,7 @@ func (x *Expr) Len() int { return 0; } n := 1; - for ; x.tok == Scanner.COMMA; x = x.y { + for ; x.Tok == Scanner.COMMA; x = x.Y { n++; } return n; @@ -197,11 +197,11 @@ func (x *Expr) Len() int { export func NewExpr(pos, tok int, x, y *Expr) *Expr { - if x != nil && x.tok == Scanner.TYPE || y != nil && y.tok == Scanner.TYPE { + if x != nil && x.Tok == Scanner.TYPE || y != nil && y.Tok == Scanner.TYPE { panic("no type expression allowed"); } e := new(Expr); - e.pos, e.tok, e.x, e.y = pos, tok, x, y; + e.Pos, e.Tok, e.X, e.Y = pos, tok, x, y; return e; } @@ -209,7 +209,7 @@ export func NewExpr(pos, tok int, x, y *Expr) *Expr { // TODO probably don't need the tok parameter eventually export func NewLit(tok int, obj *Object) *Expr { e := new(Expr); - e.pos, e.tok, e.obj = obj.pos, tok, obj; + e.Pos, e.Tok, e.Obj = obj.Pos, tok, obj; return e; } @@ -296,47 +296,47 @@ export const /* channel mode */ ( export type Type struct { - id int; // unique id + Id int; // unique id - ref int; // for exporting only: >= 0 means already exported - form int; // type form - size int; // size in bytes - obj *Object; // primary type object or NULL - scope *Scope; // forwards, structs, interfaces, functions + Ref int; // for exporting only: >= 0 means already exported + Form int; // type form + Size int; // size in bytes + Obj *Object; // primary type object or NULL + Scope *Scope; // forwards, structs, interfaces, functions // syntactic components - pos int; // source position (< 0 if unknown position) - expr *Expr; // type name, array length - mode int; // channel mode - key *Type; // receiver type or map key - elt *Type; // array, map, channel or pointer element type, function result type - list *array.Array; end int; // struct fields, interface methods, function parameters - scope *Scope; // struct fields, methods + Pos int; // source position (< 0 if unknown position) + Expr *Expr; // type name, array length + Mode int; // channel mode + Key *Type; // receiver type or map key + Elt *Type; // array, map, channel or pointer element type, function result type + List *array.Array; End int; // struct fields, interface methods, function parameters + Scope *Scope; // struct fields, methods } -var TypeId int; +var typeId int; export func NewType(pos, form int) *Type { typ := new(Type); - typ.id = TypeId; - TypeId++; + typ.Id = typeId; + typeId++; - typ.ref = -1; // not yet exported - typ.pos = pos; - typ.form = form; + typ.Ref = -1; // not yet exported + typ.Pos = pos; + typ.Form = form; return typ; } -func (t *Type) nfields() int { - if t.list == nil { +func (t *Type) Nfields() int { + if t.List == nil { return 0; } nx, nt := 0, 0; - for i, n := 0, t.list.Len(); i < n; i++ { - if t.list.At(i).(*Expr).tok == Scanner.TYPE { + for i, n := 0, t.List.Len(); i < n; i++ { + if t.List.At(i).(*Expr).Tok == Scanner.TYPE { nt++; } else { nx++; @@ -349,10 +349,10 @@ func (t *Type) nfields() int { } -// requires complete Type.pos access +// requires complete Type.Pos access export func NewTypeExpr(typ *Type) *Expr { - obj := NewObject(typ.pos, TYPE, ""); - obj.typ = typ; + obj := NewObject(typ.Pos, TYPE, ""); + obj.Typ = typ; return NewLit(Scanner.TYPE, obj); } @@ -365,16 +365,16 @@ export var BadType = NewType(0, Scanner.ILLEGAL); export type Stat struct { Node; - init, post *Stat; - expr *Expr; - block *array.Array; end int; // block end position - decl *Decl; + Init, Post *Stat; + Expr *Expr; + Block *array.Array; End int; // block end position + Decl *Decl; } export func NewStat(pos, tok int) *Stat { s := new(Stat); - s.pos, s.tok = pos, tok; + s.Pos, s.Tok = pos, tok; return s; } @@ -387,19 +387,19 @@ export var BadStat = NewStat(0, Scanner.ILLEGAL); export type Decl struct { Node; - exported bool; - ident *Expr; // nil for ()-style declarations - typ *Type; - val *Expr; + Exported bool; + Ident *Expr; // nil for ()-style declarations + Typ *Type; + Val *Expr; // list of *Decl for ()-style declarations // list of *Stat for func declarations (or nil for forward decl) - list *array.Array; end int; + List *array.Array; End int; } export func NewDecl(pos, tok int, exported bool) *Decl { d := new(Decl); - d.pos, d.tok, d.exported = pos, tok, exported; + d.Pos, d.Tok, d.Exported = pos, tok, exported; return d; } @@ -411,28 +411,28 @@ export var BadDecl = NewDecl(0, Scanner.ILLEGAL, false); // Program export type Comment struct { - pos int; - text string; + Pos int; + Text string; } export func NewComment(pos int, text string) *Comment { c := new(Comment); - c.pos, c.text = pos, text; + c.Pos, c.Text = pos, text; return c; } export type Program struct { - pos int; // tok is Scanner.PACKAGE - ident *Expr; - decls *array.Array; - comments *array.Array; + Pos int; // tok is Scanner.PACKAGE + Ident *Expr; + Decls *array.Array; + Comments *array.Array; } export func NewProgram(pos int) *Program { p := new(Program); - p.pos = pos; + p.Pos = pos; return p; } diff --git a/usr/gri/pretty/compilation.go b/usr/gri/pretty/compilation.go index 7e4811f404e..6e78e8f7ec5 100644 --- a/usr/gri/pretty/compilation.go +++ b/usr/gri/pretty/compilation.go @@ -34,7 +34,7 @@ export type Flags struct { } -type ErrorHandler struct { +type errorHandler struct { filename string; src string; nerrors int; @@ -44,7 +44,7 @@ type ErrorHandler struct { } -func (h *ErrorHandler) Init(filename, src string, columns bool) { +func (h *errorHandler) Init(filename, src string, columns bool) { h.filename = filename; h.src = src; h.nerrors = 0; @@ -55,7 +55,7 @@ func (h *ErrorHandler) Init(filename, src string, columns bool) { // Compute (line, column) information for a given source position. -func (h *ErrorHandler) LineCol(pos int) (line, col int) { +func (h *errorHandler) LineCol(pos int) (line, col int) { line = 1; lpos := 0; @@ -75,7 +75,7 @@ func (h *ErrorHandler) LineCol(pos int) (line, col int) { } -func (h *ErrorHandler) ErrorMsg(pos int, msg string) { +func (h *errorHandler) ErrorMsg(pos int, msg string) { print(h.filename, ":"); if pos >= 0 { // print position @@ -97,7 +97,7 @@ func (h *ErrorHandler) ErrorMsg(pos int, msg string) { } -func (h *ErrorHandler) Error(pos int, msg string) { +func (h *errorHandler) Error(pos int, msg string) { // only report errors that are sufficiently far away from the previous error // in the hope to avoid most follow-up errors const errdist = 20; @@ -112,7 +112,7 @@ func (h *ErrorHandler) Error(pos int, msg string) { } -func (h *ErrorHandler) Warning(pos int, msg string) { +func (h *errorHandler) Warning(pos int, msg string) { panic("UNIMPLEMENTED"); } @@ -124,7 +124,7 @@ export func Compile(src_file string, flags *Flags) (*AST.Program, int) { return nil, 1; } - var err ErrorHandler; + var err errorHandler; err.Init(src_file, src, flags.columns); var scanner Scanner.Scanner; @@ -148,7 +148,7 @@ export func Compile(src_file string, flags *Flags) (*AST.Program, int) { } -func FileExists(name string) bool { +func fileExists(name string) bool { fd, err := OS.Open(name, OS.O_RDONLY, 0); if err == nil { fd.Close(); @@ -158,7 +158,7 @@ func FileExists(name string) bool { } -func AddDeps(globalset map [string] bool, wset *array.Array, src_file string, flags *Flags) { +func addDeps(globalset map [string] bool, wset *array.Array, src_file string, flags *Flags) { dummy, found := globalset[src_file]; if !found { globalset[src_file] = true; @@ -168,27 +168,27 @@ func AddDeps(globalset map [string] bool, wset *array.Array, src_file string, fl return; } - nimports := prog.decls.Len(); + nimports := prog.Decls.Len(); if nimports > 0 { print(src_file, ".6:\t"); localset := make(map [string] bool); for i := 0; i < nimports; i++ { - decl := prog.decls.At(i).(*AST.Decl); - assert(decl.tok == Scanner.IMPORT && decl.val.tok == Scanner.STRING); - src := decl.val.obj.ident; + decl := prog.Decls.At(i).(*AST.Decl); + assert(decl.Tok == Scanner.IMPORT && decl.Val.Tok == Scanner.STRING); + src := decl.Val.Obj.Ident; src = src[1 : len(src) - 1]; // strip "'s // ignore files when they are seen a 2nd time dummy, found := localset[src]; if !found { localset[src] = true; - if FileExists(src + ".go") { + if fileExists(src + ".go") { wset.Push(src); print(" ", src, ".6"); } else if - FileExists(Platform.GOROOT + "/pkg/" + src + ".6") || - FileExists(Platform.GOROOT + "/pkg/" + src + ".a") { + fileExists(Platform.GOROOT + "/pkg/" + src + ".6") || + fileExists(Platform.GOROOT + "/pkg/" + src + ".a") { } else { // TODO should collect these and print later @@ -207,6 +207,6 @@ export func ComputeDeps(src_file string, flags *Flags) { wset := array.New(0); wset.Push(src_file); for wset.Len() > 0 { - AddDeps(globalset, wset, wset.Pop().(string), flags); + addDeps(globalset, wset, wset.Pop().(string), flags); } } diff --git a/usr/gri/pretty/parser.go b/usr/gri/pretty/parser.go index fe759e1c202..1f975682e0c 100644 --- a/usr/gri/pretty/parser.go +++ b/usr/gri/pretty/parser.go @@ -91,7 +91,7 @@ func (P *Parser) Next0() { P.pos, P.tok, P.val = P.scanner.Scan(); } else { t := <-P.tokchan; - P.tok, P.pos, P.val = t.tok, t.pos, t.val; + P.tok, P.pos, P.val = t.Tok, t.Pos, t.Val; } P.opt_semi = false; @@ -168,13 +168,13 @@ func (P *Parser) DeclareInScope(scope *AST.Scope, x *AST.Expr, kind int) { if P.scope_lev < 0 { panic("cannot declare objects in other packages"); } - if x.tok != Scanner.ILLEGAL { // ignore bad exprs - obj := x.obj; - assert(x.tok == Scanner.IDENT && obj.kind == AST.NONE); - obj.kind = kind; - obj.pnolev = P.scope_lev; - if scope.LookupLocal(obj.ident) != nil { - P.Error(obj.pos, `"` + obj.ident + `" is declared already`); + if x.Tok != Scanner.ILLEGAL { // ignore bad exprs + obj := x.Obj; + assert(x.Tok == Scanner.IDENT && obj.Kind == AST.NONE); + obj.Kind = kind; + obj.Pnolev = P.scope_lev; + if scope.LookupLocal(obj.Ident) != nil { + P.Error(obj.Pos, `"` + obj.Ident + `" is declared already`); return; // don't insert it into the scope } scope.Insert(obj); @@ -184,23 +184,23 @@ func (P *Parser) DeclareInScope(scope *AST.Scope, x *AST.Expr, kind int) { // Declare a comma-separated list of idents or a single ident. func (P *Parser) Declare(p *AST.Expr, kind int) { - for p.tok == Scanner.COMMA { - P.DeclareInScope(P.top_scope, p.x, kind); - p = p.y; + for p.Tok == Scanner.COMMA { + P.DeclareInScope(P.top_scope, p.X, kind); + p = p.Y; } P.DeclareInScope(P.top_scope, p, kind); } func (P *Parser) VerifyExport1(p *AST.Expr, exported bool) { - obj := p.obj; + obj := p.Obj; if exported { if !obj.IsExported() { - P.Error(obj.pos, `"` + obj.ident + `" should be uppercase`); + P.Error(obj.Pos, `"` + obj.Ident + `" should be uppercase`); } } else if P.scope_lev == 0 { if obj.IsExported() { - P.Error(obj.pos, `"` + obj.ident + `" should be lowercase`); + P.Error(obj.Pos, `"` + obj.Ident + `" should be lowercase`); } } } @@ -210,9 +210,9 @@ func (P *Parser) VerifyExport(p *AST.Expr, exported bool) { if !P.naming { return; } - for p.tok == Scanner.COMMA { - P.VerifyExport1(p.x, exported); - p = p.y; + for p.Tok == Scanner.COMMA { + P.VerifyExport1(p.X, exported); + p = p.Y; } P.VerifyExport1(p, exported); } @@ -222,27 +222,27 @@ func (P *Parser) VerifyExport(p *AST.Expr, exported bool) { // ---------------------------------------------------------------------------- // AST support -func ExprType(x *AST.Expr) *AST.Type { +func exprType(x *AST.Expr) *AST.Type { var t *AST.Type; - if x.tok == Scanner.TYPE { - t = x.obj.typ; - } else if x.tok == Scanner.IDENT { + if x.Tok == Scanner.TYPE { + t = x.Obj.Typ; + } else if x.Tok == Scanner.IDENT { // assume a type name - t = AST.NewType(x.pos, AST.TYPENAME); - t.expr = x; - } else if x.tok == Scanner.PERIOD && x.y != nil && ExprType(x.x) != nil { + t = AST.NewType(x.Pos, AST.TYPENAME); + t.Expr = x; + } else if x.Tok == Scanner.PERIOD && x.Y != nil && exprType(x.X) != nil { // possibly a qualified (type) identifier - t = AST.NewType(x.pos, AST.TYPENAME); - t.expr = x; + t = AST.NewType(x.Pos, AST.TYPENAME); + t.Expr = x; } return t; } func (P *Parser) NoType(x *AST.Expr) *AST.Expr { - if x != nil && x.tok == Scanner.TYPE { - P.Error(x.pos, "expected expression, found type"); - val := AST.NewObject(x.pos, AST.NONE, "0"); + if x != nil && x.Tok == Scanner.TYPE { + P.Error(x.Pos, "expected expression, found type"); + val := AST.NewObject(x.Pos, AST.NONE, "0"); x = AST.NewLit(Scanner.INT, val); } return x; @@ -276,10 +276,10 @@ func (P *Parser) ParseIdent(scope *AST.Scope) *AST.Expr { if obj == nil { obj = AST.NewObject(P.pos, AST.NONE, P.val); } else { - assert(obj.kind != AST.NONE); + assert(obj.Kind != AST.NONE); } x = AST.NewLit(Scanner.IDENT, obj); - x.pos = P.pos; // override obj.pos (incorrect if object was looked up!) + x.Pos = P.pos; // override obj.pos (incorrect if object was looked up!) if P.verbose { P.PrintIndent(); print("Ident = \"", P.val, "\"\n"); @@ -307,8 +307,8 @@ func (P *Parser) ParseIdentList() *AST.Expr { x = P.NewExpr(pos, Scanner.COMMA, x, y); last = x; } else { - last.y = P.NewExpr(pos, Scanner.COMMA, last.y, y); - last = last.y; + last.Y = P.NewExpr(pos, Scanner.COMMA, last.Y, y); + last = last.Y; } } @@ -364,7 +364,7 @@ func (P *Parser) ParseTypeName() *AST.Type { P.Trace("TypeName"); t := AST.NewType(P.pos, AST.TYPENAME); - t.expr = P.ParseQualifiedIdent(); + t.Expr = P.ParseQualifiedIdent(); P.Ecart(); return t; @@ -377,13 +377,13 @@ func (P *Parser) ParseArrayType() *AST.Type { t := AST.NewType(P.pos, AST.ARRAY); P.Expect(Scanner.LBRACK); if P.tok == Scanner.ELLIPSIS { - t.expr = P.NewExpr(P.pos, Scanner.ELLIPSIS, nil, nil); + t.Expr = P.NewExpr(P.pos, Scanner.ELLIPSIS, nil, nil); P.Next(); } else if P.tok != Scanner.RBRACK { - t.expr = P.ParseExpression(1); + t.Expr = P.ParseExpression(1); } P.Expect(Scanner.RBRACK); - t.elt = P.ParseType(); + t.Elt = P.ParseType(); P.Ecart(); return t; @@ -394,19 +394,19 @@ func (P *Parser) ParseChannelType() *AST.Type { P.Trace("ChannelType"); t := AST.NewType(P.pos, AST.CHANNEL); - t.mode = AST.FULL; + t.Mode = AST.FULL; if P.tok == Scanner.CHAN { P.Next(); if P.tok == Scanner.ARROW { P.Next(); - t.mode = AST.SEND; + t.Mode = AST.SEND; } } else { P.Expect(Scanner.ARROW); P.Expect(Scanner.CHAN); - t.mode = AST.RECV; + t.Mode = AST.RECV; } - t.elt = P.ParseVarType(); + t.Elt = P.ParseVarType(); P.Ecart(); return t; @@ -417,8 +417,8 @@ func (P *Parser) ParseVar(expect_ident bool) *AST.Type { t := AST.BadType; if expect_ident { x := P.ParseIdent(nil); - t = AST.NewType(x.pos, AST.TYPENAME); - t.expr = x; + t = AST.NewType(x.Pos, AST.TYPENAME); + t.Expr = x; } else if P.tok == Scanner.ELLIPSIS { t = AST.NewType(P.pos, AST.ELLIPSIS); P.Next(); @@ -463,11 +463,11 @@ func (P *Parser) ParseVarList(list *array.Array, ellipsis_ok bool) { // convert the type entries into identifiers for i, n := i0, list.Len(); i < n; i++ { t := list.At(i).(*AST.Type); - if t.form == AST.TYPENAME && t.expr.tok == Scanner.IDENT { - list.Set(i, t.expr); + if t.Form == AST.TYPENAME && t.Expr.Tok == Scanner.IDENT { + list.Set(i, t.Expr); } else { list.Set(i, AST.BadExpr); - P.Error(t.pos, "identifier expected"); + P.Error(t.Pos, "identifier expected"); } } // add type @@ -507,9 +507,9 @@ func (P *Parser) ParseParameters(ellipsis_ok bool) *AST.Type { t := AST.NewType(P.pos, AST.STRUCT); P.Expect(Scanner.LPAREN); if P.tok != Scanner.RPAREN { - t.list = P.ParseParameterList(ellipsis_ok); + t.List = P.ParseParameterList(ellipsis_ok); } - t.end = P.pos; + t.End = P.pos; P.Expect(Scanner.RPAREN); P.Ecart(); @@ -543,9 +543,9 @@ func (P *Parser) ParseResult() *AST.Type { typ := P.TryType(); if typ != nil { t = AST.NewType(P.pos, AST.STRUCT); - t.list = array.New(0); - t.list.Push(AST.NewTypeExpr(typ)); - t.end = P.pos; + t.List = array.New(0); + t.List.Push(AST.NewTypeExpr(typ)); + t.End = P.pos; } } @@ -567,9 +567,9 @@ func (P *Parser) ParseFunctionType() *AST.Type { P.scope_lev++; t := AST.NewType(P.pos, AST.FUNCTION); - t.list = P.ParseParameters(true).list; // TODO find better solution - t.end = P.pos; - t.elt = P.ParseResult(); + t.List = P.ParseParameters(true).List; // TODO find better solution + t.End = P.pos; + t.Elt = P.ParseResult(); P.scope_lev--; P.CloseScope(); @@ -605,14 +605,14 @@ func (P *Parser) ParseInterfaceType() *AST.Type { P.OpenScope(); P.scope_lev++; - t.list = array.New(0); + t.List = array.New(0); for P.tok == Scanner.IDENT { - P.ParseMethodSpec(t.list); + P.ParseMethodSpec(t.List); if P.tok != Scanner.RBRACE { P.Expect(Scanner.SEMICOLON); } } - t.end = P.pos; + t.End = P.pos; P.scope_lev--; P.CloseScope(); @@ -630,9 +630,9 @@ func (P *Parser) ParseMapType() *AST.Type { t := AST.NewType(P.pos, AST.MAP); P.Expect(Scanner.MAP); P.Expect(Scanner.LBRACK); - t.key = P.ParseVarType(); + t.Key = P.ParseVarType(); P.Expect(Scanner.RBRACK); - t.elt = P.ParseVarType(); + t.Elt = P.ParseVarType(); P.Ecart(); return t; @@ -651,12 +651,12 @@ func (P *Parser) ParseStructType() *AST.Type { P.OpenScope(); P.scope_lev++; - t.list = array.New(0); + t.List = array.New(0); for P.tok != Scanner.RBRACE && P.tok != Scanner.EOF { - P.ParseVarList(t.list, false); + P.ParseVarList(t.List, false); if P.tok == Scanner.STRING { // ParseOperand takes care of string concatenation - t.list.Push(P.ParseOperand()); + t.List.Push(P.ParseOperand()); } if P.tok == Scanner.SEMICOLON { P.Next(); @@ -665,7 +665,7 @@ func (P *Parser) ParseStructType() *AST.Type { } } P.OptSemicolon(); - t.end = P.pos; + t.End = P.pos; P.scope_lev--; P.CloseScope(); @@ -682,7 +682,7 @@ func (P *Parser) ParsePointerType() *AST.Type { t := AST.NewType(P.pos, AST.POINTER); P.Expect(Scanner.MUL); - t.elt = P.ParseType(); + t.Elt = P.ParseType(); P.Ecart(); return t; @@ -775,7 +775,7 @@ func (P *Parser) ParseExpressionList() *AST.Expr { x = P.NewExpr(pos, Scanner.COMMA, x, y); first = false; } else { - x.y = P.NewExpr(pos, Scanner.COMMA, x.y, y); + x.Y = P.NewExpr(pos, Scanner.COMMA, x.Y, y); } } @@ -790,10 +790,10 @@ func (P *Parser) ParseFunctionLit() *AST.Expr { val := AST.NewObject(P.pos, AST.NONE, ""); x := AST.NewLit(Scanner.FUNC, val); P.Expect(Scanner.FUNC); - val.typ = P.ParseFunctionType(); + val.Typ = P.ParseFunctionType(); P.expr_lev++; P.scope_lev++; - val.block, val.end = P.ParseBlock(); + val.Block, val.End = P.ParseBlock(); P.scope_lev--; P.expr_lev--; @@ -813,7 +813,7 @@ func (P *Parser) ParseNewCall() *AST.Expr { x.t = P.ParseType(); if P.tok == Scanner.COMMA { P.Next(); - x.y = P.ParseExpressionList(); + x.Y = P.ParseExpressionList(); } P.expr_lev--; P.Expect(Scanner.RPAREN); @@ -845,11 +845,11 @@ func (P *Parser) ParseOperand() *AST.Expr { val := AST.NewObject(P.pos, AST.NONE, P.val); x = AST.NewLit(P.tok, val); P.Next(); - if x.tok == Scanner.STRING { + if x.Tok == Scanner.STRING { // TODO should remember the list instead of // concatenate the strings here for ; P.tok == Scanner.STRING; P.Next() { - x.obj.ident += P.val; + x.Obj.Ident += P.val; } } @@ -878,11 +878,11 @@ func (P *Parser) ParseSelectorOrTypeGuard(x *AST.Expr) *AST.Expr { P.Expect(Scanner.PERIOD); if P.tok == Scanner.IDENT { - x.y = P.ParseIdent(nil); + x.Y = P.ParseIdent(nil); } else { P.Expect(Scanner.LPAREN); - x.y = AST.NewTypeExpr(P.ParseType()); + x.Y = AST.NewTypeExpr(P.ParseType()); P.Expect(Scanner.RPAREN); } @@ -916,25 +916,25 @@ func (P *Parser) ParseCall(x0 *AST.Expr) *AST.Expr { if P.tok != Scanner.RPAREN { P.expr_lev++; var t *AST.Type; - if x0.tok == Scanner.IDENT && (x0.obj.ident == "new" || x0.obj.ident == "make") { + if x0.Tok == Scanner.IDENT && (x0.Obj.Ident == "new" || x0.Obj.Ident == "make") { // heuristic: assume it's a new(T) or make(T, ...) call, try to parse a type t = P.TryType(); } if t != nil { // we found a type - x.y = AST.NewTypeExpr(t); + x.Y = AST.NewTypeExpr(t); if P.tok == Scanner.COMMA { pos := P.pos; P.Next(); y := P.ParseExpressionList(); // create list manually because NewExpr checks for type expressions z := AST.NewExpr(pos, Scanner.COMMA, nil, y); - z.x = x.y; - x.y = z; + z.X = x.Y; + x.Y = z; } } else { // normal argument list - x.y = P.ParseExpressionList(); + x.Y = P.ParseExpressionList(); } P.expr_lev--; } @@ -953,7 +953,7 @@ func (P *Parser) ParseCompositeElements() *AST.Expr { // first element determines mode singles := true; - if x.tok == Scanner.COLON { + if x.Tok == Scanner.COLON { singles = false; } @@ -962,12 +962,12 @@ func (P *Parser) ParseCompositeElements() *AST.Expr { y := P.ParseExpression(0); if singles { - if y.tok == Scanner.COLON { - P.Error(y.x.pos, "single value expected; found pair"); + if y.Tok == Scanner.COLON { + P.Error(y.X.Pos, "single value expected; found pair"); } } else { - if y.tok != Scanner.COLON { - P.Error(y.pos, "key:value pair expected; found single value"); + if y.Tok != Scanner.COLON { + P.Error(y.Pos, "key:value pair expected; found single value"); } } @@ -975,8 +975,8 @@ func (P *Parser) ParseCompositeElements() *AST.Expr { x = P.NewExpr(pos, Scanner.COMMA, x, y); last = x; } else { - last.y = P.NewExpr(pos, Scanner.COMMA, last.y, y); - last = last.y; + last.Y = P.NewExpr(pos, Scanner.COMMA, last.Y, y); + last = last.Y; } if P.tok == Scanner.COMMA { @@ -996,11 +996,11 @@ func (P *Parser) ParseCompositeLit(t *AST.Type) *AST.Expr { P.Trace("CompositeLit"); x := P.NewExpr(P.pos, Scanner.LBRACE, nil, nil); - x.obj = AST.NewObject(t.pos, AST.TYPE, ""); - x.obj.typ = t; + x.Obj = AST.NewObject(t.Pos, AST.TYPE, ""); + x.Obj.Typ = t; P.Expect(Scanner.LBRACE); if P.tok != Scanner.RBRACE { - x.y = P.ParseCompositeElements(); + x.Y = P.ParseCompositeElements(); } P.Expect(Scanner.RBRACE); @@ -1024,7 +1024,7 @@ func (P *Parser) ParsePrimaryExpr() *AST.Expr { // (composites inside control clauses must be parenthesized) var t *AST.Type; if P.expr_lev >= 0 { - t = ExprType(x); + t = exprType(x); } if t != nil { x = P.ParseCompositeLit(t); @@ -1050,10 +1050,10 @@ func (P *Parser) ParseUnaryExpr() *AST.Expr { pos, tok := P.pos, P.tok; P.Next(); y := P.ParseUnaryExpr(); - if tok == Scanner.MUL && y.tok == Scanner.TYPE { + if tok == Scanner.MUL && y.Tok == Scanner.TYPE { // pointer type t := AST.NewType(pos, AST.POINTER); - t.elt = y.obj.typ; + t.Elt = y.Obj.Typ; x = AST.NewTypeExpr(t); } else { x = P.NewExpr(pos, tok, nil, y); @@ -1129,9 +1129,9 @@ func (P *Parser) ParseSimpleStat(range_ok bool) *AST.Stat { case Scanner.COLON: // label declaration s = AST.NewStat(P.pos, Scanner.COLON); - s.expr = x; + s.Expr = x; if x.Len() != 1 { - P.Error(x.pos, "illegal label declaration"); + P.Error(x.Pos, "illegal label declaration"); } P.Next(); // consume ":" P.opt_semi = true; @@ -1156,22 +1156,22 @@ func (P *Parser) ParseSimpleStat(range_ok bool) *AST.Stat { } else { y = P.ParseExpressionList(); if is_range { - P.Error(y.pos, "expected 'range', found expression"); + P.Error(y.Pos, "expected 'range', found expression"); } if xl, yl := x.Len(), y.Len(); xl > 1 && yl > 1 && xl != yl { - P.Error(x.pos, "arity of lhs doesn't match rhs"); + P.Error(x.Pos, "arity of lhs doesn't match rhs"); } } - s = AST.NewStat(x.pos, Scanner.EXPRSTAT); - s.expr = AST.NewExpr(pos, tok, x, y); + s = AST.NewStat(x.Pos, Scanner.EXPRSTAT); + s.Expr = AST.NewExpr(pos, tok, x, y); case Scanner.RANGE: pos := P.pos; P.Next(); y := P.ParseExpression(1); y = P.NewExpr(pos, Scanner.RANGE, nil, y); - s = AST.NewStat(x.pos, Scanner.EXPRSTAT); - s.expr = AST.NewExpr(pos, Scanner.DEFINE, x, y); + s = AST.NewStat(x.Pos, Scanner.EXPRSTAT); + s.Expr = AST.NewExpr(pos, Scanner.DEFINE, x, y); default: var pos, tok int; @@ -1179,12 +1179,12 @@ func (P *Parser) ParseSimpleStat(range_ok bool) *AST.Stat { pos, tok = P.pos, P.tok; P.Next(); } else { - pos, tok = x.pos, Scanner.EXPRSTAT; + pos, tok = x.Pos, Scanner.EXPRSTAT; } s = AST.NewStat(pos, tok); - s.expr = x; + s.Expr = x; if x.Len() != 1 { - P.Error(x.pos, "only one expression allowed"); + P.Error(x.Pos, "only one expression allowed"); } } @@ -1198,7 +1198,7 @@ func (P *Parser) ParseGoStat() *AST.Stat { s := AST.NewStat(P.pos, Scanner.GO); P.Expect(Scanner.GO); - s.expr = P.ParseExpression(1); + s.Expr = P.ParseExpression(1); P.Ecart(); return s; @@ -1211,7 +1211,7 @@ func (P *Parser) ParseReturnStat() *AST.Stat { s := AST.NewStat(P.pos, Scanner.RETURN); P.Expect(Scanner.RETURN); if P.tok != Scanner.SEMICOLON && P.tok != Scanner.RBRACE { - s.expr = P.ParseExpressionList(); + s.Expr = P.ParseExpressionList(); } P.Ecart(); @@ -1225,7 +1225,7 @@ func (P *Parser) ParseControlFlowStat(tok int) *AST.Stat { s := AST.NewStat(P.pos, tok); P.Expect(tok); if tok != Scanner.FALLTHROUGH && P.tok == Scanner.IDENT { - s.expr = P.ParseIdent(P.top_scope); + s.Expr = P.ParseIdent(P.top_scope); } P.Ecart(); @@ -1242,23 +1242,23 @@ func (P *Parser) ParseControlClause(keyword int) *AST.Stat { prev_lev := P.expr_lev; P.expr_lev = -1; if P.tok != Scanner.SEMICOLON { - s.init = P.ParseSimpleStat(keyword == Scanner.FOR); + s.Init = P.ParseSimpleStat(keyword == Scanner.FOR); // TODO check for range clause and exit if found } if P.tok == Scanner.SEMICOLON { P.Next(); if P.tok != Scanner.SEMICOLON && P.tok != Scanner.LBRACE { - s.expr = P.ParseExpression(1); + s.Expr = P.ParseExpression(1); } if keyword == Scanner.FOR { P.Expect(Scanner.SEMICOLON); if P.tok != Scanner.LBRACE { - s.post = P.ParseSimpleStat(false); + s.Post = P.ParseSimpleStat(false); } } } else { - if s.init != nil { // guard in case of errors - s.expr, s.init = s.init.expr, nil; + if s.Init != nil { // guard in case of errors + s.Expr, s.Init = s.Init.Expr, nil; } } P.expr_lev = prev_lev; @@ -1274,7 +1274,7 @@ func (P *Parser) ParseIfStat() *AST.Stat { P.OpenScope(); s := P.ParseControlClause(Scanner.IF); - s.block, s.end = P.ParseBlock(); + s.Block, s.End = P.ParseBlock(); if P.tok == Scanner.ELSE { P.Next(); s1 := AST.BadStat; @@ -1284,20 +1284,20 @@ func (P *Parser) ParseIfStat() *AST.Stat { s1 = P.ParseStatement(); if s1 != nil { // not the empty statement - if s1.tok != Scanner.LBRACE { + if s1.Tok != Scanner.LBRACE { // wrap in a block if we don't have one b := AST.NewStat(P.pos, Scanner.LBRACE); - b.block = array.New(0); - b.block.Push(s1); + b.Block = array.New(0); + b.Block.Push(s1); s1 = b; } - s.post = s1; + s.Post = s1; } } else { s1 = AST.NewStat(P.pos, Scanner.LBRACE); - s1.block, s1.end = P.ParseBlock(); + s1.Block, s1.End = P.ParseBlock(); } - s.post = s1; + s.Post = s1; } P.CloseScope(); @@ -1311,7 +1311,7 @@ func (P *Parser) ParseForStat() *AST.Stat { P.OpenScope(); s := P.ParseControlClause(Scanner.FOR); - s.block, s.end = P.ParseBlock(); + s.Block, s.End = P.ParseBlock(); P.CloseScope(); P.Ecart(); @@ -1325,7 +1325,7 @@ func (P *Parser) ParseCase() *AST.Stat { s := AST.NewStat(P.pos, P.tok); if P.tok == Scanner.CASE { P.Next(); - s.expr = P.ParseExpressionList(); + s.Expr = P.ParseExpressionList(); } else { P.Expect(Scanner.DEFAULT); } @@ -1341,7 +1341,7 @@ func (P *Parser) ParseCaseClause() *AST.Stat { s := P.ParseCase(); if P.tok != Scanner.CASE && P.tok != Scanner.DEFAULT && P.tok != Scanner.RBRACE { - s.block = P.ParseStatementList(); + s.Block = P.ParseStatementList(); } P.Ecart(); @@ -1354,12 +1354,12 @@ func (P *Parser) ParseSwitchStat() *AST.Stat { P.OpenScope(); s := P.ParseControlClause(Scanner.SWITCH); - s.block = array.New(0); + s.Block = array.New(0); P.Expect(Scanner.LBRACE); for P.tok != Scanner.RBRACE && P.tok != Scanner.EOF { - s.block.Push(P.ParseCaseClause()); + s.Block.Push(P.ParseCaseClause()); } - s.end = P.pos; + s.End = P.pos; P.Expect(Scanner.RBRACE); P.opt_semi = true; P.CloseScope(); @@ -1386,7 +1386,7 @@ func (P *Parser) ParseCommCase() *AST.Stat { P.Expect(Scanner.ARROW); // use Expect() error handling } } - s.expr = x; + s.Expr = x; } else { P.Expect(Scanner.DEFAULT); } @@ -1402,7 +1402,7 @@ func (P *Parser) ParseCommClause() *AST.Stat { s := P.ParseCommCase(); if P.tok != Scanner.CASE && P.tok != Scanner.DEFAULT && P.tok != Scanner.RBRACE { - s.block = P.ParseStatementList(); + s.Block = P.ParseStatementList(); } P.Ecart(); @@ -1414,11 +1414,11 @@ func (P *Parser) ParseSelectStat() *AST.Stat { P.Trace("SelectStat"); s := AST.NewStat(P.pos, Scanner.SELECT); - s.block = array.New(0); + s.Block = array.New(0); P.Expect(Scanner.SELECT); P.Expect(Scanner.LBRACE); for P.tok != Scanner.RBRACE && P.tok != Scanner.EOF { - s.block.Push(P.ParseCommClause()); + s.Block.Push(P.ParseCommClause()); } P.Expect(Scanner.RBRACE); P.opt_semi = true; @@ -1435,8 +1435,8 @@ func (P *Parser) ParseRangeStat() *AST.Stat { P.Expect(Scanner.RANGE); P.ParseIdentList(); P.Expect(Scanner.DEFINE); - s.expr = P.ParseExpression(1); - s.block, s.end = P.ParseBlock(); + s.Expr = P.ParseExpression(1); + s.Block, s.End = P.ParseBlock(); P.Ecart(); return s; @@ -1451,7 +1451,7 @@ func (P *Parser) ParseStatement() *AST.Stat { switch P.tok { case Scanner.CONST, Scanner.TYPE, Scanner.VAR: s = AST.NewStat(P.pos, P.tok); - s.decl = P.ParseDeclaration(); + s.Decl = P.ParseDeclaration(); case Scanner.FUNC: // for now we do not allow local function declarations, // instead we assume this starts a function literal @@ -1470,7 +1470,7 @@ func (P *Parser) ParseStatement() *AST.Stat { s = P.ParseControlFlowStat(P.tok); case Scanner.LBRACE: s = AST.NewStat(P.pos, Scanner.LBRACE); - s.block, s.end = P.ParseBlock(); + s.Block, s.End = P.ParseBlock(); case Scanner.IF: s = P.ParseIfStat(); case Scanner.FOR: @@ -1505,20 +1505,20 @@ func (P *Parser) ParseImportSpec(pos int) *AST.Decl { P.Error(P.pos, `"import ." not yet handled properly`); P.Next(); } else if P.tok == Scanner.IDENT { - d.ident = P.ParseIdent(nil); + d.Ident = P.ParseIdent(nil); } if P.tok == Scanner.STRING { // TODO eventually the scanner should strip the quotes val := AST.NewObject(P.pos, AST.NONE, P.val); - d.val = AST.NewLit(Scanner.STRING, val); + d.Val = AST.NewLit(Scanner.STRING, val); P.Next(); } else { P.Expect(Scanner.STRING); // use Expect() error handling } - if d.ident != nil { - P.Declare(d.ident, AST.PACKAGE); + if d.Ident != nil { + P.Declare(d.Ident, AST.PACKAGE); } P.Ecart(); @@ -1530,15 +1530,15 @@ func (P *Parser) ParseConstSpec(exported bool, pos int) *AST.Decl { P.Trace("ConstSpec"); d := AST.NewDecl(pos, Scanner.CONST, exported); - d.ident = P.ParseIdentList(); - d.typ = P.TryType(); + d.Ident = P.ParseIdentList(); + d.Typ = P.TryType(); if P.tok == Scanner.ASSIGN { P.Next(); - d.val = P.ParseExpressionList(); + d.Val = P.ParseExpressionList(); } - P.Declare(d.ident, AST.CONST); - P.VerifyExport(d.ident, exported); + P.Declare(d.Ident, AST.CONST); + P.VerifyExport(d.Ident, exported); P.Ecart(); return d; @@ -1549,11 +1549,11 @@ func (P *Parser) ParseTypeSpec(exported bool, pos int) *AST.Decl { P.Trace("TypeSpec"); d := AST.NewDecl(pos, Scanner.TYPE, exported); - d.ident = P.ParseIdent(nil); - d.typ = P.ParseType(); + d.Ident = P.ParseIdent(nil); + d.Typ = P.ParseType(); P.opt_semi = true; - P.VerifyExport(d.ident, exported); + P.VerifyExport(d.Ident, exported); P.Ecart(); return d; @@ -1564,20 +1564,20 @@ func (P *Parser) ParseVarSpec(exported bool, pos int) *AST.Decl { P.Trace("VarSpec"); d := AST.NewDecl(pos, Scanner.VAR, exported); - d.ident = P.ParseIdentList(); + d.Ident = P.ParseIdentList(); if P.tok == Scanner.ASSIGN { P.Next(); - d.val = P.ParseExpressionList(); + d.Val = P.ParseExpressionList(); } else { - d.typ = P.ParseVarType(); + d.Typ = P.ParseVarType(); if P.tok == Scanner.ASSIGN { P.Next(); - d.val = P.ParseExpressionList(); + d.Val = P.ParseExpressionList(); } } - P.Declare(d.ident, AST.VAR); - P.VerifyExport(d.ident, exported); + P.Declare(d.Ident, AST.VAR); + P.VerifyExport(d.Ident, exported); P.Ecart(); return d; @@ -1606,16 +1606,16 @@ func (P *Parser) ParseDecl(exported bool, keyword int) *AST.Decl { if P.tok == Scanner.LPAREN { P.Next(); d = AST.NewDecl(pos, keyword, exported); - d.list = array.New(0); + d.List = array.New(0); for P.tok != Scanner.RPAREN && P.tok != Scanner.EOF { - d.list.Push(P.ParseSpec(exported, pos, keyword)); + d.List.Push(P.ParseSpec(exported, pos, keyword)); if P.tok == Scanner.SEMICOLON { P.Next(); } else { break; } } - d.end = P.pos; + d.End = P.pos; P.Expect(Scanner.RPAREN); P.opt_semi = true; @@ -1647,23 +1647,23 @@ func (P *Parser) ParseFunctionDecl(exported bool) *AST.Decl { if P.tok == Scanner.LPAREN { pos := P.pos; recv = P.ParseParameters(true); - if recv.nfields() != 1 { + if recv.Nfields() != 1 { P.Error(pos, "must have exactly one receiver"); } } - d.ident = P.ParseIdent(nil); - d.typ = P.ParseFunctionType(); - d.typ.key = recv; + d.Ident = P.ParseIdent(nil); + d.Typ = P.ParseFunctionType(); + d.Typ.Key = recv; if P.tok == Scanner.LBRACE { P.scope_lev++; - d.list, d.end = P.ParseBlock(); + d.List, d.End = P.ParseBlock(); P.scope_lev--; } if recv == nil || exported { - P.VerifyExport(d.ident, exported); + P.VerifyExport(d.Ident, exported); } P.Ecart(); @@ -1675,7 +1675,7 @@ func (P *Parser) ParseExportDecl() *AST.Decl { P.Trace("ExportDecl"); d := AST.NewDecl(P.pos, Scanner.EXPORT, false); - d.ident = P.ParseIdentList(); + d.Ident = P.ParseIdentList(); P.Ecart(); return d; @@ -1735,25 +1735,25 @@ func (P *Parser) ParseProgram() *AST.Program { P.OpenScope(); p := AST.NewProgram(P.pos); P.Expect(Scanner.PACKAGE); - p.ident = P.ParseIdent(nil); + p.Ident = P.ParseIdent(nil); // package body { P.OpenScope(); - p.decls = array.New(0); + p.Decls = array.New(0); for P.tok == Scanner.IMPORT { - p.decls.Push(P.ParseDecl(false, Scanner.IMPORT)); + p.Decls.Push(P.ParseDecl(false, Scanner.IMPORT)); P.OptSemicolon(); } if !P.deps { for P.tok != Scanner.EOF { - p.decls.Push(P.ParseDeclaration()); + p.Decls.Push(P.ParseDeclaration()); P.OptSemicolon(); } } P.CloseScope(); } - p.comments = P.comments; + p.Comments = P.comments; P.CloseScope(); P.Ecart(); diff --git a/usr/gri/pretty/platform.go b/usr/gri/pretty/platform.go index 529ef13ff2c..c605b07a5cc 100644 --- a/usr/gri/pretty/platform.go +++ b/usr/gri/pretty/platform.go @@ -17,7 +17,7 @@ export var USER string; -func GetEnv(key string) string { +func getEnv(key string) string { n := len(key); for i := 0; i < sys.envc(); i++ { v := sys.envv(i); @@ -30,10 +30,10 @@ func GetEnv(key string) string { func init() { - GOARCH = GetEnv("GOARCH"); - GOOS = GetEnv("GOOS"); - GOROOT = GetEnv("GOROOT"); - USER = GetEnv("USER"); + GOARCH = getEnv("GOARCH"); + GOOS = getEnv("GOOS"); + GOROOT = getEnv("GOROOT"); + USER = getEnv("USER"); } @@ -42,13 +42,13 @@ func init() { export const ( MAGIC_obj_file = "@gri-go.7@v0"; // make it clear that it cannot be a source file - src_file_ext = ".go"; - obj_file_ext = ".7"; + Src_file_ext = ".go"; + Obj_file_ext = ".7"; ) export func ReadObjectFile(filename string) (data string, ok bool) { - data, ok = sys.readfile(filename + obj_file_ext); + data, ok = sys.readfile(filename + Obj_file_ext); magic := MAGIC_obj_file; // TODO remove once len(constant) works if ok && len(data) >= len(magic) && data[0 : len(magic)] == magic { return data, ok; @@ -58,13 +58,13 @@ export func ReadObjectFile(filename string) (data string, ok bool) { export func ReadSourceFile(name string) (data string, ok bool) { - name = Utils.TrimExt(name, src_file_ext) + src_file_ext; + name = Utils.TrimExt(name, Src_file_ext) + Src_file_ext; data, ok = sys.readfile(name); return data, ok; } export func WriteObjectFile(name string, data string) bool { - name = Utils.TrimExt(Utils.BaseName(name), src_file_ext) + obj_file_ext; + name = Utils.TrimExt(Utils.BaseName(name), Src_file_ext) + Obj_file_ext; return sys.writefile(name, data); } diff --git a/usr/gri/pretty/pretty.go b/usr/gri/pretty/pretty.go index b5656ce242e..366b176cd50 100644 --- a/usr/gri/pretty/pretty.go +++ b/usr/gri/pretty/pretty.go @@ -29,7 +29,7 @@ func init() { } -func Usage() { +func usage() { print("usage: pretty { flags } { files }\n"); Flag.PrintDefaults(); sys.exit(0); @@ -40,7 +40,7 @@ func main() { Flag.Parse(); if Flag.NFlag() == 0 && Flag.NArg() == 0 { - Usage(); + usage(); } // process files diff --git a/usr/gri/pretty/printer.go b/usr/gri/pretty/printer.go index de4a601cc6c..45ef1a0e744 100644 --- a/usr/gri/pretty/printer.go +++ b/usr/gri/pretty/printer.go @@ -54,7 +54,7 @@ const ( ) -type Printer struct { +export type Printer struct { // output text io.Write; @@ -86,7 +86,7 @@ func (P *Printer) HasComment(pos int) bool { func (P *Printer) NextComment() { P.cindex++; if P.comments != nil && P.cindex < P.comments.Len() { - P.cpos = P.comments.At(P.cindex).(*AST.Comment).pos; + P.cpos = P.comments.At(P.cindex).(*AST.Comment).Pos; } else { P.cpos = 1<<30; // infinite } @@ -109,7 +109,7 @@ func (P *Printer) Init(text io.Write, comments *array.Array) { // ---------------------------------------------------------------------------- // Printing support -func HtmlEscape(s string) string { +func htmlEscape(s string) string { if *html { var esc string; for i := 0; i < len(s); i++ { @@ -118,7 +118,7 @@ func HtmlEscape(s string) string { case '&': esc = "&"; default: continue; } - return s[0 : i] + esc + HtmlEscape(s[i+1 : len(s)]); + return s[0 : i] + esc + htmlEscape(s[i+1 : len(s)]); } } return s; @@ -126,7 +126,7 @@ func HtmlEscape(s string) string { // Reduce contiguous sequences of '\t' in a string to a single '\t'. -func Untabify(s string) string { +func untabify(s string) string { for i := 0; i < len(s); i++ { if s[i] == '\t' { j := i; @@ -134,7 +134,7 @@ func Untabify(s string) string { j++; } if j-i > 1 { // more then one tab - return s[0 : i+1] + Untabify(s[j : len(s)]); + return s[0 : i+1] + untabify(s[j : len(s)]); } } } @@ -210,7 +210,7 @@ func (P *Printer) TaggedString(pos int, tag, s, endtag string) { for ; P.HasComment(pos); P.NextComment() { // we have a comment/newline that comes before the string comment := P.comments.At(P.cindex).(*AST.Comment); - ctext := comment.text; + ctext := comment.Text; if ctext == "\n" { // found a newline in src - count it @@ -261,9 +261,9 @@ func (P *Printer) TaggedString(pos int, tag, s, endtag string) { if *debug { P.Printf("[%d]", P.cpos); } - // calling Untabify increases the change for idempotent output + // calling untabify increases the change for idempotent output // since tabs in comments are also interpreted by tabwriter - P.Printf("%s", HtmlEscape(Untabify(ctext))); + P.Printf("%s", htmlEscape(untabify(ctext))); if ctext[1] == '/' { //-style comments must end in newline @@ -309,7 +309,7 @@ func (P *Printer) TaggedString(pos int, tag, s, endtag string) { if *debug { P.Printf("[%d]", pos); } - P.Printf("%s%s%s", tag, HtmlEscape(s), endtag); + P.Printf("%s%s%s", tag, htmlEscape(s), endtag); // -------------------------------- // interpret state @@ -359,7 +359,7 @@ func (P *Printer) HtmlPrologue(title string) { "\n" "
\n" " \n" - "