Integrating Generative and Composite Techniques to Construct
Flow-based Tools
: 88-2213-E-009-015 : 87 5 1 88 7 31 : : !"#$: fjwang@csie.nctu.edu.tw %&'()* +*,-./(0[1] (Attribute Grammars – AGs) 12#345678 9:;< = >? @AB CD E FG56789H,-I=J@KL>1 MN>>89HOPG,-HQHRS TU./(0VWXYZ[H\/,=] 2#34 89 R^_ `a' WS b GUIcJHdeG+'UfghH ij MVS[3] (Model-View-Shape)> k 1 . / ( 0 H l m OOAG (Object-Oriented AG)[5][6] ,-nopq rsHd e: <t= ?@ AB C FGuQh@vnwxUfy,-89< tz6{>?|}F=]%{> ~G>?|}FIE><t f^ H>XY>? I= OOAG |}>V HnR>H'nh zIHG : program generator, attribute grammar, program analysis, flow-based tools
Abstract
The project presents an approach to construct language-based tools by
combining attribute grammars and object-oriented technology. The combination of AGs and OO exemplifies the integration of generative and compositional programming techniques. The approach, called OOAG, is presented to effectively construct language-based tools that deal with fine-grained language semantics as well as a mass of graphics-drawing activities. It consists of two inter-related parts: a model-view-shape class framework and an AG++, an object-oriented extension to traditional AGs, is intended to preserve both advantages introduced by respective OO and AG models, such as rapid prototyping, reusability, extensibility, incrementality, and applicability. So far, a flow-based editor associated with two flow-analyzer prototypes, DU/UD tools and a program slicer, have been implemented using OOAG on Windows programming environment. The flow-based editor can be used to construct programs by specifying the associated flow information in a visual way, while (incremental) flow analyzers incorporated into the editor can help analyze incomplete program fragments to
2
locate and inform the user of possible errors or anomalies during programming.
¡&¢1QH R£¤<tH¥'n¦§¨f© ª«¬:XY£¤H@\/G®Rb ¯°n¦§±fr>r²H?«n® ³´?&µ?n¶·¸¹«n=] E-R «ºn=»¼r7½4 (facet) :¬ ¾>¿HGUf5À«¬Hde C%ÁI=ÂE¦§ÃÄoÅÆÇH £¤nyde±ÈÉ^ FH iÊËÌG Ín¼ÎÏÐ%Ñ=?@+HF[2] Á%ÒÓ¥ÔÕÖH×ØGÙyÏÚ 5ÛFÜÝD=%ÑqÞH0ßnà y0ß=qáH>Ìâ<tH n=ã-äHi+;<zyÛ FGåæCçn*¾iyQèoéV Wnꦧ<5ÛFëqÛìH\ eníÁ5ÀF(1)ëÁîï(0ð57 µñÚ>\/H|}nòÕ(2) óñjôu^_õG îï\e%n¦§IUfö¯÷øZù: XY(0ðHµñÚúän=](0ð õHZ[|}GS\e¡nSh6 H û ü ñ j ý Á % Ñ = MVS (Model-View-Shape) þÚ@ABb zH flow-based FnyþÚ-+Hûü'\e¡HG n¼ flow-based FH<tx OnZ[|}½H>Uf á 0néUf÷øKL>n± i>éVWÄ1ÅÆHGÙ Á%{Z[|}HJZ0ð õª7éò·Hen|}Hµ SHeni%{Z[ |}JH>*|Rr{ C++ ZùHÛ0 (class methods) nrs ÐHZ[|}Jní>Å ÆH!e:æn"#rsi%$MnêQ hH0%±ó+:"#rs ÐH >&Rò%{ C++ ÛnöÃÅ ÆH'(GÙy¦§)*+./(0 ÷øZù:,-g=.H C++ Z [|}>n=/:sKL>H0 únÙ@./(0÷øI=órs ÐHZ [| }J Ré òH $M n=1/:VWÄ1ÅÆH0úG 2ùCn+ûüHQHRS3 RÏÚ flow-based FH'nà Z[|}JH>I= >sKLG RÏÚ flow-based FH'nq ^_O4|H5nI=6 MVS 7H>k1$¾iG 6÷øZùXY flow-based F H>89n=Ä:=; flow-based FH>89<=Ä1ÅÆH G =&ñj1>ß R+Hûü'n¦§wx?@à ®AòÕUf,->1MN>89:Ï Ú=>?@ABH><tFG2# 3489R>Bf=]«C D½ tzEdFH\/G./(0R>Z ùHZ[ XY =] >s K L ½nqEG÷/1>(incremental)| }H0úG Rûü'n¦§f2#3489: XY./(0Z0ð¥'HenoR. /(0HZ0ð'H©b¨f IeÇ,(remote access)H5:XY Z[oH©FqòÛ\JH./K' (aggregate)L:nòÕZ[|}H MG5Àîï./(0HNOn2 ÃZ [XYHXYJnàZ[PYQR2
3 S ò Õ 1 T Ã Z [ | } d (optimization)HI/G S MVS ^ >knSUwxó >?FH UI cJVNi2#3 4 H C > R 1 2 # 3 4 . / ( 0 (OOAG),-HÕWnOEöHþÚ ÓV/1Bf/G «%OHFÁ%{QX define-use H|}Fnîï a=c 5{PYn6
OOAGHZ[XYnI=Yz use a HP
YnZý e>f&e=a&d=a+e&f=a ºPYn o6 MVS H>knó5ÀPY Óï"HeèO(highlight)z:G «%&KLH DU FCP[½ «¡OHFÁ%{2WH>~ nîï a = b PYG4(forward)H >~n OOAG HZ[÷øXY (\]^_)nó a > 1&c = a&a = a+1 º ¨fuQX a HPYYz:no MVS >kó5ÀPYï"He èO(highlight)z:G «¡&KLH>~P[½ `&ij1sa +HijwxbiÃ,->1 KL>5 67 >8 9,- Hc de fnogEfSKL=?@ABC >FG yûühÃ÷zy6789,-Õ H£¤þÚ1biCno=2 H!OP®A¨fy,-89G¤ õnûüñj1gbjHkbÓl-n ¼ñj1>ß'OHPn¦§I=R mKL>1,->67>89I=, -L:nKL=>?@ABH>DE FG +C4|ûüij[4][7][8]w< ¬SÓnoC±p1qG r&\s(t
1. Alblas H., “Introduction to Attribute Grammars,” in Lecture Notes in Computer Science - Attribute Grammars, Applications and Systems, Alblas, H. and Melichar, B. (eds.), Springer-Verlag, 1991, pp. 1-15
2. Arefi, F. et al., “Automatically generating visual syntax-directed editors,” Communications of the ACM, Vol. 33, No. 3, March 1990, pp. 349-360.
4
“Constructing flow-based editors with a model-view-shape architecture,” Proceedings of the International Computer Symposium (ICS’96), Taiwan, 1996, pp. 391-397.
4. Hu, C.-H. And Wang, F.-J., “Constructing an Integrated Visual
Programming Environment,” Software – Practice and Experience,
1998.
5. Wu, P. C., Wang, F. J., and Yang J. T., “A Semantic Specification Language for Compiler Construction,” The Proceedings of the National Science Council, Vol. 20, No. 1, pp. 23—41, 1996
6. Yang, J. -T. And Wang. F. -J., “A Specification Language for Compiler
Construction Based on Attribute
Grammar,” Proceedings of the
International Computer Symposium (ICS ’96), Taiwan, pp.398-405.
7. Yang, J.-T., Hu, C.-H., Wang, F.-J., and Chu, C.-C. William, “Constructing a Toolset for Software Maintenance with
OOAG,” Asia Pacific Software
Engineering Conference, December 1998.
8. Yang, J.-T., Hu, C.-H., Wang, F.-J., and Chu, C.-C. William, "Constructing Flow-Based Tools with Generative and Compositional Techniques," accepted by International Journal of Software Engineering and Knowledge Engineering.
Appendix: ¨f OOAG :>~ (uvzr class H prototype wx4|)
%SEMANTICS
CLASS Statement-List INHERIT Tree-Node PROTOCOL
VOID GetBranchExpressionsBackwardUp(Tree-Node* from, NODELIST_REF marked_nodes) { ... } VOID GetBranchExpressionsBackwardDown(Tree-Node* from, NODELIST_REF marked_nodes) { ... }; END
//--- CLASS Expression INHERIT Tree-Node PROTOCOL
VOID ComputeBackwardSlice(STRING var_name, NODELIST_REF marked_nodes) { ... }
VOID GetBranchExpressionsBackwardUp(Tree-Node* from, NODELIST_REF marked_nodes) { ... }; END
//--- CLASS Assignment-Stmnt INHERIT Statement PROTOCOL
VOID ComputeForwardSlice(STRING var_name, NODELIST_REF marked_nodes) { ... }
VOID ComputeBackwardSlice(String variableName, StatementModel *pFrom, ModelList *pMarkedModels) { ... } VOID GetBranchExpressionsBackwardUp(STRING var_name, NODELIST_REF marked_nodes) { ... }
END
//--- CLASS If-Then-Else-Stmnt INHERIT Statement PROTOCOL
VOID GetBranchExpressionsBackwardUp(Tree-Node* from, NODELIST_REF marked_nodes) { ... } VOID GetBranchExpressionsBackwardDown(Tree-Node* from, NODELIST_REF marked_nodes) { ... } END
//--- CLASS While-Stmnt INHERIT Statement PROTOCOL
VOID GetBranchExpressionsBackwardUp(Tree-Node* from, NODELIST_REF marked_nodes) { ... } VOID GetBranchExpressionsBackwardDown(Tree-Node* from, NODELIST_REF marked_nodes) { ... } END
//---
CLASS Function, Compound-Stmnt, If-Then-Stmnt, Do-Stmnt, Statement, … ……