Commit Graph

73 Commits

Author SHA1 Message Date
Robert Griesemer
77567265a8 Preparation for moving scanner into a lib:
- separated out token definition from scanner
- cleaned up token and scanner implementation
- added comments to exported interfaces

R=r
OCL=25665
CL=25665
2009-03-03 18:25:07 -08:00
Robert Griesemer
63b332eddd - allow ()'s and {}'s for now when parsing calls/composite literals
- require ()'s around composite literals at the if/for/switch control clause level
- fixed a nasty bug: passing a value instead of a pointer to a value to an interface
  variable - and not noticing that the value is copied

R=r
OCL=25649
CL=25649
2009-03-03 16:00:06 -08:00
Robert Griesemer
fadf159a81 fix a bug: do not print a ';' after a label if there wasn't one
R=r
OCL=25526
CL=25528
2009-02-27 16:28:36 -08:00
Robert Griesemer
3689e221e8 Steps towards a general scanner/parser library for Go:
- converted more of AST and parser to use interfaces and explicit
structs for individual Go constructs (can be replaced now with
interface calls such that the parser becomes AST structure
independent, as suggested by rsc)
- added more tests (find all .go files under GOROOT)
- (temporarily) lost html links for identifiers when generating
html output
- TODO: lots of cleanups

R=r
OCL=25518
CL=25518
2009-02-27 15:40:17 -08:00
Robert Griesemer
18ed7e690a - accept new composite literal syntax
- remove all parsing heuristics
- as a result, accept a wider syntax, but parser is simpler

R=r
OCL=25029
CL=25029
2009-02-13 16:27:53 -08:00
Robert Griesemer
127526649f - vector package (identical to array except for names)
- updated some file (but not all - left array package in place for now)

R=rsc
DELTA=530  (483 added, 0 deleted, 47 changed)
OCL=25025
CL=25025
2009-02-13 15:07:56 -08:00
Robert Griesemer
8e7873672e - fixed bugs related to the empty statement
(now in sync with the spec and with 6g)
- fixed incorrect logging statement in gds

R=r
OCL=24970
CL=24970
2009-02-12 16:06:21 -08:00
Robert Griesemer
e08cc15251 Some real GDS functionality:
- directory listings w/ working links
- some links working in source code (most don't do the right thing yet)
- use of logging

R=r
OCL=24728
CL=24728
2009-02-09 21:05:14 -08:00
Robert Griesemer
9acd2a9731 snapshot:
- first stab at a Go Documentation Server (gds)
- various fixes to make initial version of gds work

R=r
OCL=24588
CL=24588
2009-02-06 15:26:30 -08:00
Robert Griesemer
187cf78a7c - preparation for setting up types
- moved Object, Type, Scope  out of AST into symboltable
  - moved universe into symboltable
  - removed dead code
- fixed dependency computation (pretty -d filename.go)
- lots of cleanups
- removed tocken channel connection between parser and scanner
  (was cute, but not really needed)

R=r
OCL=24545
CL=24545
2009-02-06 11:10:25 -08:00
Robert Griesemer
5d571cc67e snapshot:
- ast statements now use interfaces
- deleted old (now unused) code

R=r
OCL=24422
CL=24422
2009-02-05 11:05:02 -08:00
Robert Griesemer
1595a1947c today's snapshot: steps towards using interfaces for statements in ast
R=r
OCL=24380
CL=24380
2009-02-04 18:28:41 -08:00
Robert Griesemer
c048ee21ad - converted expr representation of ast into a new representation
using interfaces properly => much cleaner code
- converted tracing code to use 'defer' statement
- next steps: convert rest of ast as well

R=r
OCL=24277
CL=24277
2009-02-03 17:44:01 -08:00
Robert Griesemer
b67603dfef - added experimental flag '-def': will print (not parse!)
'def' instead of 'func', 'const', or 'type'

R=r
OCL=24092
CL=24094
2009-02-02 11:51:07 -08:00
Robert Griesemer
6dd93bbfbc - changed pretty parser to parse and print new function type syntax
- added more test cases
- fixed a bug in test script which prevented errors to show up...

R=r
OCL=23832
CL=23974
2009-01-30 15:31:04 -08:00
Robert Griesemer
3d4d5ad04c defer statement
R=r
OCL=23542
CL=23542
2009-01-26 17:48:27 -08:00
Robert Griesemer
9e3b0f444a snapshot before making more changes:
- fine-tuning of ast
- more accurate block pos info (improved printing in some cases)
- collecting local variables and fields
- more work on type checking
- lots of minor tweaks

R=r
OCL=23375
CL=23375
2009-01-23 09:44:01 -08:00
Robert Griesemer
96c20204a7 - updated pretty (removed "export")
R=r
OCL=23134
CL=23134
2009-01-20 15:22:33 -08:00
Russ Cox
839a68469b delete export
TBR=r
OCL=23121
CL=23127
2009-01-20 14:40:40 -08:00
Robert Griesemer
2527bba993 casify pretty
R=r
OCL=22899
CL=22899
2009-01-15 17:16:41 -08:00
Rob Pike
61f3302044 printf->Printf etc.
the raw fmt routines will be another, smaller but subtler pass.

R=rsc
DELTA=157  (0 added, 0 deleted, 157 changed)
OCL=22851
CL=22851
2009-01-15 13:48:11 -08:00
Robert Griesemer
ba556a8818 - removed an unnecessary field from AST.Expr nodes
R=r
OCL=22601
CL=22601
2009-01-12 17:44:10 -08:00
Robert Griesemer
c620dd9759 - preparation to add type info to ast
- consolidation of files, cleanup
- more success producing idempotent output for some files with comments
  containing tabs
- snapshot of the day

R=r
OCL=22474
CL=22474
2009-01-09 16:28:09 -08:00
Rob Pike
c45d2a767c simplify flag interface. no more BVal etc. you just get a pointer.
fixed everything except the tutorial.

R=rsc
DELTA=404  (94 added, 139 deleted, 171 changed)
OCL=22414
CL=22422
2009-01-09 13:42:46 -08:00
Robert Griesemer
d54abad06f - first (global) idents with proper links to declarations in html output
(e.g. pretty -html source.go > source.html; then look at the html.file in a browser)

R=r
OCL=22331
CL=22331
2009-01-08 14:43:56 -08:00
Robert Griesemer
cb13c4d552 - more steps towards tracking idents in scopes
- snapshot of today

R=r
OCL=22247
CL=22247
2009-01-07 16:54:03 -08:00
Robert Griesemer
215eb7eb7f - steps towards augmenting ast with declaration info
(will help produce html output where we can click on identifiers and
  get to the declaration)
- snapshot before changing back to old new

R=r
OCL=22159
CL=22159
2009-01-06 14:54:18 -08:00
Robert Griesemer
c9859e7bc6 - support for range clauses
R=r
OCL=21030
CL=21030
2008-12-11 17:45:45 -08:00
Robert Griesemer
4873bb217c Snapshot:
- fixed html tag generation
- simplified html escaping machinery
  (not 100% correct for strings yet)
- can now produce the first mostly correct formatted html pages from source
  with (fake) links: e.g. pretty -html srcfile.go > srcfile.html
  R=r

OCL=20915
CL=20915
2008-12-10 13:51:19 -08:00
Robert Griesemer
4ad804679d - snapshot if current state
- fix pretty printer to work with new tabwriter interface

R=r
OCL=20854
CL=20854
2008-12-09 15:29:15 -08:00
Robert Griesemer
77aaf4f3a2 - adjusted const decl grammar to reflect spec changes
- first cut at html writer (will do html escaping, html tag production)
- first cut at generating basic html output via pretty
- some cleanups

R=r
OCL=20550
CL=20550
2008-12-04 18:18:41 -08:00
Robert Griesemer
2dba9a66e2 - fixed a bug with import printing (missing separator between alias and string)
- rewrote declaration printing - was unreadable before
- no semicolons after closing "}" for types

R=r
OCL=20379
CL=20379
2008-12-03 15:47:30 -08:00
Robert Griesemer
acfd1fd443 - oversight: extra allow source-level line breaks inside statement lists
- fixed printing of empty structs/interfaces
- enable two more tests

R=r
OCL=20296
CL=20296
2008-12-02 17:01:31 -08:00
Robert Griesemer
cb67a8324b - fine-tuning of white space
- by default consider extra newlines in src for better formatting
- additional flags for control (-newlines, -maxnewlines, -optsemicolons)
- don't print ()'s around single anonymous result types

Status: Comparing the output of pretty with the input for larger files
shows mostly whitespace/formatting differences, which is what is desired.

TODO:
- Handling of overlong lines
- some esoteric cases which look funny

R=r
OCL=20293
CL=20293
2008-12-02 16:49:44 -08:00
Robert Griesemer
37bdd3c3f5 - enabled comment printing by default
- changed tab width to 8 chars by default to make test run properly
- excluded 4 files that are not idempotently printed
- fixed a couple of incorrect file position recordings in parser
- fine-tuned layout engine
- white-space formatting reasonable, but not perfect
- no handling of overlong lines
R=r

To use with smaller tabs:           pretty -tabwidth=4 file.go
To use with blanks instead of tabs: pretty -usetabs=0 file.go

OCL=20184
CL=20184
2008-12-01 17:20:59 -08:00
Robert Griesemer
8bbd873c34 - better comment formatting, starting to look good
- comment printing still disabled by default because idempotency test fails
- whitespace control better but not perfect yet
- snapshot before making some heuristics changes

R=r
OCL=20151
CL=20151
2008-12-01 14:03:20 -08:00
Robert Griesemer
d79f687ed8 - collect addition source position information in parser
for end of declarations, blocks, parameter lists, etc.
- use extra src positions to more accurately print comments
- fine-tuned low-level printing routine for comments
- added better debugging support

Status:
- comments now appear at the right place (inbetween the right tokens)
- newline control needs improvement (not very hard)
- comment printing disabled for now because pretty is not idempotent
with it; to enable: -comments

R=r
OCL=20079
CL=20079
2008-11-26 17:07:45 -08:00
Robert Griesemer
732b53a1fe - snapshot of state before trying yet another, hopefully better working
way to integrate comments into the generated output
- various simplificatins and cleanups throughout

R=r
OCL=20062
CL=20062
2008-11-26 13:23:26 -08:00
Robert Griesemer
130e6f42f1 - implemented arbitrary padding char for tabwriter
- implemented right-to-left alignment (numerical results)
- better comments and error handling
- added more tests
- updated dependent files

R=r
DELTA=232  (175 added, 11 deleted, 46 changed)
OCL=19761
CL=19780
2008-11-21 09:35:49 -08:00
Robert Griesemer
0998eaf4a1 - correct error handling throughout
- documentation, cleanups
- more options

R=r
OCL=19736
CL=19736
2008-11-20 16:26:43 -08:00
Robert Griesemer
fcdcf33a71 - array-ify code, remove local implementation
R=r
OCL=19648
CL=19651
2008-11-19 16:49:50 -08:00
Robert Griesemer
34533f06eb - support for alignment via tabs instead of blanks
- exclude a test due to syntax errors

R=r
OCL=19563
CL=19565
2008-11-18 19:25:43 -08:00
Robert Griesemer
654bc2badc - factored out tabwriter a separate writer filter
(to be moved into std lib eventually)
- rewrote tabwriter to use byte buffers instead of strings
  (byte buffers to be moved into stdlib eventually)
- support for recent syntax changes
- no space printed after function name and before function parameters
- comments still disabled due to a known bug

R=r
OCL=19430
CL=19430
2008-11-17 19:58:52 -08:00
Robert Griesemer
22e0e1b049 - better comment classification
- related cleanups

R=r
OCL=19227
CL=19227
2008-11-13 19:06:57 -08:00
Robert Griesemer
3c2f0ae132 * pretty printing snapshot: towards printing comments nicely
- implemented elastic tabstops algorithm, now correct and documented
- first cut at printing comments (use -comments flag, disabled for now)
- struct field types are now aligned (using elastic tab stops)
- needs more fine-tuning

* fixed a bug in test script
* added quick smoke test to makefile and invoke it in run.bash
  instead of the full test

R=r
OCL=19220
CL=19220
2008-11-13 17:50:46 -08:00
Robert Griesemer
2a58e7d7a0 more work on elastic tabs:
- new code enabled, but no comments printed yet (so the effect
  of the elastic tabs is not seen yet)

TBR=r
DELTA=200  (93 added, 69 deleted, 38 changed)
OCL=18951
CL=18951
2008-11-10 17:56:46 -08:00
Robert Griesemer
a3b4a3c29d - steps towards "flexible tab stops" simulation in pretty
printing output
- not yet enabled

R=r
OCL=18842
CL=18842
2008-11-07 18:30:58 -08:00
Robert Griesemer
42ae5270d8 - handle field tags in pretty printer
R=r
OCL=18264
CL=18264
2008-10-31 14:27:34 -07:00
Robert Griesemer
cec64a2dd5 - some factoring of scan/parse phase so we can attach other functionality
easily (for instance import dependency extraction)
- support for new "..." syntax
- minor cleanup

R=r
OCL=17811
CL=17811
2008-10-24 14:04:54 -07:00
Robert Griesemer
816c1cefff - expanded parsing heuristics to deal with new(T, ...)
- fixed an issue with select
- added all bugs and fixedbugs tests that are syntactically correct to the test suite
- minor cosmetic changes

R=r
OCL=17759
CL=17759
2008-10-23 17:56:54 -07:00