1 / 31

Grammar-Driven Generation of Domain-Specific Language Testing Tools

Grammar-Driven Generation of Domain-Specific Language Testing Tools. Hui Wu. http://www.cis.uab.edu/wuh. February 08 2006. Motivation of Proposed Research. Test Engine. Editor. Compiler. Domain Experts program at DSL level. Visualizer. Domain Experts deal with GPL. Debugger. Profiler.

naeva
Télécharger la présentation

Grammar-Driven Generation of Domain-Specific Language Testing Tools

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Grammar-Driven Generation ofDomain-Specific Language Testing Tools Hui Wu http://www.cis.uab.edu/wuh February 08 2006

  2. Motivation of Proposed Research Test Engine Editor Compiler Domain Experts program at DSL level Visualizer Domain Experts deal with GPL Debugger Profiler DSL translated into General Purpose Language (GPL) Integrated Development Environment (IDE) Domain Experts deal with DSL

  3. A Horizontal Direction: Debuggers for Different Types of DSLs • Imperative DSL: Centered around assignment expressions or control flow statements • Robot Language … 17 Down: 18 position(+0,-1) 19 Down: F_end 20 M_end 21 Init position(0,0) 22 Call left 23 Call down 24 Call knight 25 Set position(5,6) 26 Call up 27 Call right 28 Print position …

  4. A Horizontal Direction: Debuggers for Different Types of DSLs • Declarative DSL: declares the relationship between inputs and outputs. • Feature Definition Language (FDL) 1 Car : all (carbody, Transmission, Engine, Horsepower, opt(pullsTrailer)) 2 Transmission : oneof(automatic, manual) 3 Engine : moreof (electric, gasoline) 4 Horsepower : oneof (lowPower, mediumPower, highPower) 5 include pullsTrailer 6 pullsTrailer requires highPower

  5. A Horizontal Direction: • Hybrid DSL: embedded GPL code within the DSL description … Random: { String answer; int max; JOptionPane myGUI = new JOptionPane(); Random rand = new Random(); answer = myGUI.showInputDialog("Generate a random number for X-axis between 1 and "); max = Integer.parseInt(answer); x = rand.nextInt(max); answer = myGUI.showInputDialog("Generate a random number for Y-axis between 1 and "); max = Integer.parseInt(answer); y = rand.nextInt(max); myGUI.showMessageDialog(null, "Generated Position(" + x + "," + y+ ")"); } Random: F_end M_end Init position(0,0) Call left Call down Call knight Set position(5,6) Call up Call random Call right Print position …

  6. Mismatch Between Abstraction Levels Generated Java Parser Code ANTLR Grammar …. public final void commands() throws RecognitionException, TokenStreamException { try { // for error handling { switch ( LA(1)) { case CALL: case INIT: case SET: case PRINT: { command(); commands(); break; } case END: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); … public final void function_name() throws RecognitionException, TokenStreamException { try { // for error handling { switch ( LA(1)) { case RIGHT: { match(RIGHT); fileio.print(" //move right"); fileio.print(" move_right();"); fileio.print(" "); break; } case LEFT: { match(LEFT); sllinenumber=dsllinenumber+1; fileio.print(" //move left"); fileio.print(" move_left();"); fileio.print(" "); break; } … …. commands : ( c:command cs:commands | ) ; command : ( RIGHT { fileio.print("//move right"); fileio.print("x=x+1;"); fileio.print("time=time+1;"); fileio.print(" "); } |LEFT { fileio.print("//move left"); fileio.print("x=x-1;"); fileio.print("time=time+1;"); fileio.print(" "); …

  7. Difficulties with Building DSL Testing Tools • Debuggers and Profilers are difficult to build because they depend heavily on the underlying operating system’s capabilities and lower-level native code functionality • Manual construction of the test tools for each new DSL can be time-consuming, expensive, and error-prone

  8. Three Aspects of the Research • Programming Language Tool Generation Environment • Aspect-Oriented Language for Grammar • DSL Debugger

  9. Related Work • Programming Language Tool Generation Environment • ASF+SDF: • Does not generate test engines and profilers • Jakarta Tool Suite: • Complicated mechanism (e.g., Language extension) • Dose not provide rich transformation ability • LISA: • Debugger, test engine, and profiler are not the target language tools, LISA can be used as the front-end of our framework. • SmartTools: • Base on Java and XML technologies • Debugger, test engine, and profiler are not target language tools

  10. Research Directions Imperative DSLs Declarative DSLs Hybrid DSLs construction of the same software tool (e.g., debugging) to different categories of DSLs Debuggers Unit Test Engines vertical direction corresponds to the vector representing the various testing tools that will be applied to DSLs Profilers

  11. A Matrix of DSL Testing Tools Research Goal generalized approach to produce a software product line of testing tools for DSLs

  12. Background • Eclipse Debugger Platform • Eclipse Unit Test Platform • Design Maintenance System (DMS)

  13. Processes of DSL Debugger Generation Robot DSL corresponding GPL code generated in Java DSL grammar is defined using ANTLR Notation DSL is the input of the Lexer and Parser generated by ANTLR Additional Mapping code generated in Java DSL translation process Corresponding GPL and Mapping Code are inputs of Mapping component Eclipse Debugging perspective communicates with mapping component jdb communicates with mapping component

  14. Debugging: A Crosscutting Grammar Concern Base Grammar … command :( RIGHT { fileio.print(" //move right"); fileio.print(" x=x+1;"); fileio.print(" time=time+1;"); fileio.print(" "); } |LEFT { fileio.print(" //move left"); fileio.print(" x=x-1;"); fileio.print(" time=time+1;"); fileio.print(" "); } | … What if this line changes? Change here Duplicate Debugging Aspect Code dsllinenumber=dsllinenumber+1; gplbeginline=fileio.getLinenumber(); gplendline=fileio.getLinenumber(); filemap.print(" mapping.add(new Map("+dsllinenumber+", \"Robot.java\","+gplbeginline+","+gplendline+"));"); dsllinenumber=dsllinenumber+1; gplbeginline=fileio.getLinenumber(); gplendline=fileio.getLinenumber(); filemap.print(" mapping.add(new Map("+dsllinenumber+", \"Robot.java\","+gplbeginline+","+gplendline+"));"); Change here Change ……

  15. Related Work • Aspect Oriented Language for Grammars • AspectAsf: • weave all possible debugging aspects into all potential program locations • AspectLISA: • aspect-oriented compiler generator based on attribute grammars • incrementally extend a language design • advices before and after join point are not applicable • purpose of AspectLISA is not tool generation

  16. AspectG Pointcut Model

  17. Weaving into DSL Grammars Using AspectG

  18. Related Work • DSL Debugger • Khepera: • Support optimization code debugger • Store transformation information in a database • JSR-045: • Java Specification Requests for Debugging Support for Other Languages • Java language domain with similar source code mapping mechanism • AntlrStudio: • provides end-users debugging support on ANTLR grammar • Based on JSR-045 • ToolBus Integrated Debugging Environment (TIDE) • Based on ASF+SDF • 4 tedious steps to implement debugger for a new language • UFO • A framework for rapidly constructing dynamic analyzers • Target Unicon language (SNOBOL-style) high level, goal-directed, object-oriented, GPL.

  19. UFO Demo

  20. Approaches Used in This Proposed Research Syntax-Directed Translation Plug-In Based Software Development ANTLR Eclipse Design Patterns Automated Software Engineering Software 6 after(int commandname): 7 call(void antlr.Parser.match(int)) 8 && args(commandname) 9 { match(commandname); } 10 pointcut count_dsllinenumber(): 11 call (void P.command()); 12 after(): count_dsllinenumber(){ 13 { dsllinenumber=dsllinenumber+1;} Model-View-Controller Adapter Pattern Weaving Aspects into DSL Grammars AspectG

  21. DSL Debugger Perspective in Eclipse

  22. Declarative DSL Debugger

  23. Hybrid DSL Debugger

  24. Hybrid DSL Debugger Demo

  25. DSL Unit Test Framework (DUTF) • Similar to the DSL Debugging Framework architecture and approaches • Complement to the DSL Debugging Framework, identify the existence of program errors • To monitor the performance of DSLs at run time, similar architecture and approaches can be applied to DSL Profiler Framework (DPF) to generate DSL profilers

  26. DSL Unit Test Perspective in Eclipse

  27. DSL Unit Test Perspective in Eclipse

  28. Experimental Validation of This Work • Various types of DSLs serve as test cases • Robot Language (imperative DSL) • FDL (declarative DSL) • Robot Language with extension (hybrid DSL) • Qualitative Metrics-How well the generated testing tools behave • To what degree of success can the DSL unit test engine detect errors in DSL program units? • To what degree can the DSL debugger help end-users to locate and fix the detected errors?

  29. Summary • End-user developers (e.g., scientist, accountant, and statistician) are in large number • Software failures caused by program errors pose a great threat to economy • Testing and Debugging on GPLs have been investigated for decades, but testing and debugging DSLs has been neglected. • Several publication reviews, paper citations, and source code requests indicate the proposed research is in the right direction.

  30. Summary • Preliminary feasibility study: • Debuggers for imperative, declarative, and hybrid DSLs • Unit Test Engine for imperative DSLs • Published initial experiences [WGR+05] • An initial investigation into weaving aspects into DSL grammars and working on implementation of AspectG.

  31. Thank you for coming!Questions? • Summary of URLs referenced in talk • DSL Debugger Framework • http://www.cis.uab.edu/wuh/DDF • ANTLR • http://www.antlr.org • AspectJ • http://www.aspectj.org • DMS • http://www.semdesigns.com DDF

More Related