Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
饶先宏
hdl4se
提交
342a18da
H
hdl4se
项目概览
饶先宏
/
hdl4se
通知
12
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hdl4se
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
342a18da
编写于
5月 29, 2021
作者:
饶先宏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
202105291721 error corrected
上级
b92532c6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
17 deletion
+35
-17
preprocess/include/filestack.h
preprocess/include/filestack.h
+22
-1
preprocess/src/verilog_preprocess.c
preprocess/src/verilog_preprocess.c
+13
-16
未找到文件。
preprocess/include/filestack.h
浏览文件 @
342a18da
...
...
@@ -35,6 +35,8 @@
*/
#define BUFLEN 2048
#define MAX_UNGET 4
typedef
struct
_sfilestack
{
struct
_sfilestack
*
pNext
;
struct
_sfilestack
*
pLast
;
...
...
@@ -46,7 +48,9 @@ typedef struct _sfilestack {
int
filepos
;
char
*
buf
;
int
ungetch
;
int
ungetchwr
;
int
ungetchrd
;
int
ungetchs
[
MAX_UNGET
];
int
bufindex
;
int
buflen
;
int
isbufonly
;
...
...
@@ -73,6 +77,23 @@ static void filestack_destroy(filestack * stack)
stack
->
pNext
=
stack
->
pLast
=
stack
;
}
static
int
filestack_unget
(
filestack
*
stack
,
int
ch
)
{
stack
->
ungetchs
[
stack
->
ungetchwr
]
=
ch
;
stack
->
ungetchwr
=
(
stack
->
ungetchwr
+
1
)
%
MAX_UNGET
;
return
0
;
}
static
int
filestack_get_unget
(
filestack
*
stack
)
{
int
ch
;
if
(
stack
->
ungetchrd
==
stack
->
ungetchwr
)
return
-
1
;
ch
=
stack
->
ungetchs
[
stack
->
ungetchrd
];
stack
->
ungetchrd
=
(
stack
->
ungetchrd
+
1
)
%
MAX_UNGET
;
return
ch
;
}
static
filestack
*
filestack_push_file
(
filestack
*
stack
,
const
char
*
filename
)
{
filestack
*
pitem
;
...
...
preprocess/src/verilog_preprocess.c
浏览文件 @
342a18da
...
...
@@ -32,6 +32,7 @@
/*
修改记录:
202105140816: 根据git的要求增加License
202105291720: correct an error on get ch from a filestack
*/
#include "stdio.h"
...
...
@@ -642,9 +643,7 @@ static int verilog_preprocess_GetCh(sVerilogPreprocess * pPreprocess)
ch
=
0
;
goto
returnch
;
}
if
(
curfile
->
ungetch
!=
0
)
{
ch
=
curfile
->
ungetch
;
curfile
->
ungetch
=
0
;
if
((
ch
=
filestack_get_unget
(
curfile
))
>
0
)
{
goto
returnch
;
}
/* 找到一个有字符的缓冲区 */
...
...
@@ -685,6 +684,9 @@ static int verilog_preprocess_GetCh(sVerilogPreprocess * pPreprocess)
}
}
while
(
curfile
->
bufindex
<
curfile
->
buflen
)
{
if
((
ch
=
filestack_get_unget
(
curfile
))
>
0
)
{
goto
returnch
;
}
ch
=
curfile
->
buf
[
curfile
->
bufindex
];
curfile
->
bufindex
++
;
/* 滤掉非字符串中的\r字符 */
...
...
@@ -744,7 +746,7 @@ static int verilog_preprocess_GetToken(sVerilogPreprocess* pPreprocess, int ch,
pPreprocess
->
tokenstate
=
TOKEN_NONE
;
pPreprocess
->
tokentype
=
TT_NUMBER
;
pPreprocess
->
token
[
pPreprocess
->
tokenlen
]
=
0
;
pPreprocess
->
file_stack_top
->
ungetch
=
ch
;
filestack_unget
(
pPreprocess
->
file_stack_top
,
ch
)
;
*
pch
=
' '
;
}
}
else
if
(
pPreprocess
->
tokenstate
==
TOKEN_IN_SIMIDENT
)
{
...
...
@@ -753,7 +755,7 @@ static int verilog_preprocess_GetToken(sVerilogPreprocess* pPreprocess, int ch,
pPreprocess
->
token
[
pPreprocess
->
tokenlen
++
]
=
ch
;
return
NEXT_CONTINUE
;
}
else
{
/* 完成一个SIMIDENT */
pPreprocess
->
file_stack_top
->
ungetch
=
ch
;
filestack_unget
(
pPreprocess
->
file_stack_top
,
ch
)
;
*
pch
=
' '
;
pPreprocess
->
tokenstate
=
TOKEN_NONE
;
pPreprocess
->
tokentype
=
TT_SIMIDENT
;
...
...
@@ -764,7 +766,7 @@ static int verilog_preprocess_GetToken(sVerilogPreprocess* pPreprocess, int ch,
pPreprocess
->
token
[
pPreprocess
->
tokenlen
++
]
=
ch
;
return
NEXT_CONTINUE
;
}
else
{
pPreprocess
->
file_stack_top
->
ungetch
=
ch
;
filestack_unget
(
pPreprocess
->
file_stack_top
,
ch
)
;
*
pch
=
' '
;
pPreprocess
->
token
[
pPreprocess
->
tokenlen
]
=
0
;
pPreprocess
->
tokenstate
=
TOKEN_NONE
;
...
...
@@ -810,7 +812,7 @@ static int verilog_preprocess_GetToken(sVerilogPreprocess* pPreprocess, int ch,
pPreprocess
->
lastch
=
' '
;
/* 这个*号不能作为结束注释的开始*号 */
return
NEXT_CONTINUE
;
}
else
{
pPreprocess
->
file_stack_top
->
ungetch
=
ch
;
filestack_unget
(
pPreprocess
->
file_stack_top
,
ch
)
;
*
pch
=
'/'
;
pPreprocess
->
tokenstate
=
TOKEN_NONE
;
pPreprocess
->
tokentype
=
TT_SYMBOL
;
/*token text is in ch*/
...
...
@@ -819,7 +821,7 @@ static int verilog_preprocess_GetToken(sVerilogPreprocess* pPreprocess, int ch,
}
}
else
if
(
pPreprocess
->
tokenstate
==
TOKEN_IN_COMMENT
)
{
if
(
(
ch
==
'/'
)
&&
(
pPreprocess
->
lastch
==
'*'
)
)
{
pPreprocess
->
file_stack_top
->
ungetch
=
' '
;
filestack_unget
(
pPreprocess
->
file_stack_top
,
' '
)
;
*
pch
=
' '
;
pPreprocess
->
tokenstate
=
TOKEN_NONE
;
pPreprocess
->
tokentype
=
TT_NONE
;
...
...
@@ -832,7 +834,7 @@ static int verilog_preprocess_GetToken(sVerilogPreprocess* pPreprocess, int ch,
if
(
ch
==
'\n'
)
{
pPreprocess
->
tokenstate
=
TOKEN_NONE
;
pPreprocess
->
tokentype
=
TT_NONE
;
pPreprocess
->
file_stack_top
->
ungetch
=
'\n'
;
filestack_unget
(
pPreprocess
->
file_stack_top
,
ch
)
;
pPreprocess
->
lastch
=
ch
;
return
NEXT_CONTINUE
;
}
else
{
...
...
@@ -844,7 +846,7 @@ static int verilog_preprocess_GetToken(sVerilogPreprocess* pPreprocess, int ch,
pPreprocess
->
tokenstate
=
TOKEN_NONE
;
pPreprocess
->
tokentype
=
TT_MACRO_TEXT
;
pPreprocess
->
token
[
pPreprocess
->
tokenlen
]
=
0
;
pPreprocess
->
file_stack_top
->
ungetch
=
'\n'
;
filestack_unget
(
pPreprocess
->
file_stack_top
,
ch
)
;
}
else
if
(
ch
==
'\\'
)
{
pPreprocess
->
lastch
=
ch
;
pPreprocess
->
tokenstate
=
TOKEN_IN_MACRO_TEXT_SLASH
;
...
...
@@ -1478,12 +1480,8 @@ static int verilog_preprocess_state_macro(sVerilogPreprocess * pPreprocess, int
pPreprocess
->
state
=
STATE_CD_MACRO_PARAM_TEXT
;
pPreprocess
->
tokenlen
=
0
;
DLIST_DESTROY
(
stringitem
,
&
pPreprocess
->
macro_param_list
);
}
else
if
(
isblank
(
ch
)
||
(
ch
==
'\n'
)
)
{
}
else
if
(
(
ch
==
'/'
)
&&
(
pPreprocess
->
tokentype
!=
TT_SYMBOL
))
{
pPreprocess
->
tokenstate
=
TOKEN_COMMENT_START
;
pPreprocess
->
lastch
=
'/'
;
}
else
{
pPreprocess
->
file_stack_top
->
ungetch
=
ch
;
filestack_unget
(
pPreprocess
->
file_stack_top
,
ch
)
;
verilog_preprocess_preprocess_PreAction
(
pPreprocess
,
PA_MACRO
,
pPreprocess
->
macro_name
,
""
);
pPreprocess
->
state
=
STATE_INITIAL
;
pPreprocess
->
tokenstate
=
TOKEN_NONE
;
...
...
@@ -1491,7 +1489,6 @@ static int verilog_preprocess_state_macro(sVerilogPreprocess * pPreprocess, int
}
return
NEXT_CONTINUE
;
}
else
if
(
pPreprocess
->
state
==
STATE_CD_MACRO_PARAM_TEXT
)
{
pPreprocess
->
file_stack_top
->
ungetch
=
ch
;
ch
=
verilog_preprocess_GetMacroParamText
(
pPreprocess
);
pPreprocess
->
token
[
pPreprocess
->
tokenlen
]
=
0
;
stringlistaddstring
(
&
pPreprocess
->
macro_param_list
,
pPreprocess
->
token
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录