Beyond Annotations A Proposal for Extensible Java XJ

Beyond Annotations: A Proposal for Extensible Java (XJ) Tony Clark, Thames Valley University Paul Sammut, HSBC James Willans, Ceteva tony. clark@tvu. ac. uk www. ceteva. com/home/tony. html 1

Domain Specific Languages • Aims: to provide a tailored language; to support mixed languages; language evolution. • Pros: declarative; maintenance; reuse; verification • Cons: specialist skills; no standard technology; lack of integration. • Technologies: macros; pre-processing; rollyour-own; chained calls. 2

DSLs: Technology Problems • Communication: 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. 3

DSLs: An OO Proposal Syntax Classes • • Modular: class-based language constructs. Conservative: extends base language. Fully Integrated: static; dynamic; IDE. Standardized: syntax extension; AST manipulation; static processing; execution. 4

Syntax Classes: DSL Architecture package 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. 5

Example DSL Constructs public Vector<Integer> add 1(Vector<Integer> nums) { return @Cmp(x + 1) { int x <- nums }; } @Reader Call. Reader { map(SVCL, Service. Call) 4 -18: Customer. Name 19 -23: Customer. ID 24 -27: Call. Type. Code 28 -35: Data. Of. Call. String end map(USGE, Usage) 4 -8: Customer. ID 9 -22: Customer. Name 30 -30: Cycle 31 -36: Read. Date end do Service. Call Usage } @Entity. Bean Order persist. As "ORDER_TABLE" { private int id persist. As "ORDER_ID" (get, set); private int address persist. As "SHIPPING_ADDRESS" (get, set); 6 }

Syntax Classes: Technologies • Grammars: 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; [| … |]. 7

Review • Implemented in XMF: commercial tool; opensource (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. 8

Statement New languages and constructs can/should implement a standard interface to facilitate program analysis. 9
- Slides: 9