提交 a94a42b9 创建 作者: demo10's avatar demo10

modify

上级 564244cb
流水线 #844 已失败 于阶段
用时 34 秒
/Debug /Debug
/Release /Release
*.bak
\ No newline at end of file
image: "registry.cn-hangzhou.aliyuncs.com/engintime/ubuntu_16.04_program:latest"
stages:
- make
- code-analysis
- case1
- case2
- case3
- case4
- case5
- case6
- case7
- case8
variables:
TEACHERCHECK_REPO: "engintime/cp-lab/teachers-packet/Lab001.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
case2:
stage: case2
<<: *codecode-runner
script:
- make
- ./app < input2.txt > user_output2.txt
- diff output2.txt user_output2.txt -b -B -y -i --suppress-common-lines
- execscore.sh 60
only:
- master
teacher-check2:
stage: case2
<<: *codecode-runner
script:
- make
- ./app < input2.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/input2.txt input2.txt -b -B -y -i --suppress-common-lines
- diff template/output2.txt output2.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/input2.txt > user_output2.txt
- diff teacher_check/output2.txt user_output2.txt -b -B -y -i --suppress-common-lines
- extracase.sh
only:
- master
when: manual
allow_failure: true
case3:
stage: case3
<<: *codecode-runner
script:
- make
- ./app < input3.txt > user_output3.txt
- diff output3.txt user_output3.txt -b -B -y -i --suppress-common-lines
- execscore.sh 65
only:
- master
teacher-check3:
stage: case3
<<: *codecode-runner
script:
- make
- ./app < input3.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/input3.txt input3.txt -b -B -y -i --suppress-common-lines
- diff template/output3.txt output3.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/input3.txt > user_output3.txt
- diff teacher_check/output3.txt user_output3.txt -b -B -y -i --suppress-common-lines
- extracase.sh
only:
- master
when: manual
allow_failure: true
case4:
stage: case4
<<: *codecode-runner
script:
- make
- ./app < input4.txt > user_output4.txt
- diff output4.txt user_output4.txt -b -B -y -i --suppress-common-lines
- execscore.sh 70
only:
- master
teacher-check4:
stage: case4
<<: *codecode-runner
script:
- make
- ./app < input4.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/input4.txt input4.txt -b -B -y -i --suppress-common-lines
- diff template/output4.txt output4.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/input4.txt > user_output4.txt
- diff teacher_check/output4.txt user_output4.txt -b -B -y -i --suppress-common-lines
- extracase.sh
only:
- master
when: manual
allow_failure: true
case5:
stage: case5
<<: *codecode-runner
script:
- make
- ./app < input5.txt > user_output5.txt
- diff output5.txt user_output5.txt -b -B -y -i --suppress-common-lines
- execscore.sh 75
only:
- master
teacher-check5:
stage: case5
<<: *codecode-runner
script:
- make
- ./app < input5.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/input5.txt input5.txt -b -B -y -i --suppress-common-lines
- diff template/output5.txt output5.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/input5.txt > user_output5.txt
- diff teacher_check/output5.txt user_output5.txt -b -B -y -i --suppress-common-lines
- extracase.sh
only:
- master
when: manual
allow_failure: true
case6:
stage: case6
<<: *codecode-runner
script:
- make
- ./app < input6.txt > user_output6.txt
- diff output6.txt user_output6.txt -b -B -y -i --suppress-common-lines
- execscore.sh 80
only:
- master
teacher-check6:
stage: case6
<<: *codecode-runner
script:
- make
- ./app < input6.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/input6.txt input6.txt -b -B -y -i --suppress-common-lines
- diff template/output6.txt output6.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/input6.txt > user_output6.txt
- diff teacher_check/output6.txt user_output6.txt -b -B -y -i --suppress-common-lines
- extracase.sh
only:
- master
when: manual
allow_failure: true
case7:
stage: case7
<<: *codecode-runner
script:
- make
- ./app < input7.txt > user_output7.txt
- diff output7.txt user_output7.txt -b -B -y -i --suppress-common-lines
- execscore.sh 90
only:
- master
teacher-check7:
stage: case7
<<: *codecode-runner
script:
- make
- ./app < input7.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/input7.txt input7.txt -b -B -y -i --suppress-common-lines
- diff template/output7.txt output7.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/input7.txt > user_output7.txt
- diff teacher_check/output7.txt user_output7.txt -b -B -y -i --suppress-common-lines
- extracase.sh
only:
- master
when: manual
allow_failure: true
case8:
stage: case8
<<: *codecode-runner
script:
- make
- ./app < input8.txt > user_output8.txt
- diff output8.txt user_output8.txt -b -B -y -i --suppress-common-lines
- execscore.sh 100
only:
- master
teacher-check8:
stage: case8
<<: *codecode-runner
script:
- make
- ./app < input8.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/input8.txt input8.txt -b -B -y -i --suppress-common-lines
- diff template/output8.txt output8.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/input8.txt > user_output8.txt
- diff teacher_check/output8.txt user_output8.txt -b -B -y -i --suppress-common-lines
- extracase.sh
only:
- master
when: manual
allow_failure: true
\ No newline at end of file
#ifndef _NFAFRAGMENTSTACK_H_ #ifndef NFAFRAGMENTSTACK_H_
#define _NFAFRAGMENTSTACK_H_ #define NFAFRAGMENTSTACK_H_
// //
...@@ -46,5 +46,5 @@ int NFAFragmentStackEmpty(NFAFragmentStack* pS); ...@@ -46,5 +46,5 @@ int NFAFragmentStackEmpty(NFAFragmentStack* pS);
#endif /* _NFAFRAGMENTSTACK_H_ */ #endif /* NFAFRAGMENTSTACK_H_ */
#include "OutputResult.h"
int g_address[100] = {0};
int g_count = 0;
/*
功能:
输出 NFA。
参数:
result -- NFA 的开始状态指针。
*/
void OutputResult(NFAState* result)
{
if(result == NULL)
{
return;
}
int k = 0;
for(k = 0; k < 100; k++)
{
if((int)result == g_address[k])
{
return;
}
}
if(result != NULL)
{
g_address[g_count++] = (int)result;
if(result -> Next1 != NULL)
{
printf("%d(%d)",result->Name,result->AcceptFlag);
if(result->Transform == '$')
{
printf("->$->%d",result->Next1->Name);
}
else
{
printf("->%c->%d",result->Transform,result->Next1->Name);
}
printf("\n");
}
if(result -> Next2 != NULL)
{
printf("%d(%d)",result->Name,result->AcceptFlag);
if(result->Transform == '$')
{
printf("->$->%d",result->Next2->Name);
}
else
{
printf("->%c->%2d",result->Transform,result->Next2->Name);
}
printf("\n");
}
if(result -> Next1 != NULL)
{
NFAState* result1 = result -> Next1;
OutputResult(result1);
}
if(result -> Next2 != NULL)
{
NFAState* result2 = result -> Next2;
OutputResult(result2);
}
if(result->AcceptFlag == 1)
{
printf("%d(%d)\n",result->Name,result->AcceptFlag);
}
}
}
#ifndef OUTPUTRESULT_H_
#define OUTPUTRESULT_H_
#include "RegexpToNFA.h"
void OutputResult(NFAState* result);
#endif /* OUTPUTRESULT_H_ */
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
<Filter Name="ͷļ" Filter="h;hpp;hxx"> <Filter Name="ͷļ" Filter="h;hpp;hxx">
<File RelativePath=".\NFAFragmentStack.h"> <File RelativePath=".\NFAFragmentStack.h">
</File> </File>
<File RelativePath=".\OutputResult.h">
</File>
<File RelativePath=".\RegexpToNFA.h"> <File RelativePath=".\RegexpToNFA.h">
</File> </File>
<File RelativePath=".\RegexpToPost.h"> <File RelativePath=".\RegexpToPost.h">
...@@ -38,8 +40,44 @@ ...@@ -38,8 +40,44 @@
</File> </File>
<File RelativePath=".\NFAFragmentStack.c"> <File RelativePath=".\NFAFragmentStack.c">
</File> </File>
<File RelativePath=".\OutputResult.c">
</File>
<File RelativePath=".\RegexpToPost.c"> <File RelativePath=".\RegexpToPost.c">
</File> </File>
</Filter> </Filter>
<File RelativePath=".\input1.txt">
</File>
<File RelativePath=".\input2.txt">
</File>
<File RelativePath=".\input3.txt">
</File>
<File RelativePath=".\input4.txt">
</File>
<File RelativePath=".\input5.txt">
</File>
<File RelativePath=".\input6.txt">
</File>
<File RelativePath=".\input7.txt">
</File>
<File RelativePath=".\input8.txt">
</File>
<File RelativePath=".\makefile">
</File>
<File RelativePath=".\output1.txt">
</File>
<File RelativePath=".\output2.txt">
</File>
<File RelativePath=".\output3.txt">
</File>
<File RelativePath=".\output4.txt">
</File>
<File RelativePath=".\output5.txt">
</File>
<File RelativePath=".\output6.txt">
</File>
<File RelativePath=".\output7.txt">
</File>
<File RelativePath=".\output8.txt">
</File>
</Files> </Files>
</OSLProject> </OSLProject>
#ifndef _REGEXPTONFA_H_ #ifndef REGEXPTONFA_H_
#define _REGEXPTONFA_H_ #define REGEXPTONFA_H_
// //
...@@ -54,4 +54,4 @@ extern const char VoidTrans; ...@@ -54,4 +54,4 @@ extern const char VoidTrans;
extern char* regexp; extern char* regexp;
#endif /* _REGEXPTONFA_H_ */ #endif /* REGEXPTONFA_H_ */
#ifndef _REGEXPTOPOST_H_ #ifndef REGEXPTOPOST_H_
#define _REGEXPTOPOST_H_ #define REGEXPTOPOST_H_
// //
...@@ -28,4 +28,4 @@ ...@@ -28,4 +28,4 @@
char* re2post(char *re); char* re2post(char *re);
#endif /* _REGEXPTOPOST_H_ */ #endif /* REGEXPTOPOST_H_ */
ab
\ No newline at end of file
a|b
\ No newline at end of file
a*
\ No newline at end of file
a?
\ No newline at end of file
a+
\ No newline at end of file
a(a|1)*
\ No newline at end of file
(aa|b)*a(a|bb)*
\ No newline at end of file
(a|b)*a(a|b)?
\ No newline at end of file
#include "RegexpToNFA.h" #include "RegexpToNFA.h"
#include "RegexpToPost.h" #include "RegexpToPost.h"
#include "NFAFragmentStack.h" #include "NFAFragmentStack.h"
#include "OutputResult.h"
NFAFragmentStack FragmentStack; // 栈。用于储存 NFA 片段 NFAFragmentStack FragmentStack; // 栈。用于储存 NFA 片段
...@@ -14,11 +15,18 @@ char* regexp = "ab"; // 例 1 ...@@ -14,11 +15,18 @@ char* regexp = "ab"; // 例 1
// char* regexp = "(aa|b)*a(a|bb)*";// 例 7 // char* regexp = "(aa|b)*a(a|bb)*";// 例 7
// char* regexp = "(a|b)*a(a|b)?"; // 例 8 // char* regexp = "(a|b)*a(a|b)?"; // 例 8
char regexp_ci[256];
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
char *post; char *post;
NFAState *start; NFAState *start;
#ifdef CODECODE_CI
scanf("%s", regexp_ci);
regexp = regexp_ci;
#endif
// //
// 初始化栈 // 初始化栈
// //
...@@ -34,6 +42,8 @@ int main(int argc, char **argv) ...@@ -34,6 +42,8 @@ int main(int argc, char **argv)
// //
start = post2nfa(post); start = post2nfa(post);
OutputResult(start);
return 0; return 0;
} }
......
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
1(0)->a->2
2(0)->$->3
3(0)->b->4
4(1)
\ No newline at end of file
5(0)->$->1
5(0)->$->3
1(0)->a->2
2(0)->$->6
6(1)
3(0)->b->4
4(0)->$->6
\ No newline at end of file
3(0)->$->1
3(0)->$->4
1(0)->a->2
2(0)->$->1
2(0)->$->4
4(1)
\ No newline at end of file
3(0)->$->1
3(0)->$->4
1(0)->a->2
2(0)->$->4
4(1)
\ No newline at end of file
1(0)->a->2
2(0)->$->3
3(1)->$->1
3(1)
\ No newline at end of file
1(0)->a->2
2(0)->$->9
9(0)->$->7
9(0)->$->10
7(0)->$->3
7(0)->$->5
3(0)->a->4
4(0)->$->8
8(0)->$->7
8(0)->$->10
10(1)
5(0)->1->6
6(0)->$->8
\ No newline at end of file
9(0)->$->7
9(0)->$->10
7(0)->$->1
7(0)->$->5
1(0)->a->2
2(0)->$->3
3(0)->a->4
4(0)->$->8
8(0)->$->7
8(0)->$->10
10(0)->$->11
11(0)->a->12
12(0)->$->21
21(0)->$->19
21(0)->$->22
19(0)->$->13
19(0)->$->15
13(0)->a->14
14(0)->$->20
20(0)->$->19
20(0)->$->22
22(1)
15(0)->b->16
16(0)->$->17
17(0)->b->18
18(0)->$->20
5(0)->b->6
6(0)->$->8
\ No newline at end of file
7(0)->$->5
7(0)->$->8
5(0)->$->1
5(0)->$->3
1(0)->a->2
2(0)->$->6
6(0)->$->5
6(0)->$->8
8(0)->$->9
9(0)->a->10
10(0)->$->17
17(0)->$->15
17(0)->$->18
15(0)->$->11
15(0)->$->13
11(0)->a->12
12(0)->$->16
16(0)->$->18
18(1)
13(0)->b->14
14(0)->$->16
3(0)->b->4
4(0)->$->6
\ No newline at end of file
# 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论