press pgdn to start
play

Press PgDn to start. T OWARDS AN ENGINEERING DISCIPLINE FOR - PDF document

Press PgDn to start. T OWARDS AN ENGINEERING DISCIPLINE FOR GRAMMARWARE Ralf L ammel, VU und CWI, Amsterdam G RAMMARWARE DEFINITION The term grammarware comprises grammars and grammar-driven software, i.e., software artifacts that


  1. Press PgDn to start.

  2. T OWARDS AN ENGINEERING DISCIPLINE FOR GRAMMARWARE Ralf L¨ ammel, VU und CWI, Amsterdam

  3. G RAMMARWARE — DEFINITION The term ‘grammarware’ comprises grammars and grammar-driven software, i.e., software artifacts that di- rectly involve grammar knowledge.

  4. S OFTWARE RE -/ REVERSE ENGINEERING NEEDS ENGINEERING OF GRAMMARWARE — THINK OF T RANSFORMATION ENVIRONMENTS Grammar Parser Unparser Engine Transformation AST AST

  5. S OFTWARE RE -/ REVERSE ENGINEERING NEEDS GRAMMAR ENGINEERING — THE EF - FORT DISTRIBUTION Tool 1 Tool 2 Parser Unparser ... Generic Grammar core Tool n Editor Visitor (length of arrow represents effort)

  6. S O MUCH GRAMMARWARE , SO LITTLE ATTENTION Application Client/server Analysis Weaving Industrial Compiler applications ... tooling generators tools standards Grammar− dependent Modification Reflection Document Software CASE tools APIs processors models software tooling Actual DGL PRECC XMI / UML ASDL ... ... ... ... grammar notations YACC SDF CTS.NET XML schema Principle grammar forms BNF EBNF Class dictionary Signature

  7. W HAT IS ENGINEERING OF GW ? L ET ’ S LOOK AT SCENARIOS . • As a developer of database applications, you want to make a transition to a new screen definition language . • As a developer of Commercial Off-The-Shelf software, you want to import user profiles used by competing products; think of web browsers. • As an object-oriented application developer, you want to systematically mi- grate to a new release of some API . • As a developer of an inhouse domain-specific language (DSL), you want to provide a tool to convert existing DSL programs to the evolved DSL. • As an online service provider, you want to support new import/export for- mats (maybe using XML schemas) or new protocols for system use.

  8. G RAMMAR FORMS AND NOTATIONS • Definitions of interchange and storage formats • Interface descriptions • Specifications of interaction protocols • Concrete and abstract syntax definitions • Definitions of intermediate and internal representations

  9. G RAMMAR - DRIVEN SOFTWARE • Application generators, tools for generative programming, aspect-oriented weavers, tools for automated software engi- neering • Distributed or component-based applications where grammars occur in the sense of interfaces and I/O formats • Functionality in language implementations, e.g., compilers, an- imators, documentation generators, profilers, debuggers, ... • Functionality for automated software re-documentation, analy- sis and modification, pre- and post-processors • Reference manuals, style guides, and industrial standards

  10. G RAMMARWARE REALITY — HACKING Given the omnipresence of grammarware, one may expect that grammarware is treated as an engineering artifact — subject to reasonable common or best practices. In reality, grammar- ware is predominantly treated in an ad-hoc manner.

  11. E XAMPLE PARSER DEVELOPMENT "Grammarware hacking" "Grammarware engineering" Grammar knowledge Automated recovery Grammar specification Automated Manual Grammarware generation coding tooling ... Parser Parser Parser Parser

  12. L ACK OF BEST PRACTICES • There is no established approach for performing grammar evo- lution in a traceable manner — not to mention the even more difficult problem of co-evolution of grammar-driven software. • There is no established approach for maintaining consistency between the incarnations of conceptually the same grammar. • Grammars are immediately implemented using specific tech- nology, which implies the use of idiosyncratic notations.

  13. L ACK OF COMPREHENSIVE FOUNDATIONS • no comprehensive theory of testing grammarware • ... of transforming ... • version management? • quality assessment? • design patterns? • debugging?

  14. T HE G RAMMAR DILEMMA Improving on hacking sounds like such a good idea! Why did it not happen? Myth “Grammars are a buried subject” Myth “Engineering of grammarware = parser generation”] Myth “XML is the answer” Myth “Grammarware is all about programming languages”

  15. I N NEED OF A PARADIGM SHIFT Perspective Perspective "Lines of code" "Impact ratio" ��� ��� ��� ��� All software assets ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� �� �� ��� ��� �� �� ��� ��� �� �� ��� ��� �� �� ��� ��� �� �� � � ��� ��� �� �� � � ��� ��� �� �� � � ��� ��� �� �� ��� ��� �� �� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� ��� Grammars in Grammars in the ��� ��� ��� ��� ��� ��� compiler frontends widest sense ��� ��� ��� ��� ��� ��� Fig.: The mythical view and the proposed view on grammarware

  16. E NGINEERING OF GRAMMARWARE — PRINCIPLES • Abstraction • Customisation • Modularity • Evolution • Assessment • Automation

  17. E NGINEERING OF GRAMMARWARE — A LIFE CYCLE Implementation Evolution Parser Frontend specification Customisation Evolution Import/export XML serialiser schema Base−line grammar Customised Visitor framework class hierarchy Semi−structured Rendered manual document Recovery

  18. A CASE STUDY IN GRAMMAR RECOVERY AND DEPLOYMENT — VS COBOL II • Input: IBM’s industrial standard for VS COBOL II • Result: public, normative COBOL grammar Time for a demo.

  19. G RAMMAR TRANSFORMATIONS AS A PARADIGM • Grammar re-/reverse engineering – Correction – Completion – Restructuring – Style conversion

  20. C ORRECTION BY TRANSFORMATIONS Informal rule in IBM’s reference: “Level-number, data- name-1, and FILLER are not part of the REDEFINES clause itself, and are included in the format only for clar- ity.” Transformation focus on REDEFINES-clause do delete level-number ( data-name | FILLER )

  21. C OMPLETION BY TRANSFORMATIONS Informal rule in IBM’s Reference: “A series of impera- tive statements can be specified whenever an imperative statement is allowed.” Transformation generalise imperative-statement to { imperative-statement } +

  22. G RAMMAR TRANSFORMATIONS AS A PARADIGM • Grammar implementation – Style conversion – Disambiguation – Conflict resolution – Preprocessing – Grammar minimalisation

  23. G RAMMAR TRANSFORMATIONS AS A PARADIGM • Grammar maintenance – Evolution – Optimisation – Migration

  24. A FRAMEWORK FOR GRAMMAR TRANSFORMATIONS • Suitable notion of grammars • Primitive operators • Combinators • Conditions • A suite of defined operators

  25. S OME OPERATORS FOR GRAMMAR CONSTRUCTION P ′ covers P ?; generalise P in F to P ′ ≡ replace P by P ′ ! / F ; P ′ covers P ? ≡ defined N ?; include P for N add N → P ! ≡ bottom N ?; resolve N as P add N → P bottom N ?; ¬ fresh N ′ ?; unify N to N ′ ≡ replace N by N ′

  26. T RANSFORMATION OPERATORS ; THEIR PROPERTIES Operator Preservation Inverse Refactoring preserve strict preserve fold introducing unfold unfold strict fold introduce introducing eliminate eliminate eliminating introduce modulo renaming rename rename Construction generalise increasing restrict include increasing exclude resolve resolving reject unify essentially resolving separate Destruction decreasing restrict generalise decreasing exclude include rejecting reject resolve separate essentially rejecting unify delete “zig-zag”

  27. A PROCESS FOR GRAMMAR RECOVERY • Lack of a reference grammar for some intended language L . • Availability of an approximative grammar γ 0 for L . • Availability of representative portfolio C for L . • Derive the ultimate grammar γ n for L from γ 0 . • γ n is (absolutely) complete if L ⊆ L ( γ n ) . • γ n is (absolutely) correct if L ( γ n ) ⊆ L . • γ i is derived from γ i − 1 by transformations t i for correction and completion of γ 0 .

  28. E NGINEERED RECOVERY Role of portfolio C The γ i accept more and more of C . Completeness γ n parses all of C . Correctness γ n is covered by C . Preservation γ n preserves γ 0 as much as possible. Operators The t i are weakly semantics-preserving. Completion Missing branches are added. Correction Invalid branches are removed.

  29. E NGINEERING — OF GRAMMARWARE SHOWCASES OTHER THAN GRAMMAR RECOVERY AND PARSER DEVEL - OPMENT • Component-specific, tolerant parsers • Portfolio-based grammar specialisation • Transposition to XML: format evolution • API-fication • ...

  30. C OMPONENT - SPECIFIC , TOLERANT PARSERS parse tree parse tree T T G G s s no false negatives n m(n) no false positives x t y x t y for all x t y in L(G)

  31. P ORTFOLIO - BASED GRAMMAR SPECIALISATION Full Grammar Parser Generator Coverage Grammar Parser ASTs Metrics Analyser Minimaliser Portfolio Minimalised Grammar

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend