meta-programming and mde with rascal · 2020-03-10 · rascal: future development plans...

73
Introduction to Rascal Rascal for Language Development Developing Modelling Languages Tying into Existing Specifications Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der Storm and Jurgen J. Vinju CWI, INRIA ATEAMS, NFI 2nd Workshop on Algebraic Methods in Model-Based Software Engineering (AMMSE 2011) Zurich, Switzerland, 30 June 2011 Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 1/52

Upload: others

Post on 27-Jul-2020

6 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Meta-Programming and MDE with Rascal

Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der Stormand Jurgen J. Vinju

CWI, INRIA ATEAMS, NFI

2nd Workshop on Algebraic Methods in Model-Based SoftwareEngineering (AMMSE 2011)

Zurich, Switzerland, 30 June 2011

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 1/52

Page 2: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Outline

1 Introduction to Rascal

2 Rascal for Language Development

3 Developing Modelling Languages

4 Tying into Existing Specifications

5 Rascal: Future Development Plans

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 2/52

Page 3: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Outline

1 Introduction to Rascal

2 Rascal for Language Development

3 Developing Modelling Languages

4 Tying into Existing Specifications

5 Rascal: Future Development Plans

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 2/52

Page 4: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Outline

1 Introduction to Rascal

2 Rascal for Language Development

3 Developing Modelling Languages

4 Tying into Existing Specifications

5 Rascal: Future Development Plans

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 2/52

Page 5: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Outline

1 Introduction to Rascal

2 Rascal for Language Development

3 Developing Modelling Languages

4 Tying into Existing Specifications

5 Rascal: Future Development Plans

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 2/52

Page 6: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Outline

1 Introduction to Rascal

2 Rascal for Language Development

3 Developing Modelling Languages

4 Tying into Existing Specifications

5 Rascal: Future Development Plans

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 2/52

Page 7: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Rascal: From Algebraic Specification toMeta-Programming

Or...

Lessons learned: ASF to ASF+SDF to Rascal

Some background: design principles of Rascal

Overviews of several Rascal applications, with a focus on MDEand (briefly) linking to existing algebraic specifications

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 3/52

Page 8: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Plug for the Paper

Or...

Lessons learned: ASF to ASF+SDF to Rascal

Some background: design principles of Rascal

Overviews of several Rascal applications, with a focus on MDEand (briefly) linking to existing algebraic specifications

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 3/52

Page 9: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Plug for the Paper

Or...

Lessons learned: ASF to ASF+SDF to Rascal

Some background: design principles of Rascal

Overviews of several Rascal applications, with a focus on MDEand (briefly) linking to existing algebraic specifications

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 3/52

Page 10: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Plug for the Paper

Or...

Lessons learned: ASF to ASF+SDF to Rascal

Some background: design principles of Rascal

Overviews of several Rascal applications, with a focus on MDEand (briefly) linking to existing algebraic specifications

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 3/52

Page 11: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Plug for the Paper

Or...

Lessons learned: ASF to ASF+SDF to Rascal

Some background: design principles of Rascal

Overviews of several Rascal applications, with a focus on MDEand (briefly) linking to existing algebraic specifications

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 3/52

Page 12: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Outline

1 Introduction to Rascal

2 Rascal for Language Development

3 Developing Modelling Languages

4 Tying into Existing Specifications

5 Rascal: Future Development Plans

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 4/52

Page 13: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

What’s Rascal?

Rascal is

a programming language

for source code analysis and transformation

with rich data types, higher-order functions,

specialized control flow, and advanced pattern matching,including matching over concrete syntax.

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 5/52

Page 14: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

What’s Rascal?

Rascal is

a programming language

for source code analysis and transformation

with rich data types, higher-order functions,

specialized control flow, and advanced pattern matching,including matching over concrete syntax.

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 5/52

Page 15: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

What’s Rascal?

Rascal is

a programming language

for source code analysis and transformation

with rich data types, higher-order functions,

specialized control flow, and advanced pattern matching,including matching over concrete syntax.

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 5/52

Page 16: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

What’s Rascal?

Rascal is

a programming language

for source code analysis and transformation

with rich data types, higher-order functions,

specialized control flow, and advanced pattern matching,including matching over concrete syntax.

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 5/52

Page 17: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

What’s Rascal?

Rascal is

a programming language

for source code analysis and transformation

with rich data types, higher-order functions,

specialized control flow, and advanced pattern matching,including matching over concrete syntax.

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 5/52

Page 18: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Rascal Features

Familiar, C or Java-like syntax

Immutable data

Rich built-in data types and pattern matching

Domain-specific constructs (traversals, comprehensions, regularexpressions, fixed-point computation)

Arbitrary context-free grammars with generalized parsing

String templates

Java and Eclipse integration

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 6/52

Page 19: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Extract, Analyze, SYnthesize

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 7/52

Page 20: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Rascal is EASY

Rascal follows the EASY paradigm:

Information is Extracted from the program, such as theprogram’s abstract syntax

This information is then used to Analyze the program, forinstance to check consistency, generate a control flow graph, orbind names to definitions

Finally, the extracted information and the analysis results areused to Synthesize the desired results, such as by transformingthe code or generating visualizations

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 8/52

Page 21: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Domain Analysis for Rascal: Meta-Programming

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 9/52

Page 22: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Outline

1 Introduction to Rascal

2 Rascal for Language Development

3 Developing Modelling Languages

4 Tying into Existing Specifications

5 Rascal: Future Development Plans

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 10/52

Page 23: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Which Language is This?

PROCEDURE Swap(VAR x, y: INTEGER );

VAR

temp: INTEGER;

BEGIN

temp := x;

x := y;

y := temp

END Swap;

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 11/52

Page 24: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Why Look at a Standard Programming Language?

Similar challenges across standard PLs, DSLs, modellinglanguages, etc

Similar desired functionality: IDEs, consistency checking,program analysis, code generation, etc

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 12/52

Page 25: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Why Look at Oberon-0?

Part of work done for tools competition at this year’s LDTA

Focused on features as a showcase for Rascal – shows what onecould do for a language defined in Rascal

Features include checkers, code generation, visualization, IDEmenu links

Not too Oberon specific: features shown are ones you coulduse for your own language

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 13/52

Page 26: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Goals of Oberon-0 Implementation

Modular

Functional

Visual

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 14/52

Page 27: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Goals of Oberon-0 Implementation

Modular

Functional

Visual

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 14/52

Page 28: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Goals of Oberon-0 Implementation

Modular

Functional

Visual

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 14/52

Page 29: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Parsing in Rascal

Grammars defined using Rascal grammar definition notation

A Rascal program then builds a Java-based parser for thegrammar

Parser is GLL with filtering rules used to remove ambiguities

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 15/52

Page 30: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Example: Oberon-0 Grammar

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 16/52

Page 31: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Rascal Meta-Programming Architecture

Grammar Source Code

Rascal Parser

AST Builder

Rascal Interpreter

Interpreter Source Code

Java Compiler

Parser Generator

Rascal Programs

AST Generator

AST Source Code

AST Builder Source Code

InputOutput

build-timerun-time

Parse Tree AST

Parser Source Code

build-time flow

run-time flow

data

operation

legend

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 17/52

Page 32: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Code Outlining Example: Java in Eclipse

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 18/52

Page 33: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Outlining Support in Rascal: Building the Outline

Outlines are built over the concrete syntax of a language

Labels indicate the display name in the outline view

Locations allow the user to jump to the outlined item

Once the outliner is registered, the runtime keeps the view upto date as the source is edited

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 19/52

Page 34: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Code Outlining Example: Oberon-0 in Rascal

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 20/52

Page 35: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Annotators

Annotators allow annotations to be added to languageconstructs and displayed in the editor

Typical examples: name resolution, type checking – want errorsto be displayed graphically to users, marking error locations

public Module checkModule(Module x) {

m = implode(x);

<m, st> = resolve(m);

errors = { error(l, s) | <l, s> <- st.scopeErrors };

if (errors == {}) {

errors = check(m, st.symbolTable);

}

return x[@messages = errors];

}

registerAnnotator("l4", checkModule);

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 21/52

Page 36: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Annotator Example: Type Checking Oberon-0

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 22/52

Page 37: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Contributors

Contributors provide a way to add more advanced functionality

Each contribution is a menu item – execution is triggered bythe user

Examples: interaction with external tools, compilation,visualization

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 23/52

Page 38: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

An Example Contributors Menu

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 24/52

Page 39: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

ParsingOutlinersAnnotatorsContributors OverviewRascal-based Contributors

Visualization Contribution: Control Flow Graph

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 25/52

Page 40: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Outline

1 Introduction to Rascal

2 Rascal for Language Development

3 Developing Modelling Languages

4 Tying into Existing Specifications

5 Rascal: Future Development Plans

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 26/52

Page 41: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Goals

First, define a language, with support tools, for entities

Then, extend this to support packages for modularity

Next, extend this language to support entity instances

Finally, add modular extensions to the language

Note: Work by Tijs van der Storm, presented at LWC’11 by JurgenJ. Vinju

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 27/52

Page 42: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Goals

First, define a language, with support tools, for entities

Then, extend this to support packages for modularity

Next, extend this language to support entity instances

Finally, add modular extensions to the language

Note: Work by Tijs van der Storm, presented at LWC’11 by JurgenJ. Vinju

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 27/52

Page 43: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Entities and Instances

Immediate IDE: highlighting, folding, error marking, etc

Java and SQL generation

Online checking and error marking

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 28/52

Page 44: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

An IDE for Entities

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 29/52

Page 45: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Generating Java Code

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 30/52

Page 46: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Generating SQL Code

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 31/52

Page 47: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Defining Entity Concrete Syntax

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 32/52

Page 48: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Defining Entity Abstract Syntax

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 33/52

Page 49: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

String Template-based Code Generation

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 34/52

Page 50: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Checking Entities

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 35/52

Page 51: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Registering the Contributors

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 36/52

Page 52: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Adding Packages: Package Concrete Syntax

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 37/52

Page 53: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Resolving Names

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 38/52

Page 54: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Generating Java Code

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 39/52

Page 55: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Results

4 languages defined in total

5 total IDEs (1 for Rascal, plus 4 more)

3 checkers defined

3 Java code generators created

1 SQL code generator created

2 XML code generators created

Total SLOC: 950

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 40/52

Page 56: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

A Language for Entities and InstancesEntitiesAdding PackagesSummary of ResultsDerric

Derric

Developed for digital forensics

Allows specification of file formats using a DSL

Compiled to optimized Java code

Total code size: 1871 SLOC

Highly competitive in both speed and precision

Developed by a PhD student working at the NFI (DutchForensics Institute)

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 41/52

Page 57: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Integration with External Tools

Outline

1 Introduction to Rascal

2 Rascal for Language Development

3 Developing Modelling Languages

4 Tying into Existing Specifications

5 Rascal: Future Development Plans

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 42/52

Page 58: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Integration with External Tools

Integrating Rascal with K Specifications in Maude

Contributors in Rascal-based IDEs are not limited to thosewritten in Rascal

Example: linking a Rascal-based front-end with a Maude-basedanalysis framework

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 43/52

Page 59: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Integration with External Tools

What is Needed to Make the Link (Rascal)?

Grammar for the language

Maudeifier to generate Maude-readable form of program

Support for starting, reading from, writing to, and stoppingMaude

Support for preparing individual tasks and reading back results

Eclipse interaction to display results

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 44/52

Page 60: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Integration with External Tools

What is Needed to Make the Link (Maude)?

Specification support for Rascal source locations (if used)

Result generation in parsable format (not necessarily humanreadable)

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 45/52

Page 61: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Integration with External Tools

Displaying Analysis Results

Information from the external tool can be used to set upannotations...

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 46/52

Page 62: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Integration with External Tools

Displaying Analysis Results (2)

... and to add other information, such as entries in an EclipseProblems view.

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 47/52

Page 63: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Outline

1 Introduction to Rascal

2 Rascal for Language Development

3 Developing Modelling Languages

4 Tying into Existing Specifications

5 Rascal: Future Development Plans

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 48/52

Page 64: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Rascal Development: A Rough Future Timeline

Syntax: features and documentation finished by the end ofSeptember for an early October release

Performance: ongoing work on improving the performance ofprogram evaluation, with special focus on function call andpattern match performance

Type Checking: currently uses a runtime type system,switching over to static system – work mostly done, butintegrating into Rascal more closely, improving performance soit can run constantly as files are edited

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 49/52

Page 65: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Rascal Development: A Rough Future Timeline

Syntax: features and documentation finished by the end ofSeptember for an early October release

Performance: ongoing work on improving the performance ofprogram evaluation, with special focus on function call andpattern match performance

Type Checking: currently uses a runtime type system,switching over to static system – work mostly done, butintegrating into Rascal more closely, improving performance soit can run constantly as files are edited

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 49/52

Page 66: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Rascal Development: A Rough Future Timeline

Syntax: features and documentation finished by the end ofSeptember for an early October release

Performance: ongoing work on improving the performance ofprogram evaluation, with special focus on function call andpattern match performance

Type Checking: currently uses a runtime type system,switching over to static system – work mostly done, butintegrating into Rascal more closely, improving performance soit can run constantly as files are edited

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 49/52

Page 67: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Rascal in Moving to Eclipse.org!

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 50/52

Page 68: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Wrapping Up

The Rascal Language

Rascal for Language Development

MDE: Entities

MDE: Derric

Linking to Existing Specifications

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 51/52

Page 69: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Wrapping Up

The Rascal Language

Rascal for Language Development

MDE: Entities

MDE: Derric

Linking to Existing Specifications

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 51/52

Page 70: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Wrapping Up

The Rascal Language

Rascal for Language Development

MDE: Entities

MDE: Derric

Linking to Existing Specifications

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 51/52

Page 71: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Wrapping Up

The Rascal Language

Rascal for Language Development

MDE: Entities

MDE: Derric

Linking to Existing Specifications

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 51/52

Page 72: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

Wrapping Up

The Rascal Language

Rascal for Language Development

MDE: Entities

MDE: Derric

Linking to Existing Specifications

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 51/52

Page 73: Meta-Programming and MDE with Rascal · 2020-03-10 · Rascal: Future Development Plans Meta-Programming and MDE with Rascal Jeroen van den Bos, Mark Hills, Paul Klint, Tijs van der

Introduction to RascalRascal for Language Development

Developing Modelling LanguagesTying into Existing Specifications

Rascal: Future Development Plans

For More Information...

Rascal: http://www.rascal-mpl.org

IMP: http://www.eclipse.org/imp

CWI SEN1: http://www.cwi.nl/sen1

Van den Bos, Hills, Klint, Van der Storm, Vinju Meta-Programming and MDE with Rascal 52/52