1 / 22

Extending Repleo with static semantic checking using JastAdd(J)

Extending Repleo with static semantic checking using JastAdd(J). Jos Peeters. Goal Introduction Repleo JastAdd(J) Coupling Concept Progress Proof of Concept - Booleans Typechecking Java Adding placeholders. Goal. Repleo Syntax safe Static semantics? Goal

dulcea
Download Presentation

Extending Repleo with static semantic checking using JastAdd(J)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Extending Repleo with static semantic checking using JastAdd(J) Jos Peeters

  2. Goal • Introduction • Repleo • JastAdd(J) • Coupling Concept • Progress • Proof of Concept - Booleans • Typechecking Java • Adding placeholders / name of department

  3. Goal • Repleo • Syntax safe • Static semantics? • Goal • Extend Repleo to support static semantic checking • Create additional checks concerning placeholders • Get coffee / name of department

  4. Introduction • Repleo • JastAdd • JastAddJ • Concept / name of department

  5. Repleo / name of department

  6. Repleo – Placeholders • Substitution <% Expr %> • Iterator <% foreach Expr do %> Subtemplate <% od %> • Conditional <% if Expr then %> Subtemplate1 <% else %> Subtemplate2 <% fi %> / name of department

  7. JastAdd • Java based compiler compiler system • Designed to support analyzers, transformation tools, etc. • Main Feature: Extention of Reference Attribute Grammars / name of department

  8. JastAdd – Defining languages • EBNF format <nonterminal name> : <inherits from> ::= <production rule> abstract BinNumber; IntegNumber : BinNumber ::= IntegPart:BitList; RatNumber : BinNumber ::= IntegPart:BitList FracPart:BitList; abstract BitList; SingularBitList : BitList ::= Bit; PluralBitList : BitList ::= BitList Bit; abstract Bit; Zero : Bit ::= ; One : Bit ::= / name of department

  9. JastAdd – Aspect Weaving • Reference Attribute Grammars (RAGs) • syn • inh • eq aspect BinaryNumberValue { syn double Bit.value(); inh int Bit.scale(); … eq Zero.value() = 0 eq One.value() = java.lang.Math.pow(2.0, scale()); … } / name of department

  10. JastAdd – JastAddJ • Java compiler created with JastAdd • Semantic analysis for Java1.4 • Scanner en parser included • JFlex (LEX descendent) • Beaver (YACC descendent) • Definition/handling of production rules largely only in the parser definition / name of department

  11. JastAddJ / name of department

  12. Coupling Concept / name of department

  13. Progress • Proof of concept: Booleans • Typechecking Java • Adding placeholders / name of department

  14. Proof of Concept – Booleans "(" BoolExp ")" -> BoolExp {bracket,cons("bracket")} "not" "(" BoolExp ")" -> BoolExp {cons("not")} lhs:BoolExp "&" rhs:BoolExp -> BoolExp {left, cons("and")} lhs:BoolExp "|" rhs:BoolExp -> BoolExp {left, cons("or")} BoolCon -> BoolExp {cons("constant")} "true" -> BoolCon {cons("booltrue")} "false" -> BoolCon {cons("boolfalse")} BoolRoot ::= BoolExp; abstract BoolExp; bracket : BoolExp ::= BoolExp; not : BoolExp ::= BoolExp; and : BoolExp ::= lhs: BoolExp rhs: BoolExp; or : BoolExp ::= lhs: BoolExp rhs: BoolExp; constant : BoolExp ::= BoolCon; abstract BoolCon; booltrue : BoolCon ::=; boolfalse : BoolCon ::=; / name of department

  15. Booleans(2) aspect Booleanvalue { syn boolean BoolRoot.value(); syn boolean BoolExp.value(); syn boolean BoolCon.value(); eq BoolRoot.value() = getBoolExp().value(); eq and.value() = getlhs().value() && getrhs().value(); eq or.value() = getlhs().value() || getrhs().value(); eq not.value() = !getBoolExp().value(); eq bracket.value() = getBoolExp().value(); eq booltrue.value() = true; eq boolfalse.value() = false; } / name of department

  16. Typechecking Java • Connection • SDF definition • JastAddJ definition • JastAddJ parser • rewrite of production rules • additional instantiation of checker / name of department

  17. Java – Observations • Properties • Direct (explicit) access of typed attributes • Design decisions JastAddJ • Reduce number of tree traversals • Inability of accessing siblings / name of department

  18. Java – Implementation • It works! • Not the whole language supported (yet), but almost • “creative” solutions needed to deal with language/parser differences • Tools used • ImplodePT • AddPosInfo / name of department

  19. Adding placeholders • Partial evaluation done by Repleo • Extracting placeholder subtrees from PT • Current challenge • Catching typecheck errors/warning caused by placeholders • Additional checking requirements for conditional and iterative placeholders • Dealing with ambiguities / name of department

  20. Ambiguity example Template: public class Example { <% x %> <% y %>() {} } Two possible production rules apply: public class Example { public Example() {} } public class Example { int Something() {} } / name of department

  21. Ambiguities and JastAdd • How to introduce an ambiguous/generic node into JastAdd? • Constructors have explicitly types attributes • Typechecker has (via attributes) direct contact with its children and its parent / name of department

  22. Questions / name of department

More Related