Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
Lab07
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
CP Lab Group
实验项目模板
Lab07
提交
69f5aec2
提交
69f5aec2
6月 28, 2019
创建
作者:
demo10
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify
上级
87393e2c
流水线
#856
已失败 于阶段
用时 42 秒
变更
9
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
300 行增加
和
2 行删除
+300
-2
.gitignore
.gitignore
+1
-0
.gitlab-ci.yml
.gitlab-ci.yml
+69
-0
First.cplproj
First.cplproj
+8
-2
First.h
First.h
+3
-0
input1.txt
input1.txt
+10
-0
main.c
main.c
+150
-0
makefile
makefile
+21
-0
output1.txt
output1.txt
+16
-0
sonar-project.properties
sonar-project.properties
+22
-0
没有找到文件。
.gitignore
浏览文件 @
69f5aec2
/Debug
/Debug
/Release
/Release
*.bak
.gitlab-ci.yml
0 → 100644
浏览文件 @
69f5aec2
image
:
"
registry.cn-hangzhou.aliyuncs.com/engintime/ubuntu_16.04_program:latest"
stages
:
-
make
-
code-analysis
-
case1
variables
:
TEACHERCHECK_REPO
:
"
engintime/cp-lab/teachers-packet/Lab007.git"
.codecode-runner
:
&codecode-runner
tags
:
-
ubuntu-16.04
-
short-job
make
:
stage
:
make
<<
:
*codecode-runner
script
:
-
make
-
./app < input1.txt > user_output1.txt
-
execscore.sh 40
only
:
-
master
code-analysis
:
stage
:
code-analysis
<<
:
*codecode-runner
script
:
-
make
-
mkdir -p build
-
cppcheck -v --force --enable=all --xml -I./ ./ 2> ./build/cppcheck-report.xml
-
bash -c 'find ./ -regex ".*\.c\|.*\.h" | vera++ -S -s -d -c ./build/vera-report.xml'
-
valgrind --xml=yes --xml-file=./build/valgrind-report.xml ./app < input1.txt
-
sonar-scanner -Dsonar.projectKey=ProjectKey-$CI_PROJECT_ID -Dsonar.projectName=$CI_PROJECT_NAME -Dsonar.links.homepage=$CI_PROJECT_URL -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.gitlab.project_id=$CI_PROJECT_ID -Dsonar.gitlab.url=$CODECODE_PROTOCOL$CODECODE_DOMAIN
allow_failure
:
true
only
:
-
master
case1
:
stage
:
case1
<<
:
*codecode-runner
script
:
-
make
-
./app < input1.txt > user_output1.txt
-
diff output1.txt user_output1.txt -b -B -y -i --suppress-common-lines
-
execscore.sh 50
only
:
-
master
teacher-check1
:
stage
:
case1
<<
:
*codecode-runner
script
:
-
make
-
./app < input1.txt
-
git clone ${CODECODE_PROTOCOL}gitlab-ci-token:${CI_JOB_TOKEN}@${CODECODE_DOMAIN}/${CI_PROJECT_FORKSOURCE} template
-
diff template/.gitlab-ci.yml .gitlab-ci.yml -b -B -y -i --suppress-common-lines
-
diff template/input1.txt input1.txt -b -B -y -i --suppress-common-lines
-
diff template/output1.txt output1.txt -b -B -y -i --suppress-common-lines
-
fileidentity.sh
-
git clone ${CODECODE_PROTOCOL}gitlab-ci-token:${CI_JOB_TOKEN}@${CODECODE_DOMAIN}/${TEACHERCHECK_REPO} teacher_check
-
./app < teacher_check/input1.txt > user_output1.txt
-
diff teacher_check/output1.txt user_output1.txt -b -B -y -i --suppress-common-lines
-
extracase.sh
only
:
-
master
when
:
manual
allow_failure
:
true
\ No newline at end of file
First.cplproj
浏览文件 @
69f5aec2
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<Configuration
Name=
"Debug"
>
<Configuration
Name=
"Debug"
>
<Tool
Name=
"PreBuildEventTool"
/>
<Tool
Name=
"PreBuildEventTool"
/>
<Tool
Name=
"CustomBuildTool"
/>
<Tool
Name=
"CustomBuildTool"
/>
<Tool
Name=
"GCCCompilerTool"
PreprocessorDefinitions=
"_DEBUG"
GenerateDebugInformation=
"-1"
AdditionalOptions=
""
/>
<Tool
Name=
"GCCCompilerTool"
PreprocessorDefinitions=
"_DEBUG"
GenerateDebugInformation=
"-1"
AdditionalOptions=
"
-std=c99
"
/>
<Tool
Name=
"PreLinkEventTool"
/>
<Tool
Name=
"PreLinkEventTool"
/>
<Tool
Name=
"GCCLinkerTool"
AdditionalDependencies=
""$(CPLInstallDir)Dump\lib\First_Demo.o""
/>
<Tool
Name=
"GCCLinkerTool"
AdditionalDependencies=
""$(CPLInstallDir)Dump\lib\First_Demo.o""
/>
<Tool
Name=
"PostBuildEventTool"
/>
<Tool
Name=
"PostBuildEventTool"
/>
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
<Configuration
Name=
"Release"
>
<Configuration
Name=
"Release"
>
<Tool
Name=
"PreBuildEventTool"
/>
<Tool
Name=
"PreBuildEventTool"
/>
<Tool
Name=
"CustomBuildTool"
/>
<Tool
Name=
"CustomBuildTool"
/>
<Tool
Name=
"GCCCompilerTool"
PreprocessorDefinitions=
"NDEBUG"
/>
<Tool
Name=
"GCCCompilerTool"
PreprocessorDefinitions=
"NDEBUG"
AdditionalOptions=
"-std=c99"
/>
<Tool
Name=
"PreLinkEventTool"
/>
<Tool
Name=
"PreLinkEventTool"
/>
<Tool
Name=
"GCCLinkerTool"
/>
<Tool
Name=
"GCCLinkerTool"
/>
<Tool
Name=
"PostBuildEventTool"
/>
<Tool
Name=
"PostBuildEventTool"
/>
...
@@ -33,5 +33,11 @@
...
@@ -33,5 +33,11 @@
<File
RelativePath=
".\main.c"
>
<File
RelativePath=
".\main.c"
>
</File>
</File>
</Filter>
</Filter>
<File
RelativePath=
".\input1.txt"
>
</File>
<File
RelativePath=
".\makefile"
>
</File>
<File
RelativePath=
".\output1.txt"
>
</File>
</Files>
</Files>
</OSLProject>
</OSLProject>
First.h
浏览文件 @
69f5aec2
...
@@ -59,11 +59,14 @@ int AddSetToSet(Set* pDesSet, const Set* pSrcSet);
...
@@ -59,11 +59,14 @@ int AddSetToSet(Set* pDesSet, const Set* pSrcSet);
int
SetHasVoid
(
const
Set
*
pSet
);
int
SetHasVoid
(
const
Set
*
pSet
);
Rule
*
InitRules
();
Rule
*
InitRules
();
Rule
*
InitRules_CI
();
Rule
*
CreateRule
(
const
char
*
pRuleName
);
Rule
*
CreateRule
(
const
char
*
pRuleName
);
RuleSymbol
*
CreateSymbol
();
RuleSymbol
*
CreateSymbol
();
void
PrintRule
(
const
Rule
*
pHead
);
void
PrintRule
(
const
Rule
*
pHead
);
void
PrintFirstSet
(
SetList
*
pFirstSetList
);
//
//
// 在此声明全局变量
// 在此声明全局变量
...
...
input1.txt
0 → 100644
浏览文件 @
69f5aec2
exp -> exp addop term
exp -> term
addop -> +
addop -> -
term -> term mulop factor
term -> factor
mulop -> *
factor -> ( exp )
factor -> number
\ No newline at end of file
main.c
浏览文件 @
69f5aec2
#include "First.h"
#include "First.h"
#include <string.h>
#include <stdlib.h>
const
char
*
VoidSymbol
=
"$"
;
// "ε"
const
char
*
VoidSymbol
=
"$"
;
// "ε"
char
rule_table_ci
[
20
][
256
];
char
ruleNameArr
[
20
][
64
];
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
//
//
// 调用 InitRules 函数初始化文法
// 调用 InitRules 函数初始化文法
//
//
#ifdef CODECODE_CI
Rule
*
pHead
=
InitRules_CI
();
#else
Rule
*
pHead
=
InitRules
();
Rule
*
pHead
=
InitRules
();
#endif
//
//
// 输出文法
// 输出文法
...
@@ -20,6 +29,11 @@ int main(int argc, char* argv[])
...
@@ -20,6 +29,11 @@ int main(int argc, char* argv[])
SetList
FirstSet
;
SetList
FirstSet
;
FirstSet
.
nSetCount
=
0
;
FirstSet
.
nSetCount
=
0
;
First
(
pHead
,
&
FirstSet
);
First
(
pHead
,
&
FirstSet
);
//
// 输出First集合
//
PrintFirstSet
(
&
FirstSet
);
return
0
;
return
0
;
}
}
...
@@ -220,6 +234,112 @@ Rule* InitRules()
...
@@ -220,6 +234,112 @@ Rule* InitRules()
/*
/*
功能:
功能:
初始化文法链表(在执行流水线时调用)。
返回值:
文法的头指针。
*/
Rule
*
InitRules_CI
()
{
int
nRuleCount
=
0
;
// 需要读取多行文本
for
(
int
i
=
0
;
i
<
20
;
i
++
)
{
gets
(
rule_table_ci
[
i
]);
int
length
=
strlen
(
rule_table_ci
[
i
]);
if
(
length
==
0
)
{
break
;
}
for
(
int
j
=
0
;
j
<
length
;
j
++
)
{
if
(
rule_table_ci
[
i
][
j
]
==
' '
)
{
ruleNameArr
[
i
][
j
]
=
'\0'
;
break
;
}
ruleNameArr
[
i
][
j
]
=
rule_table_ci
[
i
][
j
];
}
nRuleCount
++
;
}
Rule
*
pHead
,
*
pRule
;
RuleSymbol
**
pSymbolPtr
,
*
pNewSymbol
;
Rule
**
pRulePtr
=
&
pHead
;
for
(
int
i
=
0
;
i
<
nRuleCount
;
i
++
)
{
*
pRulePtr
=
CreateRule
(
ruleNameArr
[
i
]);
pRulePtr
=
&
(
*
pRulePtr
)
->
pNextRule
;
}
pRule
=
pHead
;
for
(
int
i
=
0
;
i
<
nRuleCount
;
i
++
)
{
pSymbolPtr
=
&
pRule
->
pFirstSymbol
;
int
start
=
0
;
for
(
int
j
=
0
;
rule_table_ci
[
i
][
j
]
!=
'\0'
;
j
++
)
{
if
(
rule_table_ci
[
i
][
j
]
==
' '
&&
rule_table_ci
[
i
][
j
+
1
]
==
'-'
&&
rule_table_ci
[
i
][
j
+
2
]
==
'>'
&&
rule_table_ci
[
i
][
j
+
3
]
==
' '
)
{
start
=
j
+
4
;
break
;
}
}
for
(
int
k
=
start
;
rule_table_ci
[
i
][
k
]
!=
'\0'
;
k
++
)
{
if
(
rule_table_ci
[
i
][
k
]
==
' '
)
{
continue
;
}
pNewSymbol
=
CreateSymbol
();
char
tokenName
[
MAX_STR_LENGTH
]
=
{};
for
(
int
m
=
0
;
;
m
++
)
{
if
(
rule_table_ci
[
i
][
k
]
==
' '
||
rule_table_ci
[
i
][
k
]
==
'\0'
||
rule_table_ci
[
i
][
k
]
==
'\n'
)
{
tokenName
[
m
]
=
'\0'
;
break
;
}
tokenName
[
m
]
=
rule_table_ci
[
i
][
k
++
];
}
strcpy
(
pNewSymbol
->
SymbolName
,
tokenName
);
pNewSymbol
->
isToken
=
1
;
for
(
int
n
=
0
;
n
<
nRuleCount
;
n
++
)
{
if
(
strcmp
(
pNewSymbol
->
SymbolName
,
ruleNameArr
[
n
])
==
0
)
{
pNewSymbol
->
isToken
=
0
;
break
;
}
}
*
pSymbolPtr
=
pNewSymbol
;
pSymbolPtr
=
&
pNewSymbol
->
pNextSymbol
;
}
pRule
=
pRule
->
pNextRule
;
}
return
pHead
;
}
/*
功能:
创建一个新的文法。
创建一个新的文法。
参数:
参数:
...
@@ -272,3 +392,33 @@ void PrintRule(const Rule* pHead)
...
@@ -272,3 +392,33 @@ void PrintRule(const Rule* pHead)
//
//
}
}
/*
功能:
输出 First 集合。
参数:
pFirstSetList -- First 集合指针。
*/
void
PrintFirstSet
(
SetList
*
pFirstSetList
)
{
printf
(
"
\n
The First Set:
\n
"
);
for
(
int
i
=
0
;
i
<
pFirstSetList
->
nSetCount
;
i
++
)
{
printf
(
"First(%s) = { "
,
pFirstSetList
->
Sets
[
i
].
Name
);
for
(
int
j
=
0
;
j
<
pFirstSetList
->
Sets
[
i
].
nTerminalCount
;
j
++
)
{
if
(
j
==
pFirstSetList
->
Sets
[
i
].
nTerminalCount
-
1
)
{
printf
(
"%s "
,
pFirstSetList
->
Sets
[
i
].
Terminal
[
j
]);
}
else
{
printf
(
"%s, "
,
pFirstSetList
->
Sets
[
i
].
Terminal
[
j
]);
}
}
printf
(
"}
\n
"
);
}
}
makefile
0 → 100644
浏览文件 @
69f5aec2
DIR_INC
=
.
DIR_SRC
=
.
DIR_OBJ
=
.
DIR_BIN
=
.
SRC
=
$
(
wildcard
${
DIR_SRC
}
/
*
.c
)
OBJ
=
$
(
patsubst %.c,
${
DIR_OBJ
}
/%.o,
$
(
notdir
${
SRC
}
))
TARGET
=
app
BIN_TARGET
=
${
DIR_BIN
}
/
${
TARGET
}
CC
=
gcc
CFLAGS
=
-g
-w
-fmax-errors
=
10
-std
=
c99
-fsigned-char
-I
${
DIR_INC
}
-D
CODECODE_CI
${BIN_TARGET}
:
${OBJ}
$(CC)
$(OBJ)
-o
$@
${DIR_OBJ}/%.o
:
${DIR_SRC}/%.c
$(CC)
$(CFLAGS)
-c
$<
-o
$@
\ No newline at end of file
output1.txt
0 → 100644
浏览文件 @
69f5aec2
exp -> exp addop term
exp -> term
addop -> +
addop -> -
term -> term mulop factor
term -> factor
mulop -> *
factor -> ( exp )
factor -> number
The First Set:
First(exp) = { (, number }
First(addop) = { +, - }
First(term) = { (, number }
First(mulop) = { * }
First(factor) = { (, number }
sonar-project.properties
0 → 100644
浏览文件 @
69f5aec2
# required metadata
sonar.language
=
c
# path to source directories (required)
sonar.sources
=
./
# path to the build artifact
sonar.artifact.path
=
build/app
# paths to the reports
sonar.c.cppcheck.reportPath
=
./build/cppcheck-report.xml
#sonar.c.pclint.reportPath=./build/pclint-report.xml
#sonar.c.coverage.reportPath=./build/gcovr-report*.xml
#sonar.c.coverage.itReportPath=./build/gcovr-report*.xml
#sonar.c.coverage.overallReportPath=./build/gcovr-report*.xml
sonar.c.valgrind.reportPath
=
./build/valgrind-report.xml
sonar.c.vera.reportPath
=
./build/vera-report.xml
#sonar.c.rats.reportPath=./build/rats-report.xml
#sonar.c.xunit.reportPath=./build/xunit-report.xml
#sonar.c.drmemory.reportPath=./build/drmemory-logs/**/results.txt
sonar.c.includeDirectories
=
/usr/include/,/usr/include/linux,/usr/include/x86_64-linux-gnu/bits,/usr/include/x86_64-linux-gnu/sys,/usr/include/c++/5/tr1,./
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论