Constant folding within an expression by semantic attributes

  • Authors:
  • Kuo-Chung Tai

  • Affiliations:
  • Dept. of Computer Science, North Carolina State University, P.O. Box 5972, Raleigh, NC 27650, U.S.A.

  • Venue:
  • Computer Languages
  • Year:
  • 1979

Quantified Score

Hi-index 0.00

Visualization

Abstract

A new type of constant folding is presented, which is to replace an expression containing constants with an equivalent expression with fewer constants. The process of constant folding within an expression is described using attribute grammars. Since the attributes defined in the semantic rules are all synthesized, the evaluation of attributes of an expression for constant folding can be completed either in a single left-to-right pass of the parse tree of the expression or in conjunction with one-pass syntax analysis of the expression.