What Every Xtext User Wished to Know Industry Experience of Implementing 80+ DSLs

Similar documents
Contents I Introduction 1 Introduction to PL/SQL iii

Introduction to Computer Science and Business

Using Scala for building DSL s

Comparison and merge use-cases from practice with EMF Compare

Building Compilers with Phoenix

Semantic Analysis. Compiler Architecture

Domain-Specific Languages for Composable Editor Plugins

Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan

Informal Semantics of Data. semantic specification names (identifiers) attributes binding declarations scope rules visibility

Model transformations. Model transformations. Model transformations. Model transformations

ABAP DSL Workbench SAP TechED 2016

with openarchitectureware

Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan

Arbori Starter Manual Eugene Perkov

The role of semantic analysis in a compiler

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler so far

CMSC 132: Object-Oriented Programming II

Domain-Specific Languages Language Workbenches

Delivery Options: Attend face-to-face in the classroom or remote-live attendance.

CSE 307: Principles of Programming Languages

The Structure of a Syntax-Directed Compiler

Better Extensibility through Modular Syntax. Robert Grimm New York University

BIG MODELS AN ALTERNATIVE APPROACH

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

Lecture 7: Type Systems and Symbol Tables. CS 540 George Mason University

Compositional Model Based Software Development

IZ0-144Oracle 11g PL/SQL Certification (OCA) training

An Implementation of the Behavior Annex in the AADL-toolset Osate2

Domain-Specific. Languages. Martin Fowler. AAddison-Wesley. Sydney Tokyo. With Rebecca Parsons

Real Application Security Administration

MOC 6232A: Implementing a Microsoft SQL Server 2008 Database

RECODER - The Architecture of a Refactoring System

Introduction to OpenArchitectureWare

Anatomy of a Compiler. Overview of Semantic Analysis. The Compiler So Far. Why a Separate Semantic Analysis?

Graph-based analysis of JavaScript source code repositories

Chapter 6 Architectural Design. Lecture 1. Chapter 6 Architectural design

Compiler Errors. Flash CS4 Professional ActionScript 3.0 Language Reference. 1 of 18 9/6/2010 9:40 PM

The Compiler So Far. CSC 4181 Compiler Construction. Semantic Analysis. Beyond Syntax. Goals of a Semantic Analyzer.

Semantic Analysis. Lecture 9. February 7, 2018

COMP322 - Introduction to C++

Time : 1 Hour Max Marks : 30

Chapter 1: Getting Started. You will learn:

Semantic Analysis and Type Checking

CS152 Programming Language Paradigms Prof. Tom Austin, Fall Syntax & Semantics, and Language Design Criteria

Index. Comma-separated values (CSV), 30 Conditional expression, 16 Continuous integration (CI), 34 35, 41 Conway s Law, 75 CurrencyPair class,

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)

Robert Grimm New York University

Developing Web-Based Applications Using Model Driven Architecture and Domain Specific Languages

Combined Object-Lambda Architectures

When Modeling meets Productivity. Sven Efftinge - itemis

Plan. Language engineering and Domain Specific Languages. Language designer defines syntax. How to define language

CMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are "built" on top of that.

CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009

Declarative Language Definition

Eclipse technology in IFMS Interface Management System

CMSC 132: Object-Oriented Programming II

Compiler construction

Table of Contents. PDF created with FinePrint pdffactory Pro trial version

Client-side SOAP in S

DSL Implementation. ... with language Workbenches. v1.1 Jan 16, Markus Voelter independent/itemis

Undergraduate Compilers in a Day

Oracle Database 12c: Program with PL/SQL Duration: 5 Days Method: Instructor-Led

xtc Robert Grimm Making C Safely Extensible New York University

Lecture 16: Static Semantics Overview 1

Implementation of F# language support in JetBrains Rider IDE

5. Single-row function

Introduction to Dependable Systems: Meta-modeling and modeldriven

CSE 12 Abstract Syntax Trees

use attributes (); # optional, to get subroutine declarations = attributes::get(\&foo);

Introduce C# as Object Oriented programming language. Explain, tokens,

A little History Domain Specific Languages Examples Tools Benefits A more theoretical View Programming and Modeling The LWES Project Bonus: Best

Programming Languages Third Edition. Chapter 7 Basic Semantics

IBM Security Access Manager Version 9.0 October Federation Administration topics IBM

Oracle Database. Installation and Configuration of Real Application Security Administration (RASADM) Prerequisites

Language engineering and Domain Specific Languages

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Acknowledgement. CS Compiler Design. Semantic Processing. Alternatives for semantic processing. Intro to Semantic Analysis. V.

Scope. COMP 524: Programming Language Concepts Björn B. Brandenburg. The University of North Carolina at Chapel Hill

Syntax Errors; Static Semantics

C++11: 10 Features You Should be Using. Gordon R&D Runtime Engineer Codeplay Software Ltd.

EMF course - PACT. Etienne Borde

Oracle Database 11g: Program with PL/SQL Release 2

Syntax-Directed Translation. Lecture 14

SE352b: Roadmap. SE352b Software Engineering Design Tools. W3: Programming Paradigms

UML&AADL 11 An Implementation of the Behavior Annex in the AADL-toolset OSATE2

Generic Language Technology

Delivery Options: Attend face-to-face in the classroom or via remote-live attendance.

9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation

Oracle Database: Program with PL/SQL

SQL Developer Oracle Migration Workbench Taking Database Migration to the next level

Transformation of Java Card into Diet Java Card

Oracle PLSQL Training Syllabus

Oracle Database: Program with PL/SQL Ed 2

Core Capabilities Part 3

RAPID Resource API Design Language

Chapter 4 Defining Classes I

SQL: Data De ni on. B0B36DBS, BD6B36DBS: Database Systems. h p:// Lecture 3

Grammars. Prof. Andreas Prinz. Introduction, Compilers. Examples Meta-models vs. Grammars Summary

IncQuery for MagicDraw Quick Start Guide

Universal Data Modelling Generator User Manual

Transcription:

What Every Xtext User Wished to Know Industry Experience of Implementing 80+ DSLs EclipseCon Europe 2016 2016-10-26 Roman Mitin Avaloq Evolution AG Allmendstrasse 140 8027 Zurich Switzerland T +41 58 316 10 10 F +41 58 316 10 19 www.avaloq.com

Avaloq Technology-driven financial services provider 450 customer sites 4 BPO centres 2 200 employees 22 offices in 10 countries Own software platform for core, web and mobile banking 1 350+ certified implementation experts 2

Domain-specific Languages at Avaloq Standard DSLs WSDL, RAML, XSD, XML Avaloq DSLs Not a DSL PL/SQL API, Java API Business DSLs: BPMN, business objects & rules Visual DSLs with tabular or graphical editors Technical DSLs: i.e. Oracle objects Textual editors, enforce coding conventions Core system 100+ source types 3

Lessons of First Project with Xtext 4

Lessons of First Xtext Project: Editors for Existing Languages Favor explicit design of AST With Xtext we still model source code Model lists as lists (order, duplicates) Validate node model if needed Parser, recovery and partial reparse Relax grammar and write checks Avoid unordered groups Syntactic predicates can be slow No to backtracking for prototyping Extend Xtext if needed Semantic predicates, custom lexer 5

Lessons of First Xtext Project: Editors for Existing Languages Favor explicit design of AST With Xtext we still model source code Model lists as lists (order, duplicates) Validate node model if needed Parser, recovery and partial reparse Relax grammar and write checks Avoid unordered groups Syntactic predicates can be slow No to backtracking for prototyping Extend Xtext if needed Semantic predicates, custom lexer 6

Lessons of First Xtext Project: Editors for Existing Languages Favor explicit design of AST With Xtext we still model source code Model lists as lists (order, duplicates) Validate node model if needed Parser, recovery and partial reparse Relax grammar and write checks Avoid unordered groups Syntactic predicates can be slow No to backtracking for prototyping Extend Xtext if needed Semantic predicates, custom lexer 7

Scale All-In-Memory Index of Xtext Developer checks out few sources Only incremental builds in IDE Prebuilt index Model server Layered view on index Local H2 DB for index delta Changed & invalidated models Sources (~90k, 600 MB text) Resources Exported objects (~2M) References (~10M) Issues 8

Implementation Standards for DSLs with DSLs Xtext Check EMF Scope Format Export Available on GitHub 9

Check DSL Xbase enhanced for model validation execution time severity name /** SCA Check Documentation. */ live error "Procedure name too long" (int maxlength = 10) message "Procedure name exceeds {0 of characters." { for ProcedureDeclaration p { if (p.name.length > maxlength) { issue on p#name bind (maxlength.tostring) raise a diagnostic context [alias] 10

Format DSL Semantic-aware source text formatting NamedArgument : target=[typemodel:inamedparameter ID] "=>" value=expression ; NamedArgument { rule : linewrap 0 1 1 after, no_linewrap after { (context.econtainer as ArgumentList).arguments.size == 1 ; "=>" : column {FormatUtil::getLongestNameLength(context) relative before { (context.econtainer as ArgumentList).arguments.size > 1 ; 11

Fine-grained dependency analysis Single resource fingerprint Source 1 A Object fingerprints Source 1 A B B C C Source 2 Source 2 Ref to C Ref to C Requires stable URI fragments "semi-positional syntax with selectors for not unique names e.g. 0/1/3(0=='foo').0 and 0/1/3(0=='foo').1 for objects 'foo for unique names add '!' and omit last part: e.g. 0/1/3(0=='foo'!) Price: every visible declaration must have an exported object 12

Export DSL Resource description strategy, fingerprints, fragment provider import http://www.avaloq.com/tools/dsl/avqscript Calculation method for object fingerprints Object descriptions visible in index queries interface { ScriptPackage = name; MethodDeclaration = @+modifiers, @parameters; FunctionDeclaration = @returntype; Declaration = name;... export lookup ScriptPackage as qualified name { object-fingerprint; Fingerprint for data public = this.public; fine-grained invalidation Index entries for fine-grained invalidation with fragment structure // Only non-private methods should be exported export MethodDeclaration as name [!this.private] { uri-fragment = unique attribute (name); object-fingerprint; Defines stable segment for fragment provider 13

Scope DSL (1/2) Naming, scope provider, implicit references, caches scoping com.avaloq.tools.dsl.keydef.keydef with com.avaloq.tools.dsl.avqscript.avqscript Default naming functions for EClasses case insensitive naming { codetab::row = this.name; typemodel::inamedelement = this.name; All EObjects of EClass Row from code_obj_type namespace Reference-specific scope for feature type of EClass ObjType doing Index lookup scope ObjType#type { context * = find( codetabdata::row, key = "code_obj_type.*" ); Invariant for resource 14

Scope DSL (2/2) Type-specific named scope with simple Expression for KeyDef context object scope (implicitvariables) INamedElement { context KeyDef = this.getimplicitvariables(); Delegation to a named scope Named scope with scope chain containing delegation to a named scope, index query and local expression scope (decls) INamedElement { context CalculationBlock = scopeof(this, implicitvariables) >> find( avqscript::scriptpackage ) as name >> this.getlocaldeclarations() ; Chain of three scopes Explicitly defined name function 15

Xtext Extensions & Tips ANTLR Semantic Predicates Distributed Builder Xtext Parser Delegation Object Fingerprints Testing with Xtend 16

Testing with Xtend Easy to write and understand tests class LabelLinkingTest extends AbstractDdkScopingTest { @Tag int LABEL_A override registerrequiredsources() { addsourcetoworkspace("test.label DEF",''' label definitions test label «mark(label_a)»label.a fallback "fallback" end label definitions '''); @Test def testlabellinking(){ validatelinks("test.e.label XLATE",''' label translations test.e translation «ref(label_a)»label.a text "text" end label translations '''); Same pattern for Linking tests Scoping tests Validation tests Content assist tests Syntax coloring tests 17

Test Failure Reporting Clear test failure messages 18

Parser Delegation Where inheritance fails: mix DSLs with incompatible lexers Call parser from value converter Merge the node model returned by the parser AvaloqScriptExpression returns avqscript::expression: PLACEHOLDER ; @ValueConverter(rule = "AvaloqScriptExpression") public IValueConverter<Expression> avaloqscriptexpression() { return new AvqScriptExpressionDelegateParser<Expression>(delegate); Editor services need to be aware of delegation Validators need to be initialized with right injector DocumentTokenSource need to be aware of multiple token classes Text within placeholder [ ] is handled by a different DSL. 19

ANTLR Semantic Predicates Listing keywords in ID rules? ANTLR generated code too big? Predicate generated for keyword rule /** * @KeywordRule(visible, invisible) */ KeywordVisibleKind returns VisibleKind : ID ; Custom predicate referenced from Xtext grammar /** * Language ID pattern: "dfltlang".. "german" ("lang_" ID) * @SemanticPredicate(isLanguageTranslation) */ Translation : language=[ilanguage Language] (text=string "null")? ; Adjusted Xtext workflow inserts (<predicate call>)?=> semantic predicates for ANTLR input (*.g). Propagate predicates before ANTLR actions across all rules. public boolean iskeywordvisiblekindenabled(final ParserContext parsercontext) { final String text = parsercontext.getinput().lt(1).gettext(); return "visible".equalsignorecase(text) "invisible".equalsignorecase(text); 20

Questions? We talked about Context, database-backed index, layered index DSLs for scoping, formatting, object descriptions, and validations Xtend-based test suite for linking, content assist, validations etc. Composition of Xtext languages Semantic predicates for keyword rules etc. What we could also talk about Headless DSL compiler Types outside defining resource: managing derived resources User-defined model validations and user-defined transformations Want to work together on some of this in dsl-devkit? Try https://github.com/dsldevkit Contact roman.mitin@avaloq.com 21

Thank you for your attention. roman.mitin@avaloq.com