50 likes | 255 Views
ASF+SDF. ASF+SDF Goal: defining syntax and semantics of languages SDF: Syntax Definition Formalism goal to define: lexical syntax: keywords, comments, constants, identifiers context-free syntax: declarations, statements modular and declarative ASF: Algebraic Specification Formalism
E N D
ASF+SDF • ASF+SDF • Goal: defining syntax and semantics of languages • SDF: Syntax Definition Formalism • goal to define: • lexical syntax: keywords, comments, constants, identifiers • context-free syntax: declarations, statements • modular and declarative • ASF: Algebraic Specification Formalism • goal to define: • static semantics: scope and type of variables • dynamic semantics: evaluation • syntax-directed transformations • modular and uses concrete syntax • traversal functions
ASF+SDF Anatomy of an ASF+SDF module Name of this module; may be followed by parameters Names of modules imported by this module module ModuleName ImportSection* ExportOrHiddenSection* equations ConditionalEquation* Grammar elements that are visible from the outside (exports) or only inside the module (hiddens) imports, aliases, sorts, lexical syntax, context-free syntax, priorities, variables Unconditional: [tagId] L = R Conditional: [tagId] C1, C2, …, Cn ========== L = R
Traversal functions in ASF+SDF • Many functions have the characteristic that they traverse the tree recursively and only do something interesting at a few nodes • Example: count the identifiers in a program • Using a recursive (inductive) definition: • # of equations is equal to number of syntax rules • think about Cobol or Java with hundreds of rules • Traversal functions automate recursion
ASF+SDF Meta-Environment • IDE for ASF+SDF • syntax-directed editing of specifications • integrated access to the libraries • integrated compilation and testing/debugging of specifications • Open, robust and extendable architecture, based on third-party software and reusable components • Efficient and scalable technology