提交 b670f338 编写于 作者: chai2010's avatar chai2010

yacc: 调整生成的方法代码风格

上级 c5035ebd
...@@ -70,18 +70,18 @@ type exprLexer struct { ...@@ -70,18 +70,18 @@ type exprLexer struct {
pos int pos int
} }
func (p *exprLexer) Lex(yylval *exprSymType) int { func exprLexer.Lex(yylval *exprSymType) int {
if p.pos >= len(p.tokens) { if this.pos >= len(this.tokens) {
return eof return eof
} }
tok := p.tokens[p.pos] tok := this.tokens[this.pos]
p.pos++ this.pos++
yylval.num = tok.Value yylval.num = tok.Value
return tok.Kind return tok.Kind
} }
func (x *exprLexer) Error(s string) { func exprLexer.Error(s string) {
println("ERROR:", s) println("ERROR:", s)
} }
......
...@@ -45,18 +45,18 @@ type exprLexer struct { ...@@ -45,18 +45,18 @@ type exprLexer struct {
pos :int pos :int
} }
func (p: *exprLexer) Lex(yylval: *exprSymType) => int { func exprLexer.Lex(yylval: *exprSymType) => int {
if p.pos >= len(p.tokens) { if this.pos >= len(this.tokens) {
return eof return eof
} }
tok := p.tokens[p.pos] tok := this.tokens[this.pos]
p.pos++ this.pos++
yylval.num = tok.Value yylval.num = tok.Value
return tok.Kind return tok.Kind
} }
func (x: *exprLexer) Error(s: string) { func exprLexer.Error(s: string) {
println("ERROR:", s) println("ERROR:", s)
} }
...@@ -164,8 +164,8 @@ type exprParser struct { ...@@ -164,8 +164,8 @@ type exprParser struct {
char :int char :int
} }
func (p: *exprParser) Lookahead() => int { func exprParser.Lookahead() => int {
return p.char return this.char
} }
func exprNewParser() => *exprParser { func exprNewParser() => *exprParser {
...@@ -299,18 +299,18 @@ func exprParse(exprlex: *exprLexer) => int { ...@@ -299,18 +299,18 @@ func exprParse(exprlex: *exprLexer) => int {
return exprNewParser().Parse(exprlex) return exprNewParser().Parse(exprlex)
} }
func (exprrcvr: *exprParser) Parse(exprlex: *exprLexer) => int { func exprParser.Parse(exprlex: *exprLexer) => int {
var exprn: int var exprn: int
var exprVAL: exprSymType var exprVAL: exprSymType
var exprDollar: []exprSymType var exprDollar: []exprSymType
_ = exprDollar // silence set and not used _ = exprDollar // silence set and not used
exprS := exprrcvr.stack[:] exprS := this.stack[:]
Nerrs := 0 /* number of errors */ Nerrs := 0 /* number of errors */
Errflag := 0 /* error recovery flag */ Errflag := 0 /* error recovery flag */
exprstate := 0 exprstate := 0
exprrcvr.char = -1 this.char = -1
exprtoken := -1 // exprrcvr.char translated into internal numbering exprtoken := -1 // this.char translated into internal numbering
exprp := -1 exprp := -1
const __goto_exprstack = -1 const __goto_exprstack = -1
...@@ -348,8 +348,8 @@ Loop: ...@@ -348,8 +348,8 @@ Loop:
__goto_x = __goto_exprdefault __goto_x = __goto_exprdefault
continue Loop continue Loop
} }
if exprrcvr.char < 0 { if this.char < 0 {
exprrcvr.char, exprtoken = exprlex1(exprlex, &exprrcvr.lval) this.char, exprtoken = exprlex1(exprlex, &this.lval)
} }
exprn += exprtoken exprn += exprtoken
if exprn < 0 || exprn >= exprLast { if exprn < 0 || exprn >= exprLast {
...@@ -358,9 +358,9 @@ Loop: ...@@ -358,9 +358,9 @@ Loop:
} }
exprn = exprAct[exprn] exprn = exprAct[exprn]
if exprChk[exprn] == exprtoken { /* valid shift */ if exprChk[exprn] == exprtoken { /* valid shift */
exprrcvr.char = -1 this.char = -1
exprtoken = -1 exprtoken = -1
exprVAL = exprrcvr.lval exprVAL = this.lval
exprstate = exprn exprstate = exprn
if Errflag > 0 { if Errflag > 0 {
Errflag-- Errflag--
...@@ -376,8 +376,8 @@ Loop: ...@@ -376,8 +376,8 @@ Loop:
/* default state action */ /* default state action */
exprn = exprDef[exprstate] exprn = exprDef[exprstate]
if exprn == -2 { if exprn == -2 {
if exprrcvr.char < 0 { if this.char < 0 {
exprrcvr.char, exprtoken = exprlex1(exprlex, &exprrcvr.lval) this.char, exprtoken = exprlex1(exprlex, &this.lval)
} }
/* look through exception table */ /* look through exception table */
...@@ -398,7 +398,7 @@ Loop: ...@@ -398,7 +398,7 @@ Loop:
if exprn < 0 { if exprn < 0 {
// Make sure we report no lookahead when not parsing. // Make sure we report no lookahead when not parsing.
exprstate = -1 exprstate = -1
exprrcvr.char = -1 this.char = -1
exprtoken = -1 exprtoken = -1
return 0 return 0
...@@ -437,7 +437,7 @@ Loop: ...@@ -437,7 +437,7 @@ Loop:
// Make sure we report no lookahead when not parsing. // Make sure we report no lookahead when not parsing.
exprstate = -1 exprstate = -1
exprrcvr.char = -1 this.char = -1
exprtoken = -1 exprtoken = -1
/* there is no state on the stack with an error shift ... abort */ /* there is no state on the stack with an error shift ... abort */
...@@ -450,12 +450,12 @@ Loop: ...@@ -450,12 +450,12 @@ Loop:
if exprtoken == exprEofCode { if exprtoken == exprEofCode {
// Make sure we report no lookahead when not parsing. // Make sure we report no lookahead when not parsing.
exprstate = -1 exprstate = -1
exprrcvr.char = -1 this.char = -1
exprtoken = -1 exprtoken = -1
return 1 return 1
} }
exprrcvr.char = -1 this.char = -1
exprtoken = -1 exprtoken = -1
__goto_x = __goto_exprnewstate /* try again in the same state */ __goto_x = __goto_exprnewstate /* try again in the same state */
......
...@@ -3271,8 +3271,8 @@ type $$Parser struct { ...@@ -3271,8 +3271,8 @@ type $$Parser struct {
char int char int
} }
func (p *$$Parser) Lookahead() int { func $$Parser.Lookahead() int {
return p.char return this.char
} }
func $$NewParser() *$$Parser { func $$NewParser() *$$Parser {
...@@ -3406,18 +3406,18 @@ func $$Parse($$lex *$$Lexer) int { ...@@ -3406,18 +3406,18 @@ func $$Parse($$lex *$$Lexer) int {
return $$NewParser().Parse($$lex) return $$NewParser().Parse($$lex)
} }
func ($$rcvr *$$Parser) Parse($$lex *$$Lexer) int { func $$Parser.Parse($$lex *$$Lexer) int {
var $$n int var $$n int
var $$VAL $$SymType var $$VAL $$SymType
var $$Dollar []$$SymType var $$Dollar []$$SymType
_ = $$Dollar // silence set and not used _ = $$Dollar // silence set and not used
$$S := $$rcvr.stack[:] $$S := this.stack[:]
Nerrs := 0 /* number of errors */ Nerrs := 0 /* number of errors */
Errflag := 0 /* error recovery flag */ Errflag := 0 /* error recovery flag */
$$state := 0 $$state := 0
$$rcvr.char = -1 this.char = -1
$$token := -1 // $$rcvr.char translated into internal numbering $$token := -1 // this.char translated into internal numbering
$$p := -1 $$p := -1
const __goto_$$stack = -1 const __goto_$$stack = -1
...@@ -3454,8 +3454,8 @@ case __goto_$$newstate: ...@@ -3454,8 +3454,8 @@ case __goto_$$newstate:
__goto_x = __goto_$$default __goto_x = __goto_$$default
continue Loop continue Loop
} }
if $$rcvr.char < 0 { if this.char < 0 {
$$rcvr.char, $$token = $$lex1($$lex, &$$rcvr.lval) this.char, $$token = $$lex1($$lex, &this.lval)
} }
$$n += $$token $$n += $$token
if $$n < 0 || $$n >= $$Last { if $$n < 0 || $$n >= $$Last {
...@@ -3464,9 +3464,9 @@ case __goto_$$newstate: ...@@ -3464,9 +3464,9 @@ case __goto_$$newstate:
} }
$$n = $$Act[$$n] $$n = $$Act[$$n]
if $$Chk[$$n] == $$token { /* valid shift */ if $$Chk[$$n] == $$token { /* valid shift */
$$rcvr.char = -1 this.char = -1
$$token = -1 $$token = -1
$$VAL = $$rcvr.lval $$VAL = this.lval
$$state = $$n $$state = $$n
if Errflag > 0 { if Errflag > 0 {
Errflag-- Errflag--
...@@ -3482,8 +3482,8 @@ case __goto_$$default: ...@@ -3482,8 +3482,8 @@ case __goto_$$default:
/* default state action */ /* default state action */
$$n = $$Def[$$state] $$n = $$Def[$$state]
if $$n == -2 { if $$n == -2 {
if $$rcvr.char < 0 { if this.char < 0 {
$$rcvr.char, $$token = $$lex1($$lex, &$$rcvr.lval) this.char, $$token = $$lex1($$lex, &this.lval)
} }
/* look through exception table */ /* look through exception table */
...@@ -3504,7 +3504,7 @@ case __goto_$$default: ...@@ -3504,7 +3504,7 @@ case __goto_$$default:
if $$n < 0 { if $$n < 0 {
// Make sure we report no lookahead when not parsing. // Make sure we report no lookahead when not parsing.
$$state = -1 $$state = -1
$$rcvr.char = -1 this.char = -1
$$token = -1 $$token = -1
return 0 return 0
...@@ -3543,7 +3543,7 @@ case __goto_$$default: ...@@ -3543,7 +3543,7 @@ case __goto_$$default:
// Make sure we report no lookahead when not parsing. // Make sure we report no lookahead when not parsing.
$$state = -1 $$state = -1
$$rcvr.char = -1 this.char = -1
$$token = -1 $$token = -1
/* there is no state on the stack with an error shift ... abort */ /* there is no state on the stack with an error shift ... abort */
...@@ -3556,12 +3556,12 @@ case __goto_$$default: ...@@ -3556,12 +3556,12 @@ case __goto_$$default:
if $$token == $$EofCode { if $$token == $$EofCode {
// Make sure we report no lookahead when not parsing. // Make sure we report no lookahead when not parsing.
$$state = -1 $$state = -1
$$rcvr.char = -1 this.char = -1
$$token = -1 $$token = -1
return 1 return 1
} }
$$rcvr.char = -1 this.char = -1
$$token = -1 $$token = -1
__goto_x = __goto_$$newstate /* try again in the same state */ __goto_x = __goto_$$newstate /* try again in the same state */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册