introduction to asf sdf asf sdf
play

Introduction to ASF+SDF ASF+SDF Goal: defining languages & - PowerPoint PPT Presentation

Introduction to ASF+SDF ASF+SDF Goal: defining languages & manipulating programs Mark van den Brand SDF: Syntax definition Formalism Paul Klint Jurgen Vinju lexical & context-free syntax ASF: Algebraic Specification


  1. Introduction to ASF+SDF ASF+SDF ● Goal: defining languages & manipulating programs Mark van den Brand ● SDF: Syntax definition Formalism Paul Klint Jurgen Vinju – lexical & context-free syntax ● ASF: Algebraic Specification Formalism – static & dynamic semantics; fact extraction ● ASF+SDF Meta-Environment: IDE for ASF+SDF ● Manuals/documentation: www.meta-environment.org Introduction to ASF+SDF 1 Introduction to ASF+SDF 2 What is a Program Generator? Programming Environment Generator Declarative program Formal definition Definition of of language L problem P Generator Generator Operational program Dedicated environment Generated program that solves P for editing, manipulating and executing L programs Introduction to ASF+SDF 3 Introduction to ASF+SDF 4

  2. Programming Environment Generator ASF+SDF Meta-Environment = collection of program generators ASF+SDF Meta-Environment Definition of Definition of Definition of L syntax L static semantics L dynamic semantics Interactive Formal definition of language L (written in ASF+SDF) Development Environment Typechecker Evaluator Parser for Language Generator Generator Generator Generator definitions Stand-alone, L- parser L -typechecker L -evaluator Generated L generated, programming environment Integrated L -programming environment environment Introduction to ASF+SDF 5 Introduction to ASF+SDF 6 Typing ����������� ... ASF+SDF Meta-Environment ● An interactive development environment for generating tools from formal language definitions ● Based on: – Full context-free grammars – Conditional term rewriting ● Language definitions written in ASF+SDF – SDF: Syntax definition Formalism – ASF: Algebraic Specification Formalism Introduction to ASF+SDF Introduction to ASF+SDF 8

  3. Anatomy of ASF+SDF specifications Anatomy of an ASF+SDF Module Name of this module; may be followed by parameters Names of modules imported by this module; �������� �������� ������� ModuleName May be followed by renamings ��� ��� ImportSection* ����������� Grammar elements that are visible from the ExportOrHiddenSection* ��� outside ( ������� ) or only inside the module ��������� ) ( ������� ). ConditionalEquation* ������������������������ �������� �������� ���� �!�"�#�$ ��������������� ��� ��� Unconditional: �������������������� ��������� ���� �!�� % ��� & �������� Conditional: ��������������������� � ��� ############ "�#�$ Introduction to ASF+SDF 9 Introduction to ASF+SDF 10 BoolCon: Boolean Constants Plan ● Booleans The sort of Boolean constants, sorts ������������'������� Should always start with a capital letter ● Steps towards a Pico environment ������� The constants ���� and ����� , literals ������������� – Step 1: define syntax should always be quoted ������������������� (����(�����)�������� – Step 2: define a typechecker (�����(����)�������� – Step 3: define an evaluator – Step 4: define a compiler ● Traversal functions – Step 5: define a fact extractor Introduction to ASF+SDF 11 Introduction to ASF+SDF 12

  4. Booleans (1) Booleans (2) The infix operators and - and or * . ������������'�������� Import Boolean constants Both are left-associative ( ���� ) �������������'������� ��������� The prefix function ��� ��������(*(������������)���������+����, ������������� ��������(-(�����������)���������+����, The sort of Boolean expressions 0 and 1 may be used as brackets in ������������������� .���/ 0�������1�����������)�������� ����������)�������� (0(���������(1(������������)���������+����2��, Each Boolean constant is a Boolean Boolean expressions; expression, also-called they are ignored after parsing ����������������������� injection rule or chain rule ��������(-(����������)���������) - has higher priority than * ��������(*(����������)�������� Example: ���� -����� *����� is interpreted as: 0���� -�����1�*����� Introduction to ASF+SDF 13 Introduction to ASF+SDF 14 Booleans (3) Booleans (4) The start symbol of a grammar. Without a start symbol the parser does ������� not know how to start parsing an input ������������������� �������������������������� sentence .���/ 0�������1�����������)�������� ������� (0(���������(1(������������)���������+����2��, Shorthand for defining the infix ������� operators and ( � ) and ( � ). Import the standard comment ����������������������� �����'�������� Both are left-associative ( ���� ). conventions for equations ��������(-(����������)���������+����,�) ��������(*(����������)���������+����, These rules are promoted to ��������� context-free syntax rules (����(�3�456!7���)�������� Declares the variables ���� , ����% , ����& , ����8 , ����88 , ����%8 , etc. Introduction to ASF+SDF 15 Introduction to ASF+SDF 16

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