You are on page 1of 8

Transactions on Computer Science and Technology

June 2014, Volume 3, Issue 2, PP.73-80

The Design and Implementation of


Programming Language Specification Inspection
Model
C language specification
Xinyuan Niu, Cong Ma#
Computer School, Beijing Information Science & Technology University, Beijing 100101, China
#

Email: niuxinyuan@bistu.edu.cn

Abstract
By studying programming language specification, a programming language specification inspection model is designed. This model
is used to inspect programming language code specification for improving code maintenance efficiency. Automatic walkthroughs
is implemented for the software maintenance process. Based on C programming language Regular Expression, The program is
designed and implemented for inspection and modification for standard C language specification, to achieve the automatic code
review. Lexical analysis is used the programming language regex construct, to complete various types of non-standard code
matching regular expression for the C program identifier in header files, source code syntax and statements of lines of code.to
finish the standardized C code inspection. The system is done by using Perl scripting language. The model and its implementation
can be applied to automatic software maintenance process.
Keywords: Automatic Software Maintenance, Specification Inspection Model, Code Walkthrough, Per, C Language
Programming Specifications

*
C
1, 21
100101

CCC

CPerl

PerlC

40%-80%

IDHT20130519
PXM2013_014224_000042PXM2014_014224_000067
- 73 http://www.ivypub.org/cst

1.

2. bugbug
bug
3.

4.

5.

1.1
C

34

1. C

2. C
Microsoft Windows 7 CorporationUltraEdit
PerlActivePerl

1.2
C
CPerl
C

1.2.1

- 74 http://www.ivypub.org/cst

token<tokenname , attribute-value>
1.

2.

3.

1.2.2

Perl

rs
L(r)L(s)
1. (r)|(s)L(r)L(s)
2. (r)(s)L(r)L(s)
3. (r)*(L (r)) *
4. (r)L(r)

Perl
1 if (($code =~ m{a}) && ($code =~ m{b}))
&&$code =~ m{a}$code
a$code =~ m{b}$codeb
$codeab10
2[a-z]+

1.2.3

Kleene2050Kleene

1. + r
+ *
= | =r = rKleene *
2. ? r? r|
L(r?) = L(r)|{} ? + *
3.a1|a2|| [a1a2]
a1a2
- 75 http://www.ivypub.org/cst

a1[abc]a|b|c
[a-z]a|b||z
1.2.4

Perlif ($code =~ m{abc})=~


m$codeabc10$code
=~ s{abc}{x}=~ s$codeabcx$codeabc
$code

2.1
CC4

4
1.
2.
3.

4.

1-4C
C

2.2
Perl
CC

.
Perl

Perl
1.Perl
$$code
2.printsplit
grepforeachsub
&

2.3

2.3.1

- 76 http://www.ivypub.org/cst

#ifndef _H
#define_H

#endif
2.3.2

1
1

2.3.3

UpdataHeadFilePara()

$filename,
$result

CheckHeadFilePara()

$filename

$first_line_flag
$second_line_flag
$first_line
$second_line
$last_line
$define_file_name
$first_line
$second_line
$last_line
$unregu_flag

2 1 UpdataHeadFilePara($filename, $result) 2
CheckHeadFilePara($filename)1$filename2
$result1
2
$unregu_flag
1
2.3.4
1

1
$first_line_flag
$second_line_flag

#
#2

$first_line

$second_line

#2

$last_line

2
$define_file_name
2

1$first_line_flag1$first_line

$second_line_flag1$second_line
$last_line$last_line
- 77 http://www.ivypub.org/cst


2$define_file_name$first_line
$second_line$last_line
$unregu_flag1
3

UpdataHeadFilePara()1

$first_line_flag

$first_line

$first_line_flag

$second_line_flag

$first_line_flag

$second_line

$second_line_flag

$last_line

UpdataHeadFilePara()

3.1
C
C
C
2CC
C2
- 78 http://www.ivypub.org/cst

3.2
C3

3
C

3.3
3.3.1

22

5
- 79 http://www.ivypub.org/cst

Perl
C
38CC

CC

REFERENCES
[1] Randal L.Schwartz.Perl Language Introduction [M].fifth.Nanjing: Southeast University Press, 2009
[2] Guo youqiang.C Language Programming [M].Beijing: Tsinghua University Press, 2009
[3] Brian W.Kernighan, Dennis M.Ritchie. C Language Programming [M].second.Beijing: Machinery Industry Press, 2011
[4] Chijian, Liu yanfei. C Language Collection [M].Beijing: Electronic Industry Press, 2009
[5] Andrew Koenig.C Traps and defects [M].Beijing: People Post Press, 2008
[6] Zou zhizi. Batch Processing Command Application in Windows [M]. Beijing: People Post Press, 2008
[7] Ron Patton. Software Testing [M]. second.Beijing: Machinery Industry Press, 2006:13-127
[8] 1.0.1-2009, C language programming specifications [S]
[9] Huawei-2010, C language programming specifications [S]
[10] Baidu Encyclopedia.UltraEdit Introduction[EB/OL].[2012-1-10].http://baike.baidu.com/view/3184.htm
[11] Alfred V.Aho.Compilers[M].Second Edition.beijing: China Machine Press, 2011
[12] chromatic.Modern Perl[M].Nether land: Onyx Neon Press, 2010

19651986

Email: niuxinyuan@bistu.edu.cn
- 80 http://www.ivypub.org/cst