Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wa-lang
wa
提交
b670f338
wa
项目概览
wa-lang
/
wa
11 个月 前同步成功
通知
68
Star
655
Fork
45
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
wa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b670f338
编写于
2月 19, 2023
作者:
chai2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
yacc: 调整生成的方法代码风格
上级
c5035ebd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
42 deletion
+42
-42
_examples/expr/expr.y
_examples/expr/expr.y
+5
-5
_examples/expr/y.wa
_examples/expr/y.wa
+21
-21
internal/app/yacc/yacc.go
internal/app/yacc/yacc.go
+16
-16
未找到文件。
_examples/expr/expr.y
浏览文件 @
b670f338
...
@@ -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)
}
}
...
...
_examples/expr/y.wa
浏览文件 @
b670f338
...
@@ -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 */
...
...
internal/app/yacc/yacc.go
浏览文件 @
b670f338
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录