Extreme Grammaring Development of an industrial strength ISO VDM-SL Grammar.

Slides:



Advertisements
Similar presentations
Extreme Programming Alexander Kanavin Lappeenranta University of Technology.
Advertisements

Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
© Chinese University, CSE Dept. Software Engineering / Software Engineering Topic 1: Software Engineering: A Preview Your Name: ____________________.
Alternate Software Development Methodologies
Background information Formal verification methods based on theorem proving techniques and model­checking –to prove the absence of errors (in the formal.
Semantic analysis Parsing only verifies that the program consists of tokens arranged in a syntactically-valid combination, we now move on to semantic analysis,
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
176 Formal Languages and Applications: We know that Pascal programming language is defined in terms of a CFG. All the other programming languages are context-free.
Agile Software Development. Traditional Software Development 1.Initiation (RFP) 2.Feasibility study Technical – can we build it? Economic – should we.
Extreme Programming Mark Steverson. What Is Extreme Programming? ● Extreme Programming (XP) is a lightweight, agile methodology developed by Kent Beck.
Chapter 3 Program translation1 Chapt. 3 Language Translation Syntax and Semantics Translation phases Formal translation models.
Transitioning to XP or The Fanciful Opinions of Don Wells.
The Structure of the GNAT Compiler. A target-independent Ada95 front-end for GCC Ada components C components SyntaxSemExpandgigiGCC AST Annotated AST.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Specifying Languages CS 480/680 – Comparative Languages.
BİL744 Derleyici Gerçekleştirimi (Compiler Design)1.
Xtreme Programming. Software Life Cycle The activities that take place between the time software program is first conceived and the time it is finally.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
September 7, September 7, 2015September 7, 2015September 7, 2015 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University.
Workshop on Integrated Application of Formal Languages, Geneva J.Fischer Mappings, Use of MOF for Language Families Joachim Fischer Workshop on.
CPIS 357 Software Quality & Testing
C++ Code Analysis: an Open Architecture for the Verification of Coding Rules Paolo Tonella ITC-irst, Centro per la Ricerca Scientifica e Tecnologica
Extreme Programming(XP)
CS 360 Lecture 3.  The software process is a structured set of activities required to develop a software system.  Fundamental Assumption:  Good software.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Parser-Driven Games Tool programming © Allan C. Milne Abertay University v
Chapter 10: Compilers and Language Translation Invitation to Computer Science, Java Version, Third Edition.
1 e X treme P rogramming D. Dranidis September 2000 CITY College.
CPSC 2150 August 21, Chapter 1 Object Oriented Software Development This is an introductory course In this chapter we will look at 3 topics Challenges.
Extreme/Agile Programming Prabhaker Mateti. ACK These slides are collected from many authors along with a few of mine. Many thanks to all these authors.
Compiler course 1. Introduction. Outline Scope of the course Disciplines involved in it Abstract view for a compiler Front-end and back-end tasks Modules.
Extreme Programming (XP). Agile Software Development Paradigm Values individuals and interactions over processes and tools. Values working software over.
C H A P T E R TWO Syntax and Semantic.
Lexical and Syntax Analysis
1 Syntax In Text: Chapter 3. 2 Chapter 3: Syntax and Semantics Outline Syntax: Recognizer vs. generator BNF EBNF.
Sofia Bulgaria Summer School IST eXPERT: Best Practice on e-Project Development 30 June - 2 July 2003 eXtreme programming.
Programming Languages Seminar, Spring Grammar Adaptation (Ralf Lämmel, CWI) Presentation and slides by: Faizan Javed March 9 th, 2004.
CPS 506 Comparative Programming Languages Syntax Specification.
Stratego Song Zhou *Include slides from language.org/Stratego/SlidesForSoftwareGeneration2001http:// language.org/Stratego/SlidesForSoftwareGeneration2001.
Topic #1: Introduction EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
AP-1 4. Agile Processes. AP-2 Agile Processes Focus on creating a working system Different attitude on measuring progress XP Scrum.
Introduction to Compiling
Jin-Ning TiohComputer Engineering Tony RossComputer Engineering Dave ZajicekComputer Engineering Alex BurdsComputer Engineering Abstract In recent years,
Compiler Introduction 1 Kavita Patel. Outlines 2  1.1 What Do Compilers Do?  1.2 The Structure of a Compiler  1.3 Compilation Process  1.4 Phases.
CPSC 873 John D. McGregor Session 9 Testing Vocabulary.
Extreme programming (XP) Variant of agile Takes commonsense practices to extreme levels © 2012 by Václav Rajlich1.
The Interpreter Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Extreme Programming. Extreme Programming (XP) Formulated in 1999 by Kent Beck, Ward Cunningham and Ron Jeffries Agile software development methodology.
Cross Language Clone Analysis Team 2 February 3, 2011.
Formal Methods in Software Engineering1 Today’s Agenda  Mailing list  Syllabus  Introduction.
Software Development Process CS 360 Lecture 3. Software Process The software process is a structured set of activities required to develop a software.
©SoftMoore ConsultingSlide 1 Structure of Compilers.
CS223: Software Engineering Lecture 18: The XP. Recap Introduction to Agile Methodology Customer centric approach Issues of Agile methodology Where to.
CS416 Compiler Design1. 2 Course Information Instructor : Dr. Ilyas Cicekli –Office: EA504, –Phone: , – Course Web.
The PLA Model: On the Combination of Product-Line Analyses 강태준.
Software Development. The Software Life Cycle Encompasses all activities from initial analysis until obsolescence Analysis of problem or request Analysis.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture Ahmed Ezzat.
Chapter 3 – Describing Syntax CSCE 343. Syntax vs. Semantics Syntax: The form or structure of the expressions, statements, and program units. Semantics:
Software Development Life Cycle. The Software Life Cycle  Encompasses all activities from initial analysis until end of work  Formal process for software.
Software Development.
Compiler Design (40-414) Main Text Book:
Introduction to Compiler Construction
The Systems Engineering Context
Extreme Programming.
CS416 Compiler Design lec00-outline September 19, 2018
Lexical and Syntax Analysis
Introduction CI612 Compiler Design CI612 Compiler Design.
CS416 Compiler Design lec00-outline February 23, 2019
Lec00-outline May 18, 2019 Compiler Design CS416 Compiler Design.
Presentation transcript:

Extreme Grammaring Development of an industrial strength ISO VDM-SL Grammar

Introduction Need of building a parser for VDM from a VDM- SL grammar (VooDooM project) Although parsing is a subset of a well studied area like compilers, grammars were always looked upon as the “ugly duckling”. Extreme Programming + Engineering of Grammars = Extreme Grammaring Solution:

Background VDM: Vienna Development Method (VDM) is one of the most mature formal methods Primarily intended for formal specification and development of functional aspects of software systems. The importance of a VDM-SL Grammar: Documentation Build a parser (metric generators, language generators,...)

Starting point Previous work VDM-SL grammar in Happy + Alex Some problems State of Art (Hacking v.s. Engineering) Grammar was encoded directly Difficult to maintain/change (300 rules) Lack of tool support...

Principles of Grammar Engineering Introduced by Lämmel in “Towards an engineering discipline for grammaware” 1. Start from specifications - base-line grammar 2. Implement by customization - technology, implementation 3. Separate concerns - modularization 4. Enable evolution - minimize impact of changes 5. Ensure quality - metrics, correctness 6. Automate - traceability and scalability

Extreme Programming 1. The Planning Game - scope, priorities, technical estimates 2. Small Releases - very short release cycle 3. Metaphor - shared story 4. Simple Design - remove complexity when found 5. Testing - continuous unit testing, test-first design 6. Refactoring - restructure without functionality changes 7. Pair Programming - two programmers one machine 8. Collective Ownership - change each others code (anytime) 9. Continuous Integration - build and test Hour Week - work more = produce less 11. On-Site Customer - user in team 12. Coding Standards - no irrelevant personal preferences

Extreme Grammaring 1. The Planning Game - scope, priorities, technical estimates 2. Small Releases - very short release cycle 3. Metaphor - shared story 4. Simple Design - remove complexity when found 5. Testing - continuous unit testing, test-first design 6. Refactoring - restructure without functionality changes 7. Pair Programming - two programmers one machine 8. Collective Ownership - change each others code (anytime) 9. Continuous Integration - build and test Hour Week - work more = produce less 11. On-Site Customer - user in team 12. Coding Standards - no irrelevant personal preferences

The Planning Game Scope Follow strictly the ISO VDM-SL grammar spec Priorities 1. Disambiguate types 2. Disambiguate full grammar 3. Tree construction Technical estimates Not defined...

Small Releases Programmed releases (completed): Grammar typed from standard Disambiguated grammar AST construction Future Releases Haskell front-end (finished ) Java front-end

Testing White box Structural testing Full visibility into how system works Black box Functional or behavioral testing Only the interface with exterior is available

Grammar Unit Testing Unit test Test a single method, function, etc... Different types of unit tests: Parsing (succeeds, fails) Well-formness of the tree Test suite Combination of all unit test

Test Coverage Rule coverage Introduced by Purdon (1971) Explores all rules of a grammar Simple measure but doesn’t cover all cases Context-dependent rule coverage Introduced by Lämmel in “Grammar Testing” Generalization of the above in which the context is taken in account No known implementations

Test Coverage Metrics KP - Kernel Productions KPr - Kernel Priorities S - States RSa - Rule Size average RSm - Rule Size maximum RC - Rule Coverage Percentage version KPKPrSRSaRSmRC % % %

Test Coverage Metrics (2) Although the “Generics” test-suite does not change the coverage gets lower (Injections, total nr rules) The “expressions” and “functiontypes” were only added in version. versionGenericsexpressionsfunctiontypesAll %0 % 52% %24%6%54% %25%5%56%

Refactoring Semantic preserving transformations Study made by Lämmel in “Grammar Adaptation” Operators: preserve - replace a phrase by an equivalent fold - replace for its definition unfold - extract definition introduce - introduction of non-terminals eliminate - elimination of non-terminals rename - renaming non-terminals

Continuous Integration The integration test suite is a set of generic real world examples Only 52% coverage Examples are difficult to find Most of the examples use language extensions Examples: Found on internet Used a pre-processor for extracting code from literal programs.

Code Standards Nothing found about the subject The following can be applied: Limiting the number of children in a rule Limiting the number of alternatives in a rule Prefer some sort of constructs than other Convention for the non-terminal names Convention for syntax specification Limit module size...

Technological Alternatives Most parser technologies are too restrictive Lex + Yacc uses LALR(1) ANTLR uses LL(K) Have other problems, like: Lexical, context-free & abstract syntax separated Difficult to disambiguate (left-recursive “demon”) Grammars are technology dependent Solution: Generalized LR Parsing using SDF Grammars

Supporting the Methodology SDF - Syntax Definition Formalism Purely declarative Very expressive with natural and concise syntax Modular structure Supported by Scannerless Generalized LR Parsing Supports compositional grammars Allows parsing with ambiguities (allows earlier testing) Disambiguation is separated from the grammar using priority and associative rules

SDF - Technology Parsing sdf2table, sglr Testing test-unit, ambtracker, SdfCoverage Tree visualization tree2graph, graph2dot Transformation trm2baf, implodePT Haskell Generation Sdf2Haskell (AST, Pretty Printer)

Syntax Definition Formalism Optional: “?” Repetition: “*”, “+” Simple, e.g.: Identifier 2+ With separators, e.g.: { Indentifier “,”}+ Alternative: “|”

SDF - Example BNF: A ::= B | C B ::= “b” C ::= “c” | “c” “,” C SDF: B -> A C -> A “b” -> B { “c” “,” }+ -> C Both grammars recognize a single “b” or a list of “c” separated with a “,”

Setting up the bases Hard copy of the ISO VDM-SL standard (ISO/IEC ) Initial test suite Real world examples (loc: 1970) Exercises from Formal Methods course (loc: 507) Software: CVS to keep track of all changes parse-unit (sdf unit testing tool) Sdf2 software bundle (sdf2table, sglr) SdfCoverage Starndard unix tools (text editor, make,...)

Development cycle 1. Initial grammar 2. Correction 1. Correct grammar rules 2. Correct test suite 3. Disambiguation 1. Add filters 2. Change grammar shape Steps 2 and 3 should make heavy use of testing

Grammar correction 1. Isolate problem Source location Grammar rules involved 2. Correct grammar Change syntax (test suite) Run to verify test succeeds Run entire test battery 3. Commit Change Document change in message

Grammar Disambiguation 1. Isolate problem Source location Grammar rules involved 2. Create unit test Captures error Run to guarantee this 3. Correct grammar Add disambiguation filter (change syntax) Run to verify unit test succeeds Run entire test battery 4. Commit Change Document change in message

Grammar Metrics Simple metrics Total Number of Terminals (AVG per rule) Total Number of Non-terminals (AVG per rule) Complex metrics Introduced by Malloy in “A metrics suite for grammar-base software” McCabe Cyclomatic complexity Halstead Effort...

Problems found ISO Document has ambiguities in its specification Syntax Expressions: Apply v.s. RecordConstructor Apply v.s. IsDefTypeExpr EqualsDefinition CallStatement v.s. Expression Lexical Quotes are allowed in strings and in characters

Future plans Short-term (VDM parser “clients”): VooDooM Formal methods projects MCZ Objectifier Camila revival? Long-term Topic open for discussion...

What’s next? Test set completion (fill the rest 44%) Test generation Add examples manually Analyze the rules that were not covered Try to find pathologies Compute Grammar Metrics Test the methodology developing other grammars.

Conclusion Work was completed in only 3 weeks A complete grammar of the ISO VDM-SL is for the first time public available (parser) A strong methodology for grammar developing was defined Grammar testing were put to practice Different types of tests Test coverage

Thank you!

Questions / Discussion