from compilers to grammarware
play

From Compilers to Grammarware Dr. Vadim Zaytsev Introduction - PowerPoint PPT Presentation

From Compilers to Grammarware Dr. Vadim Zaytsev Introduction Compilers Grammarware T ransformation Maturity Consistency Understanding T esting Conclusion Introduction Vadim Zaytsev MSc in appl.math (2003) & telematics


  1. From Compilers to Grammarware Dr. Vadim Zaytsev

  2. Introduction Compilers Grammarware T ransformation Maturity Consistency Understanding T esting Conclusion

  3. Introduction • Vadim Zaytsev • MSc in appl.math (2003) & telematics (2004) • PhD in softw.lang.eng. (2010) • Postdoc at CWI (2010–2013) • Lecturer at UvA (2013–…)

  4. What is a compiler?

  5. Language processing • Internal structures • databases, configurations, tables, … • External structures • protocols, interfaces, bytecode, … • Software language • programming, modelling, markup, …

  6. Compiler Front MIDDLE BACK End End End

  7. Multi-language compiler Front End Front MIDDLE BACK End End End Front End

  8. Multi-target compiler Front BACK End End Front MIDDLE BACK End End End Front BACK End End

  9. Grammarware Front BACK End End Front MIDDLE BACK End End End Front BACK End End

  10. Compilers transform between languages Grammarware commits to grammatical structure

  11. Kinds of grammarware • Parser • IDE • API • Compiler • DSL • XMLware • Interpreter • Preprocessor • Modelware • Prettyprinter • Postprocessor • Lang. • RE • Scanner • Validator • Benchmark • Browser • Model checker • Recommender • Refactorer • Static checker • Renovation tool • Struct.editor • Code slicer Klint, Lämmel, Verhoef, T oward an Engineering Discipline for Grammarware

  12. Languages vs. grammars Declarative Multi-Purpose Language Definition Syntax Name Type Dynamic Transform Definition Binding Constraints Semantics Visser,

  13. Introduction Compilers Grammarware T ransformation Maturity Consistency Understanding T esting Conclusion

  14. What is good grammarware?

  15. Case study: JLS ? Lämmel, Zaytsev, Recovering Grammar Relationships for the

  16. What is good grammarware? What is good software?

  17. What is good software? • functional • reliable • usable • efficient • maintainable • portable ISO/IEC 9126.

  18. What is good grammarware? • functional: commits to the language • reliable: tolerant to errors • usable: the language is learnable • efficient: fast (live?) and responsive • maintainable: can be tested and evolved • portable

  19. Certified Language Processor

  20. Certified Language Engineer

  21. Capability Maturity Model • Level 1 — Chaotic • Level 2 — Repeatable • Level 3 — Defined • Level 4 • Level 5 — Optimising Paulk, Weber, Curtis, Chrissis, Capability Maturity Model for Software

  22. 
 Grammar Zoo • 974 fetched grammars • 588 extracted • 79 connected • 9 adapted +metadata http://slebok.github.io/zoo Zaytsev, Grammar Maturity Model Zaytsev, Grammar Zoo: A Corpus of Experimental Grammarware

  23. Improving quality • Manual inline editing • Refactorings • Programmed transformations • +Differs • Grammar mutations • Inference of transformation/mutation steps

  24. How to transform expr : …; expr : …; expr : ID; atom : ID | INT | '(' expr ')'; expr : INT; abstractize abridge expr : …; expr : …; atom : ID | INT | expr; expr : ID; expr : INT; expr : …; expr : expr; vertical unite atom : ID; atom : INT; atom : expr; Lämmel, Zaytsev, An Introduction to Grammar Convergence, IFM’

  25. How to mutate • Grammar has no starting symbol? • Reroot2top • Need abstract syntax from concrete syntax? • Retire T s • Grammar productions written in an • DeyaccifyAll • Change naming convention? • RenameAllNLower2Camel Zaytsev. Software Language Engineering by Intentional Rewriting, SQM’14

  26. How to be guided • Equality & algebraic equivalence • Prodsig-equivalence • signatures based on nonterminal patterns • tolerant to permutations • weak equivalence tolerant to iteration kinds • Abstract Normal Form • no terminals, labels, markers • consistent disjunctive style Zaytsev, Guided Grammar Convergence,

  27. How to be guided p master = p ( ε , expr · operator · expr ) expr , = p ( ε , s ( l , atom ) · ∗ ( s ( o , ops ) · s ( r , atom ))) F p antlr binary , = p ( binary , atom · ∗ ( ops · atom )) F p dcg expr , = p ( ε , s ( ops , Ops ) · s ( left , Expr ) · s ( right , Expr )) Binary , p emf = p ( ε , s ( Ops , Ops ) · s ( Left , Expr ) · s ( Right , Expr )) Binary , p jaxb = p ( ε , s ( ops , Ops ) · s ( left , Expr ) · s ( right , Expr )) Binary , p om F p python = p ( ε , atom · ∗ ( operators · atom )) binary , = p ( ε , s ( binary , s ( e1 , FLExpr ) · s ( op , FLOp ) · s ( e2 , FLExpr ))) FLExpr , p adt = p ( binary , s ( lexpr , Expr ) · s ( op , Ops ) · s ( rexpr , Expr )) Expr , p rascal = p ( binary , Expr · Ops · Expr ) Expr , p sdf = p ( ε , expression , expression · op · expression ) p txl = p ( ε , s ( ops , Ops ) · s ( left , Expr ) · s ( right , Expr )) Binary , p xsd Zaytsev, Guided Grammar Convergence,

  28. What we want in general • Maintenance assistants • infer whatever possible • provide advice on the rest • Not necessarily “request => result or fail” • pending • negotiated Zaytsev, Pending Evolution of Grammars Zaytsev, Negotiated Grammar Evolution

  29. Negotiating the result rename(expr,Expr) no expr! rename(exp,Exp) ok Zaytsev, Negotiated Grammar Evolution

  30. Key points • For grammarware, we need • consistency • a clear quality model • improvement processes • automation • Also, • understanding user scenarios

  31. Parsing in a broad sense grouped abstract visual tokens model diagram typed concrete graph tokens model model slices/ parse vector tokens graph drawing raw parse raster string forest picture Zaytsev, Bagge, Parsing in a Broad Sense, MoDELS'

  32. Introduction Compilers Grammarware T ransformation Maturity Consistency Understanding T esting Conclusion

  33. So, grammarware is based on grammars… …can we test/validate it based on grammars?

  34. Grammar-based testing • Purdom’s generator • builds the shortest conforming term • Maurer’s generator • randomly selects alternatives • Coverage criteria G G’ • TC, NC, PC, BC, UC, CDBC P P’ • Negative cases? Fischer, Lämmel, Zaytsev, Comparison of CFGs Based on … T est Data

  35. Combinatorial explosion 1,250 1,000 750 500 250 0 TC PC NC BC CDBC TC PC NC BC CDBC TC PC NC BC CDBC TC PC NC BC CDBC TC PC NC BC CDBC Java (Habelitz) Java (Parr) Java (Stahl) Java (Studman) TESCOL (00001) Fischer, Lämmel, Zaytsev, Comparison of CFGs Based on … T est Data

  36. Combinatorial explosion Butrus, Zaytsev, Grammar-based T esting Made Easy with Mutations

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