Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Embedding Attribute Grammars

Tony Sloane
November 08, 2016

Embedding Attribute Grammars

Slides for talk given at Lund University, Sweden.

Tony Sloane

November 08, 2016
Tweet

More Decks by Tony Sloane

Other Decks in Research

Transcript

  1. ELI

  2. ELI

  3. Anthony Sloane, Matthew Roberts, Dominic Verity Scott Buckley KIAMA High-level

    language processing in a familiar programming setting Enables experimentation with combinations of processing mechanisms A shallow embedding of Domain-Specific Languages in Scala strategic term rewriting dynamically-scheduled attribute grammars abstract state machines pretty-printing combinators A. M. Sloane. Lightweight language processing in Kiama. In Generative and Transformational Techniques in Software Engineering III, volume 6491 of Lecture Notes in Computer Science, Springer, 2011. https://bitbucket.org/inkytonik/kiama
  4. scalallvm lib control flow graph error trace trace effect (assert

    (and (= %0@1 %r@1 ) %cmp@1 (= %cmp@1 (> %0@1 0)))) (check-sat) C compiler no more traces program correct sat (get-value (r)) ((r 42)) unsat unsat, trace infeasible remove trace from graph SMT solver SMT lib sat, trace feasible program incorrect automata lib
  5. CONTEXT-FREE GRAMMAR TREE ATTRIBUTE EQUATION SELECTION EQUATION NOTATION CACHING CYCLE

    CHECK COMPLETENESS CHECK SUMMARY (1) ALGEBRAIC DATA TYPE ADT VALUE FUNCTION PATTERN-MATCHING CASES BINDING AND EXPRESSIONS IN ATTR WRAPPER DYNAMIC IN ATTR WRAPPER PATTERN EXHAUSTIVENESS CHECK
  6. TREE RELATIONS: CHILD-PARENT A B B C D E? F*

    E F F parent child A. M. Sloane, M. Roberts, and L. G. C. Hamey. Respect your parents: How attribution and rewriting can get along. In Proceedings of the International Conference on Software Language Engineering, volume 8706 of Lecture Notes in Computer Science, 2014.
  7. TREE RELATIONS: FIRST CHILD, NEXT A B B C D

    E? F* E F F first child next
  8. TREE RELATIONS AS PATTERNS Bind c to the first child

    of the matched node, or fail if there are no children Bind pn to the next node at the same level as the parent of the matched node, or fail if there is no parent or next node after parent Succeed if and only if there is a parent and it is an A
  9. CONTEXT-FREE GRAMMAR TREE ATTRIBUTE EQUATION SELECTION EQUATION NOTATION CACHING CYCLE

    CHECK COMPLETENESS CHECK INHERITED EQUATIONS CONTEXT-DEPENDENT EQUATIONS SUMMARY (2) ALGEBRAIC DATA TYPE ADT VALUE FUNCTION PATTERN-MATCHING CASES BINDING AND EXPRESSIONS IN ATTR WRAPPER DYNAMIC IN ATTR WRAPPER PATTERN EXHAUSTIVENESS CHECK MATCHING ON PARENT TREE RELATIONS AS PATTERNS
  10. CIRCULAR ATTRIBUTES E. Magnusson, G. Hedin. Circular reference attributed grammars

    — their evaluation and applications. Science of Computer Programming 68 (2007) 21–37.
  11. MODULARITY L1 L2 L3 L4 Syntax analyser Oberon-0 printer Name

    analyser Type analyser Desugarer Lifter Code generator C printer A extends B A B A B mixin: A ... with B A. M. Sloane and M. Roberts. Oberon-0 in Kiama. Science of Computer Programming, Dec. 2015
  12. CONTEXT-FREE GRAMMAR TREE ATTRIBUTE EQUATION SELECTION EQUATION NOTATION CACHING CYCLE

    CHECK COMPLETENESS CHECK INHERITED EQUATIONS CONTEXT-DEPENDENT EQUATIONS HIGHER-ORDER/REFERENCE ATTRS FORWARDING CIRCULAR ATTRIBUTES ATTRIBUTION PATTERNS MODULARITY SUMMARY (3) ALGEBRAIC DATA TYPE ADT VALUE FUNCTION PATTERN-MATCHING CASES BINDING AND EXPRESSIONS IN ATTR WRAPPER DYNAMIC IN ATTR WRAPPER PATTERN EXHAUSTIVENESS CHECK MATCHING ON PARENT TREE RELATIONS AS PATTERNS FUNCTIONS AND TREE RELATIONS IMPLICIT CONVERSION AS IN JASTADD DECORATORS MIXINS, INHERITANCE
  13. SOFTWARE LANGUAGE ENGINEERING AT MACQUARIE UNIVERSITY https://bitbucket.org/inkytonik/kiama [email protected] @inkytonik on

    Twitter High-level language processing in a familiar programming setting strategic term rewriting dynamically-scheduled attribute grammars abstract state machines pretty-printing combinators https://bitbucket.org/inkytonik/sbt-rats Scala parser generator plugin PEG-based packrat parsing tree construction pretty-printing