Commit 211cdf1e authored by Marvin Stenger's avatar Marvin Stenger Committed by Ian Lance Taylor

cmd/compile/internal/gc: cleaning lex.go

Cleaning along the way:
-convert variable types from int to bool
-remove unnecessary functions
-remove unnecessary type conversion
-remove unnecessary variable declarations
-transform struct{string,string} with lookup to map[string]string

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I259728fe4afd7f23b67f08fab856ce0abee57b21
Reviewed-on: https://go-review.googlesource.com/14435Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 19d262ff
...@@ -382,12 +382,12 @@ type Sig struct { ...@@ -382,12 +382,12 @@ type Sig struct {
type Io struct { type Io struct {
infile string infile string
bin *obj.Biobuf bin *obj.Biobuf
nlsemi int cp string // used for content when bin==nil
eofnl int
last int last int
peekc int peekc int
peekc1 int // second peekc for ... peekc1 int // second peekc for ...
cp string // used for content when bin==nil nlsemi bool
eofnl bool
importsafe bool importsafe bool
} }
...@@ -598,7 +598,7 @@ var incannedimport int ...@@ -598,7 +598,7 @@ var incannedimport int
var statuniqgen int // name generator for static temps var statuniqgen int // name generator for static temps
var loophack int var loophack bool
var iota_ int32 var iota_ int32
......
...@@ -2311,6 +2311,6 @@ func fixlbrace(lbr int) { ...@@ -2311,6 +2311,6 @@ func fixlbrace(lbr int) {
// set up for another one now that we're done. // set up for another one now that we're done.
// See comment in lex.C about loophack. // See comment in lex.C about loophack.
if lbr == LBODY { if lbr == LBODY {
loophack = 1 loophack = true
} }
} }
This diff is collapsed.
...@@ -122,7 +122,7 @@ func Yyerror(format string, args ...interface{}) { ...@@ -122,7 +122,7 @@ func Yyerror(format string, args ...interface{}) {
// An unexpected EOF caused a syntax error. Use the previous // An unexpected EOF caused a syntax error. Use the previous
// line number since getc generated a fake newline character. // line number since getc generated a fake newline character.
if curio.eofnl != 0 { if curio.eofnl {
lexlineno = prevlineno lexlineno = prevlineno
} }
......
...@@ -18,15 +18,19 @@ func atoi(s string) int { ...@@ -18,15 +18,19 @@ func atoi(s string) int {
return int(n) return int(n)
} }
func isalnum(c int) bool { func isSpace(c int) bool {
return isalpha(c) || isdigit(c) return c == ' ' || c == '\t' || c == '\n' || c == '\r'
} }
func isalpha(c int) bool { func isAlnum(c int) bool {
return isAlpha(c) || isDigit(c)
}
func isAlpha(c int) bool {
return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z'
} }
func isdigit(c int) bool { func isDigit(c int) bool {
return '0' <= c && c <= '9' return '0' <= c && c <= '9'
} }
......
...@@ -160,7 +160,7 @@ func fixlbrace(lbr int) { ...@@ -160,7 +160,7 @@ func fixlbrace(lbr int) {
// set up for another one now that we're done. // set up for another one now that we're done.
// See comment in lex.C about loophack. // See comment in lex.C about loophack.
if lbr == LBODY { if lbr == LBODY {
loophack = 1 loophack = true
} }
} }
......
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