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

modify

上级 5110454a
流水线 #845 已失败 于阶段
用时 34 秒
/Debug /Debug
/Release /Release
*.bak
image: "registry.cn-hangzhou.aliyuncs.com/engintime/ubuntu_16.04_program:latest"
stages:
- make
- code-analysis
- case1
- case2
- case3
variables:
TEACHERCHECK_REPO: "engintime/cp-lab/teachers-packet/Lab002.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 60
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 70
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 100
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
\ No newline at end of file
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
</File> </File>
<File RelativePath=".\NFAToDFA.h"> <File RelativePath=".\NFAToDFA.h">
</File> </File>
<File RelativePath=".\OutputResult.h">
</File>
<File RelativePath=".\PostToNFA.h"> <File RelativePath=".\PostToNFA.h">
</File> </File>
<File RelativePath=".\RegexpToPost.h"> <File RelativePath=".\RegexpToPost.h">
...@@ -44,10 +46,26 @@ ...@@ -44,10 +46,26 @@
</File> </File>
<File RelativePath=".\NFAStateStack.c"> <File RelativePath=".\NFAStateStack.c">
</File> </File>
<File RelativePath=".\OutputResult.c">
</File>
<File RelativePath=".\PostToNFA.c"> <File RelativePath=".\PostToNFA.c">
</File> </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=".\makefile">
</File>
<File RelativePath=".\output1.txt">
</File>
<File RelativePath=".\output2.txt">
</File>
<File RelativePath=".\output3.txt">
</File>
</Files> </Files>
</OSLProject> </OSLProject>
#include "OutputResult.h"
/*
功能:
输出 DFA 邻接表。
参数:
dfa -- DFA 指针。
*/
void OutputResult(DFA* dfa)
{
int i =0,j = 0;
for(j = 0; j < dfa->length;j++)
{
printf("%d ", j);
int count = dfa->DFAlist[j]->NFAStateCount;
int flag = 0;
for(i = 0; i < count; i++)
{
if(dfa->DFAlist[j]->NFAlist[i]->AcceptFlag ==1)
{
flag = 1;
break;
}
}
for(i = 0; i < count; i++)
{
if(count == 1)
{
printf("%d->", dfa->DFAlist[j]->NFAlist[i]->Name);
}
else
{
if(i == 0)
{
if(flag == 1)
{
printf("[%d ", dfa->DFAlist[j]->NFAlist[i]->Name);
}
else
{
printf("%d ", dfa->DFAlist[j]->NFAlist[i]->Name);
}
}
else if(i == count - 1)
{
if(flag == 1)
{
printf("%d]->", dfa->DFAlist[j]->NFAlist[i]->Name);
}
else
{
printf("%d->", dfa->DFAlist[j]->NFAlist[i]->Name);
}
}
else
{
printf("%d ", dfa->DFAlist[j]->NFAlist[i]->Name);
}
}
}
Transform* curTran = NULL;
curTran = dfa->DFAlist[j]->firstTran;
while(curTran != NULL)
{
for(i = 0; i < curTran->NFAStateCount; i++)
{
if(curTran->NFAStateCount == 1)
{
printf("%d->", curTran->NFAlist[i]->Name);
}
else
{
if(i == 0)
{
printf("%c(%d,", curTran->TransformChar,curTran->NFAlist[i]->Name);
}
else if(i == curTran->NFAStateCount - 1)
{
printf("%d)%d->", curTran->NFAlist[i]->Name, curTran->DFAStateIndex);
}
else
{
printf("%d,", curTran->NFAlist[i]->Name);
}
}
}
curTran = curTran->NextTrans;
}
printf("NULL\n");
}
}
#ifndef _OUTPUTRESULT_H_
#define _OUTPUTRESULT_H_
#include "NFAToDFA.h"
void OutputResult(DFA* dfa);
#endif /* _OUTPUTRESULT_H_ */
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
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "PostToNFA.h" #include "PostToNFA.h"
#include "NFAStateStack.h" #include "NFAStateStack.h"
#include "NFAFragmentStack.h" #include "NFAFragmentStack.h"
#include "OutputResult.h"
NFAFragmentStack FragmentStack; // 栈。用于储存 NFA 片段 NFAFragmentStack FragmentStack; // 栈。用于储存 NFA 片段
NFAStateStack StateStack; // 栈。用于储存 NFA 状态 NFAStateStack StateStack; // 栈。用于储存 NFA 状态
...@@ -14,6 +15,8 @@ char* regexp = "a(a|1)*"; // 例 1 ...@@ -14,6 +15,8 @@ char* regexp = "a(a|1)*"; // 例 1
// char* regexp = "(aa|b)*a(a|bb)*"; // 例 2 // char* regexp = "(aa|b)*a(a|bb)*"; // 例 2
// char* regexp = "(a|b)*a(a|b)?"; // 例 3 // char* regexp = "(a|b)*a(a|b)?"; // 例 3
char regexp_ci[256];
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
char *post; char *post;
...@@ -25,6 +28,11 @@ int main(int argc, char **argv) ...@@ -25,6 +28,11 @@ int main(int argc, char **argv)
// //
InitNFAFragmentStack(&FragmentStack); InitNFAFragmentStack(&FragmentStack);
#ifdef CODECODE_CI
scanf("%s", regexp_ci);
regexp = regexp_ci;
#endif
// //
// 调用 re2post 函数将正则表达式字符串转换成解析树的后序遍历序列 // 调用 re2post 函数将正则表达式字符串转换成解析树的后序遍历序列
// //
...@@ -35,6 +43,8 @@ int main(int argc, char **argv) ...@@ -35,6 +43,8 @@ int main(int argc, char **argv)
// //
dfa = post2dfa(dfa, post); dfa = post2dfa(dfa, post);
OutputResult(dfa);
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
0 1->a(2,9,7,3,5,10)1->NULL
1 [2 9 7 3 5 10]->1(6,8,7,3,5,10)2->a(4,8,7,3,5,10)3->NULL
2 [6 8 7 3 5 10]->1(6,8,7,3,5,10)2->a(4,8,7,3,5,10)3->NULL
3 [4 8 7 3 5 10]->1(6,8,7,3,5,10)2->a(4,8,7,3,5,10)3->NULL
0 9 7 1 5 10 11->b(6,8,7,1,5,10,11)1->a(2,3,12,21,19,13,15,22)2->NULL
1 6 8 7 1 5 10 11->b(6,8,7,1,5,10,11)1->a(2,3,12,21,19,13,15,22)2->NULL
2 [2 3 12 21 19 13 15 22]->b(16,17)3->a(4,8,7,1,5,10,11,14,20,19,13,15,22)4->NULL
3 16 17->b(18,20,19,13,15,22)5->NULL
4 [4 8 7 1 5 10 11 14 20 19 13 15 22]->b(6,8,7,1,5,10,11,16,17)6->a(2,3,12,21,19,13,15,22,14,20)7->NULL
5 [18 20 19 13 15 22]->b(16,17)3->a(14,20,19,13,15,22)4->NULL
6 6 8 7 1 5 10 11 16 17->b(6,8,7,1,5,10,11,18,20,19,13,15,22)8->a(2,3,12,21,19,13,15,22)2->NULL
7 [2 3 12 21 19 13 15 22 14 20]->b(16,17)3->a(4,8,7,1,5,10,11,14,20,19,13,15,22)4->NULL
8 [6 8 7 1 5 10 11 18 20 19 13 15 22]->b(6,8,7,1,5,10,11,16,17)6->a(2,3,12,21,19,13,15,22,14,20)7->NULL
0 7 5 1 3 8 9->b(4,6,5,1,3,8,9)1->a(2,6,5,1,3,8,9,10,17,15,11,13,18)2->NULL
1 4 6 5 1 3 8 9->b(4,6,5,1,3,8,9)1->a(2,6,5,1,3,8,9,10,17,15,11,13,18)2->NULL
2 [2 6 5 1 3 8 9 10 17 15 11 13 18]->b(4,6,5,1,3,8,9,14,16,18)3->a(2,6,5,1,3,8,9,10,17,15,11,13,18,12,16)4->NULL
3 [4 6 5 1 3 8 9 14 16 18]->b(4,6,5,1,3,8,9)1->a(2,6,5,1,3,8,9,10,17,15,11,13,18)2->NULL
4 [2 6 5 1 3 8 9 10 17 15 11 13 18 12 16]->b(4,6,5,1,3,8,9,14,16,18)3->a(2,6,5,1,3,8,9,10,17,15,11,13,18,12,16)4->NULL
# 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论