introduction to xbase

24
Introduction to Xbase Holger Schill

Upload: holger-schill

Post on 09-Aug-2015

241 views

Category:

Presentations & Public Speaking


2 download

TRANSCRIPT

Introduction to Xbase

Holger Schill

What is

public class Customer implements Serializable {

private String name;private Address address;private List<Phone> phones;

public String getName() {return name;

}public void setName(String name) {

this.name = name;}

public Address getAddress() {return address;

}public void setAddress(Address address) {

this.address = address;}

public List<Phone> getPhones() {return phones;

}public void setPhones(List<Phone> phones) {

this.phones = phones;}

}

bean Customer { name: String address: Address phones: Phone* }

@Entity public class Customer implements Serializable {

@Idprivate String name;private Address address;private List<Phone> phones;

public String getName() {return name;

}public void setName(String name) {

this.name = name;}@Column(name="ADDR", nullable=false)public Address getAddress() {

return address;}public void setAddress(Address address) {

this.address = address;}@OneToManypublic List<Phone> getPhones() {

return phones;}public void setPhones(List<Phone> phones) {

this.phones = phones;}

}

bean Customer { name: String address: Address phones: Phone* }

Grammargrammar org.xtext.example.BeanDsl with org.eclipse.xtext.xbase.Xbase

generate beanDsl "http://www.xtext.org/example/BeanDsl"

Root:beans+=Bean*;

Bean:'bean' name=ID '{'

property+=Property*'}'

;

Property:name=ID ':' (simpleType=TYPE | reference=[Bean]) list?='*'?

;

enum TYPE:String | Int

;

Editor and much more…

Wouldn’t it be cool when…

Expressions would be directly in the DSL…

…with a typesystem

and debugging support

Typesystem

Compiler / Interpreter

Complex Syntax

Expressions

Debugging

XbaseReusable expression language

Access to Java-elementsTypesystem

Compiled to JavaInterpreter

Core Principles

Common (JVM) Type Model

DSLs with Expressions

Scoping Validation ... Generator

Java

DSL

.classFileAST

Type Model

.javaFile

(references)

Core Principles

DSL

.classFileAST

.javaFile

(references)

Core Principles

.classFile

Derived Java Types

.javaFile

DSL

AST

Core Principles

DSL

.classFile

.javaFile

AST Derived Java Types

Core Principles

DSL .javaFile

.classFile

.javaFile

Core Principles

DEMO

What about new Expressions

Create a new ParserRuleWeave it into the Expression TreeConvince AntlrCompute the type for itImplement a compiler

Ingredients

Create a new ParserRuleWeave it into the Expression TreeConvince AntlrCompute the type for itImplement a compiler

Ingredients

Just kidding :-)

Extending the Xbase Type System Sebastian Zarnekow

Today 13:00 - 13:50

THANKS