diff --git a/_examples/expr/expr.y b/_examples/expr/expr.y index fdcc0947ad10220b8715e0f3e565525134cd9965..f845fe3357d8e7b599eae9ad37fc814d3dc2355f 100644 --- a/_examples/expr/expr.y +++ b/_examples/expr/expr.y @@ -70,18 +70,18 @@ type exprLexer struct { pos int } -func (p *exprLexer) Lex(yylval *exprSymType) int { - if p.pos >= len(p.tokens) { +func exprLexer.Lex(yylval *exprSymType) int { + if this.pos >= len(this.tokens) { return eof } - tok := p.tokens[p.pos] - p.pos++ + tok := this.tokens[this.pos] + this.pos++ yylval.num = tok.Value return tok.Kind } -func (x *exprLexer) Error(s string) { +func exprLexer.Error(s string) { println("ERROR:", s) } diff --git a/_examples/expr/y.wa b/_examples/expr/y.wa index af7c16eaa7db6ca196e048f19440880a3e3aa8f4..4eee57b97893133f556f60a0006366b963f841c8 100644 --- a/_examples/expr/y.wa +++ b/_examples/expr/y.wa @@ -45,18 +45,18 @@ type exprLexer struct { pos :int } -func (p: *exprLexer) Lex(yylval: *exprSymType) => int { - if p.pos >= len(p.tokens) { +func exprLexer.Lex(yylval: *exprSymType) => int { + if this.pos >= len(this.tokens) { return eof } - tok := p.tokens[p.pos] - p.pos++ + tok := this.tokens[this.pos] + this.pos++ yylval.num = tok.Value return tok.Kind } -func (x: *exprLexer) Error(s: string) { +func exprLexer.Error(s: string) { println("ERROR:", s) } @@ -164,8 +164,8 @@ type exprParser struct { char :int } -func (p: *exprParser) Lookahead() => int { - return p.char +func exprParser.Lookahead() => int { + return this.char } func exprNewParser() => *exprParser { @@ -299,18 +299,18 @@ func exprParse(exprlex: *exprLexer) => int { return exprNewParser().Parse(exprlex) } -func (exprrcvr: *exprParser) Parse(exprlex: *exprLexer) => int { +func exprParser.Parse(exprlex: *exprLexer) => int { var exprn: int var exprVAL: exprSymType var exprDollar: []exprSymType _ = exprDollar // silence set and not used - exprS := exprrcvr.stack[:] + exprS := this.stack[:] Nerrs := 0 /* number of errors */ Errflag := 0 /* error recovery flag */ exprstate := 0 - exprrcvr.char = -1 - exprtoken := -1 // exprrcvr.char translated into internal numbering + this.char = -1 + exprtoken := -1 // this.char translated into internal numbering exprp := -1 const __goto_exprstack = -1 @@ -348,8 +348,8 @@ Loop: __goto_x = __goto_exprdefault continue Loop } - if exprrcvr.char < 0 { - exprrcvr.char, exprtoken = exprlex1(exprlex, &exprrcvr.lval) + if this.char < 0 { + this.char, exprtoken = exprlex1(exprlex, &this.lval) } exprn += exprtoken if exprn < 0 || exprn >= exprLast { @@ -358,9 +358,9 @@ Loop: } exprn = exprAct[exprn] if exprChk[exprn] == exprtoken { /* valid shift */ - exprrcvr.char = -1 + this.char = -1 exprtoken = -1 - exprVAL = exprrcvr.lval + exprVAL = this.lval exprstate = exprn if Errflag > 0 { Errflag-- @@ -376,8 +376,8 @@ Loop: /* default state action */ exprn = exprDef[exprstate] if exprn == -2 { - if exprrcvr.char < 0 { - exprrcvr.char, exprtoken = exprlex1(exprlex, &exprrcvr.lval) + if this.char < 0 { + this.char, exprtoken = exprlex1(exprlex, &this.lval) } /* look through exception table */ @@ -398,7 +398,7 @@ Loop: if exprn < 0 { // Make sure we report no lookahead when not parsing. exprstate = -1 - exprrcvr.char = -1 + this.char = -1 exprtoken = -1 return 0 @@ -437,7 +437,7 @@ Loop: // Make sure we report no lookahead when not parsing. exprstate = -1 - exprrcvr.char = -1 + this.char = -1 exprtoken = -1 /* there is no state on the stack with an error shift ... abort */ @@ -450,12 +450,12 @@ Loop: if exprtoken == exprEofCode { // Make sure we report no lookahead when not parsing. exprstate = -1 - exprrcvr.char = -1 + this.char = -1 exprtoken = -1 return 1 } - exprrcvr.char = -1 + this.char = -1 exprtoken = -1 __goto_x = __goto_exprnewstate /* try again in the same state */ diff --git a/internal/app/yacc/yacc.go b/internal/app/yacc/yacc.go index db59e4960cbb20ce0ccec12bebb7b24e8370f9fc..b0aa44b0f523037d3e4b54959cb26ebeef843267 100644 --- a/internal/app/yacc/yacc.go +++ b/internal/app/yacc/yacc.go @@ -3271,8 +3271,8 @@ type $$Parser struct { char int } -func (p *$$Parser) Lookahead() int { - return p.char +func $$Parser.Lookahead() int { + return this.char } func $$NewParser() *$$Parser { @@ -3406,18 +3406,18 @@ func $$Parse($$lex *$$Lexer) int { return $$NewParser().Parse($$lex) } -func ($$rcvr *$$Parser) Parse($$lex *$$Lexer) int { +func $$Parser.Parse($$lex *$$Lexer) int { var $$n int var $$VAL $$SymType var $$Dollar []$$SymType _ = $$Dollar // silence set and not used - $$S := $$rcvr.stack[:] + $$S := this.stack[:] Nerrs := 0 /* number of errors */ Errflag := 0 /* error recovery flag */ $$state := 0 - $$rcvr.char = -1 - $$token := -1 // $$rcvr.char translated into internal numbering + this.char = -1 + $$token := -1 // this.char translated into internal numbering $$p := -1 const __goto_$$stack = -1 @@ -3454,8 +3454,8 @@ case __goto_$$newstate: __goto_x = __goto_$$default continue Loop } - if $$rcvr.char < 0 { - $$rcvr.char, $$token = $$lex1($$lex, &$$rcvr.lval) + if this.char < 0 { + this.char, $$token = $$lex1($$lex, &this.lval) } $$n += $$token if $$n < 0 || $$n >= $$Last { @@ -3464,9 +3464,9 @@ case __goto_$$newstate: } $$n = $$Act[$$n] if $$Chk[$$n] == $$token { /* valid shift */ - $$rcvr.char = -1 + this.char = -1 $$token = -1 - $$VAL = $$rcvr.lval + $$VAL = this.lval $$state = $$n if Errflag > 0 { Errflag-- @@ -3482,8 +3482,8 @@ case __goto_$$default: /* default state action */ $$n = $$Def[$$state] if $$n == -2 { - if $$rcvr.char < 0 { - $$rcvr.char, $$token = $$lex1($$lex, &$$rcvr.lval) + if this.char < 0 { + this.char, $$token = $$lex1($$lex, &this.lval) } /* look through exception table */ @@ -3504,7 +3504,7 @@ case __goto_$$default: if $$n < 0 { // Make sure we report no lookahead when not parsing. $$state = -1 - $$rcvr.char = -1 + this.char = -1 $$token = -1 return 0 @@ -3543,7 +3543,7 @@ case __goto_$$default: // Make sure we report no lookahead when not parsing. $$state = -1 - $$rcvr.char = -1 + this.char = -1 $$token = -1 /* there is no state on the stack with an error shift ... abort */ @@ -3556,12 +3556,12 @@ case __goto_$$default: if $$token == $$EofCode { // Make sure we report no lookahead when not parsing. $$state = -1 - $$rcvr.char = -1 + this.char = -1 $$token = -1 return 1 } - $$rcvr.char = -1 + this.char = -1 $$token = -1 __goto_x = __goto_$$newstate /* try again in the same state */