1Beyond Annotations:A Proposal for Extensible Java(XJ)Tony Clark, Thames Valley UniversityPaul Sammut, HSBCJames Willans, Cetevatony.clark@tvu.ac.ukwww.ceteva.com/home/tony.html
2Domain Specific LanguagesAims: to provide a tailored language; to support mixed languages; language evolution.Pros: declarative; maintenance; reuse; verificationCons: specialist skills; no standard technology; lack of integration.Technologies: macros; pre-processing; roll-your-own; chained calls.
3DSLs: Technology ProblemsCommunication: distributing new languages.Integration: IDEs; Analysis Tools.Modularity: clear definition of syntax and semantics.DSL Types: Internal and External.Syntax (concrete and abstract): standard extension mechanisms.
4DSLs: An OO ProposalSyntax ClassesModular: class-based language constructs.Conservative: extends base language.Fully Integrated: static; dynamic; IDE.Standardized: syntax extension; AST manipulation; static processing; execution.
5Syntax Classes: DSL Architecturepackage p.q;import language java.syntax.grammar;class mylang implements java.syntax.AST {  ...   @grammar {     // language definition  }}import language p.q.mylang;class C {  void m(...) {     ...      @mylang {       // Syntax and semantics defined       // by class mylang.     }  }} modular.
 nesting.
 conservative.
 standard.6Example DSL Constructspublic Vector<Integer> add1(Vector<Integer> nums) {  return    @Cmp(x + 1) {      int x <- nums    };}@Reader CallReader {  map(SVCL,ServiceCall)    4-18:CustomerName    19-23:CustomerID    24-27:CallTypeCode    28-35:DataOfCallString  end  map(USGE,Usage)    4-8:CustomerID    9-22:CustomerName    30-30:Cycle    31-36:ReadDate  end  do ServiceCall Usage }@EntityBean Order persistAs "ORDER_TABLE" {  private int id persistAs "ORDER_ID" (get,set);  private int address persistAs "SHIPPING_ADDRESS" (get,set);}
7Syntax Classes: TechnologiesGrammars: basic library; synthesizes abstract syntax; various languages possible.AST interface: factories; types; eval; compile;… Quasi-quotes: working with concrete/abstract syntax: [| <o>.m(<a>,1) |]Language: import; @; grammar; [| … |].

Scam 08

  • 1.
    1Beyond Annotations:A Proposalfor Extensible Java(XJ)Tony Clark, Thames Valley UniversityPaul Sammut, HSBCJames Willans, Cetevatony.clark@tvu.ac.ukwww.ceteva.com/home/tony.html
  • 2.
    2Domain Specific LanguagesAims:to provide a tailored language; to support mixed languages; language evolution.Pros: declarative; maintenance; reuse; verificationCons: specialist skills; no standard technology; lack of integration.Technologies: macros; pre-processing; roll-your-own; chained calls.
  • 3.
    3DSLs: Technology ProblemsCommunication:distributing new languages.Integration: IDEs; Analysis Tools.Modularity: clear definition of syntax and semantics.DSL Types: Internal and External.Syntax (concrete and abstract): standard extension mechanisms.
  • 4.
    4DSLs: An OOProposalSyntax ClassesModular: class-based language constructs.Conservative: extends base language.Fully Integrated: static; dynamic; IDE.Standardized: syntax extension; AST manipulation; static processing; execution.
  • 5.
    5Syntax Classes: DSLArchitecturepackage p.q;import language java.syntax.grammar;class mylang implements java.syntax.AST { ... @grammar { // language definition }}import language p.q.mylang;class C { void m(...) { ... @mylang { // Syntax and semantics defined // by class mylang. } }} modular.
  • 6.
  • 7.
  • 8.
    standard.6Example DSLConstructspublic Vector<Integer> add1(Vector<Integer> nums) { return @Cmp(x + 1) { int x <- nums };}@Reader CallReader { map(SVCL,ServiceCall) 4-18:CustomerName 19-23:CustomerID 24-27:CallTypeCode 28-35:DataOfCallString end map(USGE,Usage) 4-8:CustomerID 9-22:CustomerName 30-30:Cycle 31-36:ReadDate end do ServiceCall Usage }@EntityBean Order persistAs "ORDER_TABLE" { private int id persistAs "ORDER_ID" (get,set); private int address persistAs "SHIPPING_ADDRESS" (get,set);}
  • 9.
    7Syntax Classes: TechnologiesGrammars:basic library; synthesizes abstract syntax; various languages possible.AST interface: factories; types; eval; compile;… Quasi-quotes: working with concrete/abstract syntax: [| <o>.m(<a>,1) |]Language: import; @; grammar; [| … |].
  • 10.
    8ReviewImplemented in XMF:commercial tool; open-source (www.ceteva.com) Superlanguages book: (www.ceteva.com/docs/Superlanguages.pdf) DSLs require standard technology.Open up Java to define new languages.Issues: language interaction; IDE support; analysis tool requirements.
  • 11.
    9StatementNew languages andconstructs can/should implement a standard interface to facilitate program analysis.