Commit e06a654c authored by Robert Griesemer's avatar Robert Griesemer

daily snapshot:

- correctly associate comments with declarations
  (available through AST)
- very raw printing of interface
- much more functionality, now needs some formatting, sorting, etc.

R=r
OCL=26213
CL=26213
parent ce9417ee
......@@ -28,6 +28,21 @@ func assert(pred bool) {
}
// ----------------------------------------------------------------------------
// Comments
type Comment struct {
Loc scanner.Location;
EndLine int; // the line where the comment ends
Text []byte;
}
// A CommentGroup is a sequence of consequtive comments
// with no other tokens and no empty lines inbetween.
type CommentGroup []*Comment
// ----------------------------------------------------------------------------
// Expressions
......@@ -132,6 +147,7 @@ type (
Idents []*Ident;
Typ Expr;
Tag Expr; // nil = no tag
Comment CommentGroup;
};
StructType struct {
......@@ -445,12 +461,14 @@ type (
Idents []*Ident;
Typ Expr;
Vals Expr;
Comment CommentGroup;
};
TypeDecl struct {
Loc scanner.Location; // if > 0: position of "type"
Ident *Ident;
Typ Expr;
Comment CommentGroup;
};
VarDecl struct {
......@@ -458,6 +476,7 @@ type (
Idents []*Ident;
Typ Expr;
Vals Expr;
Comment CommentGroup;
};
FuncDecl struct {
......@@ -466,6 +485,7 @@ type (
Ident *Ident;
Sig *Signature;
Body *Block;
Comment CommentGroup;
};
DeclList struct {
......@@ -500,17 +520,13 @@ func (d *DeclList) Visit(v DeclVisitor) { v.DoDeclList(d); }
// ----------------------------------------------------------------------------
// Program
type Comment struct {
Loc scanner.Location;
Text []byte;
}
// TODO rename to Package
type Program struct {
Loc scanner.Location; // tok is token.PACKAGE
Ident *Ident;
Decls []Decl;
Comments []*Comment;
Comment CommentGroup;
Comments []CommentGroup;
}
......
......@@ -112,7 +112,7 @@ func Compile(src_file string, flags *Flags) (*AST.Program, int) {
var parser Parser.Parser;
parser.Init(&scanner, &err, flags.Verbose);
prog := parser.ParseProgram();
prog := parser.Parse(Parser.ParseEntirePackage);
if err.nerrors == 0 {
TypeChecker.CheckProgram(&err, prog);
......
......@@ -108,7 +108,7 @@ func serveFile(c *http.Conn, filename string) {
}
c.SetHeader("content-type", "text/html; charset=utf-8");
Printer.Print(c, true, prog);
Printer.Print(c, prog, true);
}
......
This diff is collapsed.
......@@ -53,7 +53,7 @@ func main() {
sys.Exit(1);
}
if !*silent {
Printer.Print(os.Stdout, *html, prog);
Printer.Print(os.Stdout, prog, *html);
}
}
}
......
This diff is collapsed.
<h1>package <!--PACKAGE--></h1>
<font color=red>THIS SECTION IS CURRENTLY UNDER CONSTRUCTION</font>
<!--INTERFACE-->
<h1>package <!--PACKAGE_NAME--></h1>
<!--PACKAGE_COMMENT-->
<!--PACKAGE_INTERFACE-->
<hr />
<h1>package <!--PACKAGE--></h1>
<h1>Implementation</h1>
<font color=grey>Comments are currently not shown in the source.</font>
<pre>
<!--BODY-->
<!--PACKAGE_BODY-->
</pre>
</div> <!-- content -->
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment