Extensible Type-Driven Parsing for Embedded DSLs in Wyvern Cyrus Omar Benjamin Chung Darya Kurilova Ligia Nistor Alex Potanin (Victoria University of Wellington)

Slides:



Advertisements
Similar presentations
CSCI N241: Fundamentals of Web Design Copyright ©2004 Department of Computer & Information Science Introducing XHTML: Module B: HTML to XHTML.
Advertisements

Microsoft Research March 20, 2000 A Programming Language for Developing Interactive Web Services Claus Brabrand BRICS, University of Aarhus, Denmark.
CS7100 (Prasad)L16-7AG1 Attribute Grammars Attribute Grammar is a Framework for specifying semantics and enables Modular specification.
Basics of HTML What is HTML?  HTML or Hyper Text Markup Language is the standard markup language used to create Web pages.  HTML is.
Visual Web Information Extraction With Lixto Robert Baumgartner Sergio Flesca Georg Gottlob.
CS 330 Programming Languages 09 / 13 / 2007 Instructor: Michael Eckmann.
Context-sensitive Analysis, II Ad-hoc syntax-directed translation, Symbol Tables, andTypes.
Chapter 3 Program translation1 Chapt. 3 Language Translation Syntax and Semantics Translation phases Formal translation models.
1 Dan Quinlan, Markus Schordan, Qing Yi Center for Applied Scientific Computing Lawrence Livermore National Laboratory Semantic-Driven Parallelization.
BİL744 Derleyici Gerçekleştirimi (Compiler Design)1.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Introducing XHTML: Module B: HTML to XHTML. Goals Understand how XHTML evolved as a language for Web delivery Understand the importance of DTDs Understand.
Introducing HTML & XHTML:. Goals  Understand hyperlinking  Understand how tags are formed and used.  Understand HTML as a markup language  Understand.
A Formal Model of Modularity in Aspect-Oriented Programming Jonathan Aldrich : Objects and Aspects Carnegie Mellon University.
CS784 (Prasad)L167AG1 Attribute Grammars Attribute Grammar is a Framework for specifying semantics and enables Modular specification.
Type-Directed, Whitespace-Delimited Parsing for Embedded DSLs Cyrus Omar School of Computer Science Carnegie Mellon University [GlobalDSL13] Benjamin ChungAlex.
A First Program Using C#
Sumant Tambe, et. al LEESA DSPD 2008 An Embedded Declarative Language for Hierarchical Object Structure Traversal Sumant Tambe* Aniruddha Gokhale Vanderbilt.
Xactium xDSLs Run Models Not Code Tony Clark
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
Sumant Tambe, et. al LEESA DSPD 2008 An Embedded Declarative Language for Hierarchical Object Structure Traversal Sumant Tambe* Aniruddha Gokhale Vanderbilt.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
Composable and Hygienic Typed Syntax Macros (TSMs) Cyrus Omar Chenglong (Stanley) Wang Jonathan Aldrich School of Computer Science Carnegie Mellon University.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
1 Extending Java And Developing DSLs With Open Source Language Workbench JetBrains MPS Konstantin Solomatov JetBrains Lead Developer for JetBrains MPS.
Tree-adjoining grammar (TAG) is a grammar formalism defined by Aravind Joshi and introduced in Tree-adjoining grammars are somewhat similar to context-free.
Winter 2007SEG2101 Chapter 71 Chapter 7 Introduction to Languages and Compiler.
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XML.
A Little Language for Surveys: Constructing an Internal DSL in Ruby H. Conrad Cunningham Computer and Information Science University of Mississippi.
Safely Composable Type-Specific Languages (TSLs) Cyrus Omar Darya Kurilova Ligia Nistor Benjamin Chung Alex Potanin (Victoria University of Wellington)
1 SystemVerilog Enhancement Requests Daniel Schostak Principal Engineer February 26 th 2010.
XHTML By Trevor Adams. Topics Covered XHTML eXtensible HyperText Mark-up Language The beginning – HTML Web Standards Concept and syntax Elements (tags)
Active Code Completion Cyrus Omar Computer Science School of Computer Science Carnegie Mellon University [ICSE12] YoungSeok Yoon Software Engineering Brad.
Safely-Composable Type-Specific Languages (TSLs) Cyrus Omar Darya Kurilova Ligia Nistor Benjamin Chung Alex Potanin (Victoria University of Wellington)
Python Functions.
Scaling Heterogeneous Databases and Design of DISCO Anthony Tomasic Louiqa Raschid Patrick Valduriez Presented by: Nazia Khatir Texas A&M University.
Copyright © 2006 Addison-Wesley. All rights reserved. Ambiguity in Grammars A grammar is ambiguous if and only if it generates a sentential form that has.
The Functions and Purposes of Translators Syntax (& Semantic) Analysis.
Weaving a Debugging Aspect into Domain-Specific Language Grammars SAC ’05 PSC Track Santa Fe, New Mexico USA March 17, 2005 Hui Wu, Jeff Gray, Marjan Mernik,
Introduction to Compiling
Secure Systems Research Group - FAU 1 A Trust Model for Web Services Ph.D Dissertation Progess Report Candidate: Nelly A. Delessy, Advisor: Dr E.B. Fernandez.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
OOPSLA workshop on Domain-Specific Visual Languages 1 Juha-Pekka Tolvanen, Steven Kelly, Jeff Gray, Kalle Lyytinen.
Representing data with XML SE-2030 Dr. Mark L. Hornick 1.
Syntax and Grammars.
Introduction to DTD A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines the document structure with a list.
The Interpreter Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
The Database and Info. Systems Lab. University of Illinois at Urbana-Champaign Understanding Web Query Interfaces: Best-Efforts Parsing with Hidden Syntax.
Concepts and Realization of a Diagram Editor Generator Based on Hypergraph Transformation Author: Mark Minas Presenter: Song Gu.
Chap. 7, Syntax-Directed Compilation J. H. Wang Nov. 24, 2015.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
SEMI-STRUCTURED DATA (XML) 1. SEMI-STRUCTURED DATA ER, Relational, ODL data models are all based on schema Structure of data is rigid and known is advance.
JSON. JSON as an XML Alternative JSON is a light-weight alternative to XML for data- interchange JSON = JavaScript Object Notation It’s really language.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
A Framework for Automated and Composable Testing of Component-based Services Miguel A. Jiménez, Ángela Villota, Norha M. Villegas, Gabriel Tamura, Laurence.
CS416 Compiler Design1. 2 Course Information Instructor : Dr. Ilyas Cicekli –Office: EA504, –Phone: , – Course Web.
Chapter 3 – Describing Syntax CSCE 343. Syntax vs. Semantics Syntax: The form or structure of the expressions, statements, and program units. Semantics:
Defects of UML Yang Yichuan. For the Presentation Something you know Instead of lots of new stuff. Cases Instead of Concepts. Methodology instead of the.
LECTURE 10 Semantic Analysis. REVIEW So far, we’ve covered the following: Compilation methods: compilation vs. interpretation. The overall compilation.
Chapter 3 – Describing Syntax
The Object-Oriented Thought Process Chapter 11
Introduction to Parsing
Introduction to Parsing (adapted from CS 164 at Berkeley)
Pattern-Directed Programming
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Lec00-outline May 18, 2019 Compiler Design CS416 Compiler Design.
COMPILER CONSTRUCTION
Presentation transcript:

Extensible Type-Driven Parsing for Embedded DSLs in Wyvern Cyrus Omar Benjamin Chung Darya Kurilova Ligia Nistor Alex Potanin (Victoria University of Wellington) Jonathan Aldrich ‘13] School of Computer Science Carnegie Mellon University

Wyvern 2 Goals: Secure web and mobile programming within a single statically-typed language. Compile-time support for a variety of domains: Security policies and architecture specifications Client-side programming (HTML, CSS) Server-side programming (Databases)

3 Monolithic languages where domain-specific features must be anticipated and built in are unsustainable. FeaturesLanguage

4 Better approach: an internally-extensible language where compile-time features can be distributed in libraries. FeaturesLanguageLibrary

Expressivity vs. Safety 5 Want expressive (syntax) extensions. But if you give each DSL too much control, they may interfere with one another at link-time.

Example: SugarJ 6 Libraries can extend the base syntax of the language These extensions are imported transitively Extensions can interfere: Pairs vs. Tuples HTML vs. XML Different implementations of the same syntax [Erdweg et al, 2010]

Our Solution 7 Libraries cannot extend the base syntax of the language Instead, syntax is associated with types. This type-specific syntax can be used to create values of that type.

Examples: HTML and URL s 8

Type-Specific Literals (TSLs) 9 Several inline forms are available `dsl syntax here, \`inner backticks\` must be escaped` 'dsl syntax here, \'inner single quotes\' must be escaped' {dsl syntax here, {inner braces} must be balanced} [dsl syntax here, [inner brackets] must be balanced] others? If you use the tilde (~) with whitespace, there are no restrictions on the code inside. Layout determines the end of the block.

Phase I: Top-Level Parsing 10 The top-level layout-sensitive syntax of Wyvern can be parsed first without involving the typechecker Useful for tools like documentation generators Wyvern’s grammar can be written down declaratively using a layout-sensitive formalism [Erdweg et al. 2012; Adams 2013] TSL code (and Wyvern expressions inside it) is left unparsed during this phase

Phase II: Typechecking and DSL Parsing 11 When a TSL is encountered during typechecking, its expected type is determined via: Explicit annotations Method signatures Type propagation into where clauses The TSL is now parsed according to the type- associated syntax. Any internal Wyvern expressions are also parsed (I & II) and typechecked recursively during this phase.

12 type HTML = … def tagName : string … attributes = new def parser : Parser = new def parse(s : TokenStream) : AST = … code to parse HTML … type Parser = def parse(s : TokenStream) : AST Associating a Parser with a type

13 type HTML = … def tagName : string … attributes = new def parser : Parser = ~ start ::= (“ ” start “ ”)* | “{“ EXP : HTML “}” tag ::=... Associating a grammar with a type

Benefits 14 Modularity and Safe Composability DSLs are distributed in libraries, along with types No link-time errors Identifiability Can easily see when a DSL is being used Can determine which DSL is being used by identifying expected type DSLs always generate a value of the corresponding type Simplicity Single mechanism that can be described in a few sentences Specify a grammar in a natural manner within the type Flexibility Whitespace-delimited blocks can contain arbitrary syntax

Types Organize Languages 15 Types represent an organizational unit for programming language semantics. Types are not only useful for traditional verification, but also safely-composable language-internal (syntax) extensions.

Examples 16

Ongoing Work 17

Are all forms equivalent? 18 That is, these three forms could be exactly equivalent, assuming f takes a single argument of type URL f(~) f(` f([ f(“ ) (String literals are simply a DSL associated with the String type!) Alternatively, types could restrict the valid forms of identifier to allow the language itself to enforce conventions.

Keyword-Directed Invocation 19 Most language extension mechanisms invoke DSLs using functions or keywords (e.g. macros), rather than types. The keyword-directed invocation strategy can be considered a special case of the type-directed strategy. The keyword is simply a function taking one argument. The argument type specifies a grammar that captures one or more expressions.

Example: Control Flow 20 if : bool -> (unit -> a), (unit -> a) -> a IfBranches if(in_france, ~) do_as_the_french_do() else panic() if(in_france) do_as_the_french_do() else panic()

Interaction with Subtyping 21 With subtyping, multiple subtypes may define a grammar. Possible Approaches: Use only the declared type of functions Explicit annotation on the tilde Parse against all possible grammars, disambiguate as needed Other mechanisms?

Interaction with Tools 22 Syntax interacts with syntax highlighters + editor features. Still need to figure out how to support type-specific syntax in these contexts. Borrow ideas from language workbenches?

Related Work 23

Active Libraries [Veldhuizen, 1998] Active libraries are not passive collections of routines or objects, as are traditional libraries, but take an active role in generating code. 24

Active Code Completion [Omar et al, ICSE 2012] Use types similarly to control the IDE’s code completion system. 25

26 Active Code Completion with GRAPHITE

27 Active Code Completion with GRAPHITE

28 Active Code Completion with GRAPHITE

29 Active Code Completion with GRAPHITE

Active Typechecking & Translation [Omar and Aldrich, presented at DSLDI 2013] Use types to control typechecking and translation. Implemented in the Ace programming language. 30