Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wa-lang
wa
提交
61d8ae10
wa
项目概览
wa-lang
/
wa
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
61d8ae10
编写于
6月 21, 2023
作者:
chai2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wayacc 输出代码改用凹语言风格
上级
a72a04ea
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
15 deletion
+16
-15
internal/app/yacc/yacc.go
internal/app/yacc/yacc.go
+15
-14
waroot/examples/expr/y.wa
waroot/examples/expr/y.wa
+1
-1
未找到文件。
internal/app/yacc/yacc.go
浏览文件 @
61d8ae10
...
...
@@ -725,7 +725,7 @@ outer:
// put out names of tokens
ftable
.
WriteRune
(
'\n'
)
fmt
.
Fprintf
(
ftable
,
"
var
%sToknames = [...]string{
\n
"
,
prefix
)
fmt
.
Fprintf
(
ftable
,
"
global
%sToknames = [...]string{
\n
"
,
prefix
)
for
i
:=
1
;
i
<=
ntokens
;
i
++
{
fmt
.
Fprintf
(
ftable
,
"
\t
%q,
\n
"
,
tokset
[
i
]
.
name
)
}
...
...
@@ -735,7 +735,7 @@ outer:
// commented out to avoid a huge table just for debugging.
// re-enable to have the names in the binary.
ftable
.
WriteRune
(
'\n'
)
fmt
.
Fprintf
(
ftable
,
"
var
%sStatenames = [...]string{
\n
"
,
prefix
)
fmt
.
Fprintf
(
ftable
,
"
global
%sStatenames = [...]string{
\n
"
,
prefix
)
// for i:=TOKSTART; i<=ntokens; i++ {
// fmt.Fprintf(ftable, "\t%q,\n", tokset[i].name);
// }
...
...
@@ -1094,7 +1094,7 @@ out:
lineno
++
case
'{'
:
if
level
==
0
{
fmt
.
Fprintf
(
ftable
,
"
\n\t
yys int"
)
fmt
.
Fprintf
(
ftable
,
"
\n\t
yys
:
int"
)
}
level
++
case
'}'
:
...
...
@@ -2889,7 +2889,7 @@ func others() {
// table 3 has everything else
ftable
.
WriteRune
(
'\n'
)
fmt
.
Fprintf
(
ftable
,
"
var
%sTok3 = [...]int{
\n\t
"
,
prefix
)
fmt
.
Fprintf
(
ftable
,
"
global
%sTok3 = [...]int{
\n\t
"
,
prefix
)
c
=
0
for
i
=
1
;
i
<=
ntokens
;
i
++
{
j
=
tokset
[
i
]
.
value
...
...
@@ -2917,12 +2917,12 @@ func others() {
// Custom error messages.
fmt
.
Fprintf
(
ftable
,
"
\n
"
)
fmt
.
Fprintf
(
ftable
,
"type %sErrorMessageInfo struct {
\n
"
,
prefix
)
fmt
.
Fprintf
(
ftable
,
"
\t
state int
\n
"
)
fmt
.
Fprintf
(
ftable
,
"
\t
token int
\n
"
)
fmt
.
Fprintf
(
ftable
,
"
\t
msg string
\n
"
)
fmt
.
Fprintf
(
ftable
,
"
\t
state
:
int
\n
"
)
fmt
.
Fprintf
(
ftable
,
"
\t
token
:
int
\n
"
)
fmt
.
Fprintf
(
ftable
,
"
\t
msg
:
string
\n
"
)
fmt
.
Fprintf
(
ftable
,
"}
\n
"
)
fmt
.
Fprintf
(
ftable
,
"
var
%sErrorMessages = [...]%sErrorMessageInfo {
\n
"
,
prefix
,
prefix
)
fmt
.
Fprintf
(
ftable
,
"
global
%sErrorMessages = [...]%sErrorMessageInfo {
\n
"
,
prefix
,
prefix
)
for
_
,
error
:=
range
errors
{
lineno
=
error
.
lineno
state
,
token
:=
runMachine
(
error
.
tokens
)
...
...
@@ -3006,7 +3006,7 @@ Loop:
func
arout
(
s
string
,
v
[]
int
,
n
int
)
{
s
=
prefix
+
s
ftable
.
WriteRune
(
'\n'
)
fmt
.
Fprintf
(
ftable
,
"
var
%v = [...]int{"
,
s
)
fmt
.
Fprintf
(
ftable
,
"
global
%v = [...]int{"
,
s
)
for
i
:=
0
;
i
<
n
;
i
++
{
if
i
%
10
==
0
{
fmt
.
Fprintf
(
ftable
,
"
\n\t
"
)
...
...
@@ -3249,6 +3249,7 @@ func wafmt() {
return
}
}
else
{
// todo: fix fmt yacc output.wa
src
,
err
=
format
.
SourceFile
(
src
)
if
err
!=
nil
{
return
...
...
@@ -3261,7 +3262,7 @@ var yaccpar string // will be processed version of yaccpartext: s/$$/prefix/g
var
yaccpartext
=
`
/* parser for yacc output */
var
(
global
(
$$Debug = 0
$$ErrorVerbose = false
)
...
...
@@ -3408,9 +3409,9 @@ func $$Parse($$lex: *$$Lexer) => int {
}
func $$Parser.Parse($$lex: *$$Lexer) => int {
var
$$n: int
var
$$VAL: $$SymType
var
$$Dollar: []$$SymType
$$n: int
$$VAL: $$SymType
$$Dollar: []$$SymType
_ = $$Dollar // silence set and not used
$$S := this.stack[:]
...
...
@@ -3424,7 +3425,7 @@ func $$Parser.Parse($$lex: *$$Lexer) => int {
const __goto_$$stack = -1
const __goto_$$newstate = -2
const __goto_$$default = -3
var __goto_x
= __goto_$$stack
__goto_x :
= __goto_$$stack
Loop:
for { switch __goto_x {
...
...
waroot/examples/expr/y.wa
浏览文件 @
61d8ae10
...
...
@@ -316,7 +316,7 @@ func exprParser.Parse(exprlex: *exprLexer) => int {
const __goto_exprstack = -1
const __goto_exprnewstate = -2
const __goto_exprdefault = -3
var __goto_x
= __goto_exprstack
__goto_x :
= __goto_exprstack
Loop:
for {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录