methodo methodo ology 1 ology 1 pla an
play

Methodo Methodo ology (1) ology (1) Pla an Strict separation - PowerPoint PPT Presentation

Methodo Methodo ology (1) ology (1) Pla an Strict separation between St i t ti b t n syntax definitions and d fi iti d Booleans signature definitions Steps towards a Pico e S d Pi nvironment i Modularize syntax definit


  1. Methodo Methodo ology (1) ology (1) Pla an ● Strict separation between St i t ti b t n syntax definitions and d fi iti d ● Booleans signature definitions ● Steps towards a Pico e S d Pi nvironment i ● Modularize syntax definit tions based on sorts or “functionality”: statement ts, expressions, types, etc. – Step 1: define syntax – Step 2: define a type che ecker ● Modularize signature def finitions based on functionality: type check, functionality: type check, , evaluate, collect, etc. , evaluate, collect, etc. – Step 3: define an evaluat Step 3: define an evaluat tor tor – Step 4: define a compile er ● Traversal functions T l f ti ● Methodology Introduction to ASF+SDF 1 Introduction to ASF+SDF Methodo Methodo ology (2) ology (2) Methodo Methodo ology (3) ology (3) ● Two styles of specificatio T t l f ifi ti ons: ● Strict separation between St i t ti b t n syntax definitions and d fi iti d signature definitions – Functional (e.g. PICO typ e checker) ● Modularize syntax definit tions based on sorts or ● Explicit control over applic cation of functions/rewrite rules “functionality”: statement ts, expressions, types, etc. ● Tedious except in combina ation with traversal functions – Algebraic (e.g. Booleans) ● Modularize signature def finitions based on ● No control over application n of rewrite rules functionality: type check, functionality: type check, , evaluate, collect, etc. , evaluate, collect, etc. ● Concise ● Use predefined libraries w whenever possible ● Very local behavior no glo obal information can be used Introduction to ASF+SDF Introduction to ASF+SDF

  2. Methodo Methodo ology (4) ology (4) Methodo Methodo ology (5) ology (5) ● Use prefix functions for s U fi f ti f signature definitions i t d fi iti ● Prevent intervention of le P t i t ti f l exical definitions and i l d fi iti d variable definitions, e.g. ● Make auxiliary signature y g definitions hidden – Start each variable name w with a special character ● Make variables sectio on always hidden “$cat”[0-9]* -> Cate [ ] egory g y ● Make the context-fre M k th t t f ee start-symbols t t b l – Use “*” or “+” in the va ariable name if it is a variable section hidden for a list for a list ● Use proper indentation, e .g. “$cat+”[0-9]* -> Cate egory+ – for each section 2 spaces i for each section 2 spaces i indentation indentation – Use [0-9]* to create Use “[0 9]*” to create e multiple variable occurrences. e multiple variable occurrences – for each production rules e etc. 4 spaces indentation Introduction to ASF+SDF Introduction to ASF+SDF Methodo Methodo ology (6) ology (6) Methodo Methodo ology (7) ology (7) ● Add a comment per set of equ Add t t f uations with the same ti ith th ● Be consistent with the ord B i t t ith th d dering of equations: d i f ti outermost function symbol: – Recursion terminating eith her first of last %% %% – Use consistently the same layout of conditions, e.g. %% hidden: convert-categories(Categor ry*) -> Ast-category* ===> , when , ======== ===== %% More explanatory comments – Ensure that all equations a are excluding via conditions %% [cc-1] convert-categories() = – Use the same order of con Use e s e o de o co nditions if equations have d o s equ o s ve [cc-2] convert-categories({$idenlst t} $cat*) = multiple conditions make-cat(convert-ident ts($idenlst)) L = R1 when C1, C2, … , , …, Ci, Ci+1, …, Cn , , , , convert categories($ca convert-categories($ca at*) at*) vs. ● Hidden auxiliary functions en nforce grouping equations in one module! one module! L = R2 when C1 L = R2 when C1, C2, … C2 …, Ci, C’i+1. …, C’m Ci C’i+1 C’m Introduction to ASF+SDF Introduction to ASF+SDF

  3. Further reading ● www.meta-environment.org ( (select Documentation): ( ( l D i ) – Guided Tour: Playing w with Booleans (flash) – ASF+SDF by Example – Writing Language Defin Writing Language Defin nitions in ASF SDF nitions in ASF+SDF – The Language Specifica ation Formalism ASF+SDF – The Syntax Definition F The Syntax Definition F Formalism SDF Formalism SDF – An Explanation of Error r Messages of SDF (draft) – An Explanation of Error r Messages of ASF (draft) – The Architecture of The e Meta-Environment Introduction to ASF+SDF 9

Recommend


More recommend