An attribute grammar with common attributes and its evaluator in prolog
暂无分享,去创建一个
Attribute grammars (AGs) have been championed in the literature as a potential basis for language-analysis systems. However, there is a well-known copy rule problem, that is, 50–70 percent of semantic rules within an AG are copy rules. In this paper, we introduce common attributes into AGs. Common attributes provide a solution to the copy rule problem, reducing copy rules to only about 10 percent. The semantics of common attributes are defined by translating them into synthesized attributes and inherited attributes. The value of these derived attributes are copied from left to right if not defined explicitly. Based on the extended attribute grammar, we have developed a specification language, named PANDA. A prototype system has been constructed to generate Prolog programs from PANDA programs automatically. Our current system is limited to process PANDA programs which belong to L-attribute grammar (L-AGs), a subclass of AGs. For a givn grammar G, a necessary and sufficient condition is used to determine whether or not G is an L-AG. Some optimization strategies are applied to generate faster-running Prolog programs.
[1] David H. D. Warren,et al. Definite Clause Grammars for Language Analysis - A Survey of the Formalism and a Comparison with Augmented Transition Networks , 1980, Artif. Intell..
[2] Rodney Farrow,et al. Generating a Production compiler from an Attribute Grammar , 1984, IEEE Software.
[3] Gregor von Bochmann,et al. Semantic evaluation from left to right , 1976, CACM.