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

press pgdn to start
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Press PgDn to start.

slide-2
SLIDE 2

TOWARDS AN ENGINEERING DISCIPLINE

FOR GRAMMARWARE

Ralf L¨ ammel, VU und CWI, Amsterdam

slide-3
SLIDE 3

GRAMMARWARE — DEFINITION

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

slide-4
SLIDE 4

SOFTWARE RE-/REVERSE ENGINEERING

NEEDS ENGINEERING OF GRAMMARWARE — THINK OF TRANSFORMATION ENVIRONMENTS

Engine Unparser Parser Grammar AST AST Transformation

slide-5
SLIDE 5

SOFTWARE RE-/REVERSE ENGINEERING

NEEDS GRAMMAR ENGINEERING — THE EF- FORT DISTRIBUTION

core Editor Visitor Parser Unparser Tool 1 Tool 2 Tool n

...

(length of arrow represents effort)

Generic

Grammar

slide-6
SLIDE 6

SO MUCH GRAMMARWARE, SO LITTLE ATTENTION

XMI / UML

grammar Principle notations Actual grammar software dependent Grammar−

SDF YACC CTS.NET XML schema

... ... ... ... ...

Modification tooling Analysis tooling Client/server CASE tools Compiler processors Document models Software standards Industrial applications generators Application APIs Reflection tools Weaving

Signature DGL PRECC ASDL BNF EBNF Class dictionary

forms

slide-7
SLIDE 7

WHAT IS ENGINEERING OF GW? LET’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.

slide-8
SLIDE 8

GRAMMAR 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
slide-9
SLIDE 9

GRAMMAR-DRIVEN SOFTWARE

  • Application generators, tools for generative programming,

aspect-oriented weavers, tools for automated software engi- neering

  • Distributed or component-based applications where grammars
  • ccur 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
slide-10
SLIDE 10

GRAMMARWARE 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.

slide-11
SLIDE 11

EXAMPLE PARSER DEVELOPMENT

Grammarware

Parser

...

Parser Parser Parser

"Grammarware hacking" "Grammarware engineering"

Manual coding specification Grammar recovery Automated knowledge Grammar generation Automated tooling

slide-12
SLIDE 12

LACK 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.

slide-13
SLIDE 13

LACK OF COMPREHENSIVE FOUNDATIONS

  • no comprehensive theory of testing grammarware
  • ... of transforming ...
  • version management?
  • quality assessment?
  • design patterns?
  • debugging?
slide-14
SLIDE 14

THE GRAMMAR 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”

slide-15
SLIDE 15

IN NEED OF A PARADIGM SHIFT

  • widest sense
  • Perspective

compiler frontends Grammars in the Grammars in

"Lines of code" Perspective "Impact ratio"

All software assets

Fig.: The mythical view and the proposed view on grammarware

slide-16
SLIDE 16

ENGINEERING OF GRAMMARWARE — PRINCIPLES

  • Abstraction
  • Customisation
  • Modularity
  • Evolution
  • Assessment
  • Automation
slide-17
SLIDE 17

ENGINEERING OF GRAMMARWARE — A LIFE CYCLE

Evolution

Import/export schema XML serialiser Visitor framework specification Parser

Evolution grammar Base−line Customisation

Frontend

Recovery

class hierarchy Customised Semi−structured document Rendered manual

Implementation

slide-18
SLIDE 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.

slide-19
SLIDE 19

GRAMMAR TRANSFORMATIONS AS A PARADIGM

  • Grammar re-/reverse engineering

– Correction – Completion – Restructuring – Style conversion

slide-20
SLIDE 20

CORRECTION 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)

slide-21
SLIDE 21

COMPLETION 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}+

slide-22
SLIDE 22

GRAMMAR TRANSFORMATIONS AS A PARADIGM

  • Grammar implementation

– Style conversion – Disambiguation – Conflict resolution – Preprocessing – Grammar minimalisation

slide-23
SLIDE 23

GRAMMAR TRANSFORMATIONS AS A PARADIGM

  • Grammar maintenance

– Evolution – Optimisation – Migration

slide-24
SLIDE 24

A FRAMEWORK FOR GRAMMAR TRANSFORMATIONS

  • Suitable notion of grammars
  • Primitive operators
  • Combinators
  • Conditions
  • A suite of defined operators
slide-25
SLIDE 25

SOME OPERATORS FOR GRAMMAR CONSTRUCTION

generalise P in F to P ′

≡ P ′ covers P ?;

replace P by P ′ !/F ;

P ′ covers P ?

include P for N

defined N ?; add N → P ! resolve N as P

bottom N ?; add N → P unify N to N′

bottom N ?; ¬ fresh N′ ?; replace N by N′

slide-26
SLIDE 26

TRANSFORMATION OPERATORS; THEIR PROPERTIES

Operator Preservation Inverse Refactoring

preserve

strict

preserve fold

introducing

unfold unfold

strict

fold introduce

introducing

eliminate eliminate

eliminating

introduce rename

modulo renaming

rename

Construction

generalise

increasing

restrict include

increasing

exclude resolve

resolving

reject unify

essentially resolving

separate

Destruction

restrict

decreasing

generalise exclude

decreasing

include reject

rejecting

resolve separate

essentially rejecting

unify delete

“zig-zag”

slide-27
SLIDE 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 ti

for correction and completion of γ0.

slide-28
SLIDE 28

ENGINEERED 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 ti are weakly semantics-preserving. Completion Missing branches are added. Correction Invalid branches are removed.

slide-29
SLIDE 29

ENGINEERING

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
  • ...
slide-30
SLIDE 30

COMPONENT-SPECIFIC, TOLERANT PARSERS

no false negatives no false positives

s s t x y x t y for all x t y in L(G) T G

parse tree

T G

parse tree

n m(n)

slide-31
SLIDE 31

PORTFOLIO-BASED GRAMMAR SPECIALISATION

Analyser Parser Parser Coverage Minimaliser Grammar Generator

Grammar Portfolio ASTs Metrics Minimalised Grammar Full

slide-32
SLIDE 32

XML ENGINEERING

  • XML increasingly used

– Storage formats – Exchange formats – in component-based, distributed applications.

  • DTD/XML-Schemas are grammars.
  • XML schemas do evolve.
  • XML challenges grammar engineering.
  • Format evolution ≈ DB scheme evolution.
slide-33
SLIDE 33

TWO LEVELS OF XML TRANSFORMATION

Transformation

XML stream XML stream

Transformation

Input Output

  • doc. processor
  • doc. processor

Transformation XML schema XML schema

slide-34
SLIDE 34

XML DEMO: STEPWISE TRANSFORMATION OF A FORM

A A1 A2 A3 A4 B B1 B2 ?

A12 A1 A2 A34 A3 A4 B B1 B2

slide-35
SLIDE 35

Step 1

A A1 A2 A3 A4 B B1 B2

fold (A1 A2) to A12

A A12 A1 A2 A3 A4 B B1 B2

slide-36
SLIDE 36

Step 2

A A12 A1 A2 A3 A4 B B1 B2

fold (A3 A4) to A34

A A12 A1 A2 A34 A3 A4 B B1 B2

slide-37
SLIDE 37

Step 3

A A12 A1 A2 A34 A3 A4 B B1 B2

unfold A

A12 A1 A2 A34 A3 A4 B B1 B2

slide-38
SLIDE 38

THINGS TO REMEMBER

  • Recover base-line grammars
  • Derive grammar uses
  • Assess quality of grammars
  • Keep track of grammar adaptation
  • Co-evolve grammar-based software
  • Treat grammars as contracts
slide-39
SLIDE 39

LAST SLIDE: CORNERSTONES

OF THE SOFTWARE EVOLUTION AGE

Methodology

Component−based Executable specifications

  • Alg. for program analysis

Generative programming Generic programming Grammar−based

Pragmatics

slide-40
SLIDE 40

End of slide show.