• Robert Griesemer's avatar
    go/printer: implement SourcePos mode · f8cf82f6
    Robert Griesemer authored
    If a printer is configured with the SourcePos mode
    set, it will emit //-line comments as necessary to
    ensure that the result - if reparsed - reflects the
    original source position information.
    
    This change required a bit of reworking of the
    output section in printer.go. Specifically:
    
    - Introduced new Config mode 'SourcePos'.
    
    - Introduced new position 'out' which tracks the
    position of the generated output if it were read
    in again. If there is a discrepancy between out
    and the current AST/source position, a //line
    comment is emitted to correct for it.
    
    - Lazy emission of indentation so that //line
    comments can be placed correctly. As a result,
    the trimmer will have to do less work.
    
    - Merged writeItem into writeString.
    
    - Merged writeByteN into writeByte.
    
    - Use a []byte instead of a byte.Buffer both in the
    printer and in the trimmer (eliminates dependency).
    
    Also: introduced explicit printer.Mode type (in
    sync w/ parser.Mode, scanner.Mode, etc.)
    
    Runs all tests. Applied gofmt to src, misc w/o changes.
    
    Fixes #1047.
    Fixes #2697.
    
    R=rsc, rsc
    CC=golang-dev
    https://golang.org/cl/5643066
    f8cf82f6
Name
Last commit
Last update
..
articles Loading commit data...
codelab/wiki Loading commit data...
codewalk Loading commit data...
devel Loading commit data...
gopher Loading commit data...
play Loading commit data...
progs Loading commit data...
talks Loading commit data...
ExpressivenessOfGo.pdf Loading commit data...
Makefile Loading commit data...
all.css Loading commit data...
button_background.png Loading commit data...
code.html Loading commit data...
codereview_with_mq.html Loading commit data...
community.html Loading commit data...
contrib.html Loading commit data...
contribute.html Loading commit data...
debugging_with_gdb.html Loading commit data...
docs.html Loading commit data...
effective_go.html Loading commit data...
effective_go.tmpl Loading commit data...
frontpage.css Loading commit data...
gccgo_contribute.html Loading commit data...
gccgo_install.html Loading commit data...
go-logo-black.png Loading commit data...
go-logo-blue.png Loading commit data...
go-logo-white.png Loading commit data...
go1.html Loading commit data...
go1.tmpl Loading commit data...
go1compat.html Loading commit data...
go_faq.html Loading commit data...
go_for_cpp_programmers.html Loading commit data...
go_mem.html Loading commit data...
go_spec.html Loading commit data...
go_tutorial.html Loading commit data...
go_tutorial.tmpl Loading commit data...
godocs.js Loading commit data...
ie.css Loading commit data...
install.html Loading commit data...
logo-153x55.png Loading commit data...
logo.png Loading commit data...
makehtml Loading commit data...
play_overlay.png Loading commit data...
playground.html Loading commit data...
popups.js Loading commit data...
root.html Loading commit data...
sieve.gif Loading commit data...
tmpltohtml.go Loading commit data...
video-001.png Loading commit data...
video-002.png Loading commit data...
video-003.png Loading commit data...
video-004.png Loading commit data...
video-005.jpg Loading commit data...