计算机科学 ›› 2012, Vol. 39 ›› Issue (Z11): 276-279.

• 数据库与数据挖掘 • 上一篇    下一篇

利用属性文法对程序中的副作用进行检测

张广梅,李景霞   

  1. (山东农业大学信息科学与工程学院 泰安271000);(安徽农业大学信息与计算机学院 合肥230036)
  • 出版日期:2018-11-16 发布日期:2018-11-16

Detection Side Effect in Expressions by Using Attributed Grammar

  • Online:2018-11-16 Published:2018-11-16

摘要: 表达式是程序的基本组成单位。在C/C++语言程序中,变量的自增/自减运算造成表达式或函数调用中存在副作用。表达式或函数调用中的副作用会造成程序运行结果的异常,甚至导致系统崩溃。首先对副作用的产生原因进行了分析,进而提出了利用属性文法对具有副作用的表达式或函数调用进行检测的方法,该方法可以有效地完成表达式或函数调用中的副作用的检测。

关键词: 表达式的副作用,函数调用副作用,词法规则,属性文法

Abstract: Expression is a basic unit of a program. There will be side effect while using increasing operator or decreasing operator in an expression or in a function call. If there is side effect in a program,the result of a program will be abnormal, even more, the computer system will be breakdown. In this paper, the reasons that cause the side effect in an expression arc analyzed and the lexical rule and attributed grammar that can detect the side effect in expression or in a function call are provided. By using the lexical analyzer that generated form the lexical rule and the parser analyzer generated from the attributed grammar, the expressions and function calls that contain side effect can be detected.

Key words: Side effect of an expression, Side effect of function call, Lexical rule, Attributed grammar

No related articles found!
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!