cmd/compile: eliminate pushedio and savedstate

While here, get drop the lexlineno{++,--} hacks for canned imports.
They were added in commit d3237f9, but don't seem to serve any
purpose.

Change-Id: I00f9e6be0ae9f217f2fa113b85e041dfd0303757
Reviewed-on: https://go-review.googlesource.com/19652
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Matthew Dempsky 2016-02-19 18:47:01 -08:00
parent 4e6e8e8c58
commit 338a891e79
3 changed files with 22 additions and 45 deletions

View file

@ -13,6 +13,7 @@ package gc
// to handle optional commas and semicolons before a closing ) or } .
import (
"cmd/internal/obj"
"fmt"
"strconv"
"strings"
@ -24,7 +25,10 @@ const trace = false // if set, parse tracing can be enabled with -x
// we can get rid of this (issue 13242).
var fileparser parser // the Go source file parser in use
func parse_import() {
func parse_import(bin *obj.Biobuf) {
pushedio := curio
curio = Io{bin: bin}
// Indentation (for tracing) must be preserved across parsers
// since we are changing the lexer source (and parser state)
// under foot, in the middle of productions. This won't be
@ -35,10 +39,14 @@ func parse_import() {
importparser := parser{indent: fileparser.indent} // preserve indentation
importparser.next()
importparser.import_package()
curio = pushedio
}
// parse_file sets up a new parser and parses a single Go source file.
func parse_file() {
func parse_file(bin *obj.Biobuf) {
curio = Io{bin: bin}
fileparser = parser{}
fileparser.next()
fileparser.file()
@ -428,6 +436,7 @@ func (p *parser) import_package() {
}
importpkg.Safe = importsafe
typecheckok = true
defercheckwidth()
p.hidden_import_list()
@ -438,6 +447,7 @@ func (p *parser) import_package() {
}
resumecheckwidth()
typecheckok = false
}
// Declaration = ConstDecl | TypeDecl | VarDecl .