1.3.3 程序理解
规模庞大的软件系统是难于理解和维护的.目前已经有了许多不同的方法和自动化工具,它们或者在体系结构层,或者在代码层,建立存在系统的概念模型,帮助人们对系统进行理解和维护.信息流分析技术可以给用户提供分析程序的有关信息,从而有助于用户对程序的理解.
1.3.4 程序分片
程序分片工具是基于代码分析的,它允许将程序分解成片,用户能够从中提取信息并且使维护中改变代码所带来的影响变得更加直观.利用信息流分析进行分片是程序分片技术的一个重要分支,值得一提的是最早的分片算法就是WEISER的以控制流图作为中间表示的基于数据流关系的分片算法.
1.4 模型语言
我们的分析对象是一种小型的面向对象程序设计语言SOOL,它是从C++简化和修改得来.我们保留程序的主干,即保留顺序,分支,循环语句以及简单的面向对象机制,即类,继承,发消息.考虑到实现的方便,SOOL只保留了基本数据类型和基本算术运算.
下面我们给出SOOL语言的语法描述:
program:
(include_statement)* (class_sect)* main_program;
include_statement:
'#' INCLUDE head_file;
head_file:
'';
//MAIN
main_program:
return_value_type MAIN '(' ')' statement_sect;
return_value_type:
basic_data_type|VOID;
basic_data_type:
INT|BOOL;
statement_sect:
'{' (declare_sect) stm_sect '}';
declare_sect:
type varible ';' ( type varible ';')*;
type:
basic_data_type|class_type;
class_type:
class_name;
class_name:
IDENTIFIER;
varible:
IDENTIFIER|IDENTIFIER '[' NUMBER ']';
stm_sect:
statement|statement stm_sect;
statement:
assignment_statement
|if_statement
|while_statement
|io_statement
|class_function_call_statement
|skip_statement;
//CLASS
class_sect:
CLASS class_name ( ':' PUBLIC class_name)
'{' (access_control_operator ':' construct_function class_declare_sequence (class_declare_sequence)* )* '}';
construct_function:
class_name '(' ')';
access_control_operator:
PUBLIC|PROTECTED|PRIVATE;
class_declare_sequence:
varible_declare|function_declare;
varible_declare:
basic_data_type varible;
function_declare:
return_value_type function_name '(' parameter_table ')'
'{' basic_statement_sect (RETURN varible ';') '}' ;
basic_statement_sect:
'{' (basic_declare_sect) basic_stm_sect '}';
basic_declare_sect:
basic_data_type varible ';' ( basic_data_type varible ';')*;
basic_stm_sect:
'{' basic_statement '}'|'{' basic_statement basic_stm_sect '}';
basic_statement:
assignment_statement
|if_statement
|while_statement
|io_statement
|skip_statement
|new_statement
|delete_statement;
function_name:
IDENTIFIER;
parameter_table:
varible;
//EXPRESSION
sign:
'+'|'-';
expression:
simple_expression |relationship_expression|bool_expression
|IDENTIFIER;
relationship_expression:
expression relationship_operator expression;
relationship_operator:
EQUAL|NOT_EQUAL|''
|LESS_EQUAL|GREAT_EQUAL;
bool_expression:
(expression) bool_operator expression;
bool_operator:
AND|OR|NOT;
simple_expression:
(sign) item (add_minus_operator item)*;
add_minus_operator:
'+'|'-';
item:
factor (plus_div_operator factor)*;
plus_div_operator:
'*'|'/';
factor:
varible|NUMBER|'(' expression ')' | class_function_call;
class_function_call:
class_name '.' function_denominate ;
function_denominate:
function_name '(' (real_parameter_table) ')';
real_parameter_table:
real_parameter (',' real_parameter)*;
real_parameter:
NUMBER|TRUE|FALSE|varible;
//STATEMENT
assignment_statement:
varible '=' expression ';' ;
skip_statement:
';';
if_statement:
IF '(' expression ')' basic_stm_sect ELSE basic_stm_sect;
while_statement:
WHILE '(' expression ')' basic_stm_sect;
io_statement:
CIN '(' IDENTIFIER ( ',' IDENTIFIER )* ')'';'
|COUT '(' IDENTIFIER ( ',' IDENTIFIER)* ')' ';';
class_function_call_statement:
class_name '.' function_denominate ';';
new_statement:
NEW class_name ';';
delete_statement:
DELETE class_name ';';
文章来源于领测软件测试网 https://www.ltesting.net/