package Ġio . gitlab . art urb os ch . gro v lin . compiler . backend Ċ Ċ import Ġcom . github . jav ap ar ser . Java Parser Ċ import Ġcom . github . jav ap ar ser . ast . Modifier Ċ import Ġcom . github . jav ap ar ser . ast . NodeList Ċ import Ġcom . github . jav ap ar ser . ast . body . Body Declaration Ċ import Ġcom . github . jav ap ar ser . ast . body . Class Or Interface Declaration Ċ import Ġcom . github . jav ap ar ser . ast . body . Field Declaration Ċ import Ġcom . github . jav ap ar ser . ast . body . Parameter Ċ import Ġcom . github . jav ap ar ser . ast . body . Variable Decl arator Ċ import Ġcom . github . jav ap ar ser . ast . expr . Assign Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . Binary Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . Boolean Literal Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . Cast Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . Double Literal Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . En closed Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . Field Access Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . Integer Literal Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . Lambda Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . MethodCall Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . Name Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . Object Creation Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . Simple Name Ċ import Ġcom . github . jav ap ar ser . ast . expr . StringLiteral Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . This Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . Unary Expr Ċ import Ġcom . github . jav ap ar ser . ast . expr . Variable Declaration Expr Ċ import Ġcom . github . jav ap ar ser . ast . stmt . Block Stmt Ċ import Ġcom . github . jav ap ar ser . ast . stmt . Expression Stmt Ċ import Ġcom . github . jav ap ar ser . ast . stmt . For Stmt Ċ import Ġcom . github . jav ap ar ser . ast . stmt . If Stmt Ċ import Ġcom . github . jav ap ar ser . ast . stmt . Return Stmt Ċ import Ġcom . github . jav ap ar ser . ast . stmt . While Stmt Ċ import Ġcom . github . jav ap ar ser . ast . type . ArrayType Ċ import Ġcom . github . jav ap ar ser . ast . type . Class Or Interface Type Ċ import Ġcom . github . jav ap ar ser . ast . type . Primitive Type Ċ import Ġcom . github . jav ap ar ser . ast . type . Void Type Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . And Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Assignment Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Block Statement Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Bool Lit Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Bool Type Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Call Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Dec Lit Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Decimal Type Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Division Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . El if Statement Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Equal Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Expression Statement Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . For Statement Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Getter Access Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Greater Equal Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Greater Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . If Statement Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Int Lit Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Int Range Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Int Type Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Less Equal Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Less Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Method Declaration Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Minus Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Multip lication Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Not Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Object Creation Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Object Declaration Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Object Or Type Type Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Or Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Parameter Declaration Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Paren Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Property Declaration Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Return Statement Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Setter Access Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Statement Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . String Lit Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Sub traction Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Sum Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . This Reference Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . TopLevel Decl arable Node Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Type Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Type Conversion Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Type Declaration Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Une qual Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Var Declaration Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Var Reference Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . While Statement Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . Xor Expression Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . builtins . Main Declaration Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . builtins . Print Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . builtins . Print Ln Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . builtins . Random Number Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . builtins . ReadLine Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . builtins . StringType Ċ import Ġio . gitlab . art urb os ch . gro v lin . ast . builtins . ToString Ċ import Ġio . gitlab . art urb os ch . gro v lin . compiler . backend . builtins . builtin To Java Ċ import Ġio . gitlab . art urb os ch . gro v lin . compiler . backend . builtins . readline To Java Ċ import Ġjava . util . ArrayList Ċ import Ġjava . util . Enum Set Ċ import Ġcom . github . jav ap ar ser . ast . body . Method Declaration Ġas ĠJava Parser Method Ċ import Ġcom . github . jav ap ar ser . ast . expr . Expression Ġas ĠJava Parser Expression Ċ import Ġcom . github . jav ap ar ser . ast . stmt . Statement Ġas ĠJava Parser Statement Ċ Ċ /** Ċ Ġ* Ġ@ author ĠArt ur ĠB os ch Ċ Ġ*/ Ċ Ċ fun ĠTop Level Decl arable Node . to Java (): ĠBody Declaration < *> Ġ= Ġwhen Ġ( this ) Ġ{ Ċ ĉ is ĠMethod Declaration Ġ-> Ġto Java () Ċ ĉ is ĠType Declaration Ġ-> Ġtransform To Interface Declaration () Ċ ĉ is ĠObject Declaration Ġ-> Ġtransform To Class Declaration () Ċ ĉ is ĠVar Declaration Ġ-> Ġtransform To Static Field () Ċ ĉ else Ġ-> Ġthrow ĠUnsupportedOperationException ( java Class . canonical Name ) Ċ } Ċ Ċ fun ĠVar Declaration . transform To Static Field (): ĠField Declaration Ġ{ Ċ ĉ val Ġmodifiers Ġ= Ċĉĉ ĉ if Ġ( is Val ) ĠEnum Set . of ( Modifier . PUBLIC , ĠModifier . STATIC , ĠModifier . FINAL ) Ċĉĉ ĉ else ĠEnum Set . of ( Modifier . PUBLIC , ĠModifier . STATIC ) Ċ ĉ return ĠField Declaration ( modifiers , ĠVariable Decl arator ( type . to Java (), Ġname ). set Initializer ( value ?. to Java ())) Ċ } Ċ Ċ fun ĠMain Declaration . to Java (): ĠClass Or Interface Declaration Ġ{ Ċ ĉ val Ġclazz Name Ġ= Ġname [ 0 ]. toUpperCase () Ġ+ Ġname . substring ( 1 ) Ċ ĉ val Ġstatements Of Program Ġ= Ġthis @ to Java . block ?. statements Ċ ĉ return ĠClass Or Interface Declaration (). apply Ġ{ Ċĉ ĉ setName ( clazz Name Ġ+ Ġ" Gv ") Ġ// Ġ# 2 0 Ċĉ ĉ add Modifier ( Modifier . PUBLIC , ĠModifier . FINAL ) Ċĉ ĉ val Ġmain Ġ= Ġadd Method (" main ", ĠModifier . PUBLIC , ĠModifier . STATIC ) Ċĉ ĉ main . add Parameter ( ArrayType ( Java Parser . parse Class Or Interface Type (" String ")), Ġ" args ") Ċĉ ĉ val Ġstatements Ġ= Ġstatements Of Program ?. map To ( NodeList < Java Parser Statement >()) Ġ{ Ġit . to Java () Ġ} Ġ?: ĠNode List () Ċĉ ĉ main . set Body ( Block Stmt ( statements )) Ċ ĉ } Ċ } Ċ Ċ fun ĠObject Declaration . transform To Class Declaration (): ĠClass Or Interface Declaration Ġ{ Ċ ĉ val Ġextends Ġ= Ġextended Types . map To ( ArrayList ()) Ġ{ Ġit . to Java () Ġas ĠClass Or Interface Type Ġ} Ċ ĉ val Ġsuperclass Ġ= Ġextended Object ?. let Ġ{ ĠJava Parser . parse Class Or Interface Type ( extended Object ?. name ) Ġ} Ċ ĉ val Ġmembers Ġ= Ġmember Declarations To Java ( block , Ġfalse ) Ċ ĉ return ĠClass Or Interface Declaration ( Enum Set . of ( Modifier . PUBLIC ), Ġfalse , Ġname ) Ċĉĉ ĉ . set Implemented Types ( NodeList . node List ( extends )) Ċĉĉ ĉ . set Members ( NodeList . node List ( members )). apply Ġ{ Ċĉ ĉ super class ?. let Ġ{ Ġadd Extended Type ( super class ) Ġ} Ċĉ ĉ fields . forEach Ġ{ Ġfield Ġ-> Ċĉĉ ĉ val ĠfieldName Ġ= Ġfield . variables [ 0 ]. name AsString Ċĉĉ ĉ field . create Getter (). body . if Present Ġ{ Ċĉĉĉ ĉ create Null Check ( fieldName , Ġit , Ġ" Access ing Ġun initialized Ġproperty !") Ċĉĉ ĉ } Ċĉĉ ĉ field . create Setter (). body . if Present Ġ{ Ċĉĉĉ ĉ create Null Check ( fieldName , Ġit , Ġ" Property Ġcannot Ġbe Ġnull !") Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } Ċ Ċ } Ċ Ċ private Ġfun Ġcreate Null Check ( variable : ĠString , Ġit : ĠBlock Stmt , ĠerrorMessage : ĠString ) Ġ{ Ċ ĉ it . add Statement ( 0 , Ċĉĉ ĉ Expression Stmt ( MethodCall Expr ( Ċĉĉĉĉ ĉ Name Expr (" java . util . Objects "), Ċĉĉĉĉ ĉ Simple Name (" requireNonNull "), Ċĉĉĉĉ ĉ NodeList . node List ( Name Expr ( variable ), ĠLambda Expr ( NodeList < Parameter >(), Ċĉĉĉĉĉĉ ĉ Expression Stmt ( StringLiteral Expr ( errorMessage )), Ġtrue )) Ċĉĉ ĉ )) Ċ ĉ ) Ċ } Ċ Ċ fun ĠType Declaration . transform To Interface Declaration (): ĠClass Or Interface Declaration Ġ{ Ċ ĉ val Ġextends Ġ= Ġextended Types . map To ( ArrayList ()) Ġ{ Ġit . to Java () Ġas ĠClass Or Interface Type Ġ} Ċ ĉ val Ġmembers Ġ= Ġmember Declarations To Java ( block , Ġtrue ) Ċ ĉ return ĠClass Or Interface Declaration ( Enum Set . of ( Modifier . PUBLIC ), Ġtrue , Ġname ) Ċĉĉ ĉ . set Extended Types ( NodeList . node List ( extends )) Ċĉĉ ĉ . set Members ( NodeList . node List ( members )) Ċ } Ċ Ċ fun Ġmember Declarations To Java ( declarations : ĠBlock Statement ?, Ġis Type : ĠBoolean Ġ= Ġfalse ): ĠMutable List < Body Declaration <* >> Ġ{ Ċ ĉ val Ġmembers Ġ= Ġmutable ListOf < Body Declaration <* >>() Ċ ĉ declarations ?. statements ?. forEach Ġ{ Ċĉ ĉ when Ġ( it ) Ġ{ Ċĉĉ ĉ is ĠMethod Declaration Ġ-> Ġmembers . add ( it . to Java ( is Type )) Ċĉĉ ĉ is ĠProperty Declaration Ġ-> Ġif Ġ( is Type ) Ġ{ Ċĉĉĉ ĉ it . generate Getter And Setter For Trait Property ( members ) Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ members . add ( it . to Java ()) Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } Ċ ĉ return Ġmembers Ċ } Ċ Ċ fun ĠProperty Declaration . to Java (): ĠBody Declaration < *> Ġ= ĠField Declaration ( Enum Set . of ( Modifier . PRIVATE ), Ċĉ ĉ Variable Decl arator ( type . to Java (), Ġname ). set Initializer ( value ?. to Java ())) Ċ Ċ fun ĠProperty Declaration . generate Getter And Setter For Trait Property ( members : ĠMutable List < Body Declaration <* >>) Ġ{ Ċ ĉ val ĠfieldType Ġ= Ġtype . to Java () Ċ ĉ members . add ( Java Parser Method (). setName (" get " Ġ+ Ġname [ 0 ]. toUpperCase () Ġ+ Ġname . substring ( 1 )) Ċĉĉ ĉ . set Modifiers ( Enum Set . of ( Modifier . AB STR ACT , ĠModifier . PUBLIC )) Ċĉĉ ĉ . set Body ( null ) Ċĉĉ ĉ . setType ( fieldType )) Ċ ĉ members . add ( Java Parser Method (). setName (" set " Ġ+ Ġname [ 0 ]. toUpperCase () Ġ+ Ġname . substring ( 1 )) Ċĉĉ ĉ . set Modifiers ( Enum Set . of ( Modifier . AB STR ACT , ĠModifier . PUBLIC )) Ċĉĉ ĉ . set Body ( null ) Ċĉĉ ĉ . set Parameters ( NodeList . node List ( Parameter ( fieldType , Ġname ))) Ċĉĉ ĉ . setType ( Void Type ())) Ċ } Ċ Ċ fun ĠMethod Declaration . to Java ( is Type : ĠBoolean Ġ= Ġfalse ): ĠBody Declaration < *> Ġ{ Ċ ĉ val Ġformal Parameters Ġ= ĠNode List . node List ( parameters . map Ġ{ Ġit . to Java () Ġ}) Ċ ĉ val ĠreturnType Ġ= Ġevaluation Type ?. to Java () Ġ?: ĠVoid Type () Ċ ĉ val Ġis Static Ġ= Ġis TopLevel Declaration Ċ ĉ return Ġif Ġ( must Be Over ridden ()) Ġ{ Ċĉ ĉ val Ġmodifiers Ġ= Ċĉĉĉ ĉ if Ġ( is Static ) ĠEnum Set . of ( Modifier . AB STR ACT , ĠModifier . PUBLIC , ĠModifier . STATIC ) Ċĉĉĉ ĉ else ĠEnum Set . of ( Modifier . AB STR ACT , ĠModifier . PUBLIC ) Ċĉ ĉ Java Parser Method (). setName ( name ) Ċĉĉĉ ĉ . set Modifiers ( modifiers ) Ċĉĉĉ ĉ . set Body ( null ) Ċĉĉĉ ĉ . set Parameters ( form al Parameters ) Ċĉĉĉ ĉ . setType ( returnType ) Ċ ĉ } Ġelse Ġ{ Ċĉ ĉ val Ġmodifiers Ġ= Ċĉĉĉ ĉ if Ġ( is Static ) ĠEnum Set . of ( Modifier . PUBLIC , ĠModifier . STATIC ) Ċĉĉĉ ĉ else ĠEnum Set . of ( Modifier . PUBLIC ) Ċĉ ĉ Java Parser Method (). setName ( name ) Ċĉĉĉ ĉ . set Modifiers ( modifiers ) Ċĉĉĉ ĉ . set Body ( block !!. to Java () Ġas ĠBlock Stmt ) Ċĉĉĉ ĉ . setType ( returnType ) Ċĉĉĉ ĉ . set Parameters ( form al Parameters ) Ċĉĉĉ ĉ . setDefault ( is Type ) Ċ ĉ } Ċ } Ċ Ċ fun ĠParameter Declaration . to Java (): ĠParameter Ġ{ Ċ ĉ val Ġreal Type Ġ= Ġpromotion Type Ġ?: Ġevaluation Type Ċ ĉ val Ġjava Type Ġ= Ġreal Type ?. to Java () Ġ?: ĠVoid Type () Ċ ĉ return ĠParameter ( java Type , Ġname ) Ċ } Ċ Ċ fun ĠStatement . to Java (): ĠJava Parser Statement Ġ= Ġwhen Ġ( this ) Ġ{ Ċ ĉ is ĠVar Declaration Ġ-> ĠExpression Stmt ( Variable Declaration Expr ( Variable Decl arator ( type . to Java (), Ġname , Ġvalue ?. to Java ()))) Ċ ĉ is ĠAssignment Ġ-> ĠExpression Stmt ( Assign Expr ( var Reference . to Java (), Ġvalue . to Java (), ĠAssign Expr . Operator . ASSIGN )) Ċ ĉ is ĠExpression Statement Ġ-> ĠExpression Stmt ( expression . to Java ()) Ċ ĉ is ĠIf Statement Ġ-> ĠIf Stmt ( condition . to Java (), Ġthen Statement . to Java (), Ġtransform El if sTo Else If Construct s ( elif s , Ġelse Statement )) Ċ ĉ is ĠBlock Statement Ġ-> ĠBlock Stmt ( NodeList . node List ( statements . map Ġ{ Ġit . to Java () Ġ})) Ċ ĉ is ĠFor Statement Ġ-> Ġto Java () Ċ ĉ is ĠWhile Statement Ġ-> Ġto Java () Ċ ĉ is ĠReturn Statement Ġ-> ĠReturn Stmt ( expression . to Java ()) Ċ ĉ else Ġ-> Ġthrow ĠUnsupportedOperationException ( java Class . canonical Name ) Ċ } Ċ Ċ fun ĠWhile Statement . to Java (): ĠWhile Stmt Ġ{ Ċ ĉ val Ġcondition Ġ= Ġcondition . to Java () Ċ ĉ val Ġbody Ġ= Ġthen Statement . to Java () Ċ ĉ return ĠWhile Stmt ( condition , Ġbody ) Ċ } Ċ Ċ fun ĠFor Statement . to Java (): ĠJava Parser Statement Ġ{ Ċ ĉ val Ġexpr Ġ= Ġexpression Ċ ĉ if Ġ( expr Ġis ĠInt Range Expression ) Ġ{ Ċĉ ĉ return Ġfor Loop From Int Range ( expr ) Ċ ĉ } Ġelse Ġ{ Ċĉ ĉ throw ĠUnsupportedOperationException (" No Ġforeach Ġfor Ġnow !") Ċ ĉ } Ċ } Ċ Ċ private Ġfun ĠFor Statement . for Loop From Int Range ( expr : ĠInt Range Expression ): ĠFor Stmt Ġ{ Ċ ĉ val Ġfor Stmt Ġ= ĠFor Stmt () Ċ ĉ val Ġstart Ġ= Ġexpr . start . to Java () Ċ ĉ val Ġend Exclusive Ġ= Ġexpr . end Exclusive . to Java () Ċ ĉ val Ġvar Reference Ġ= ĠName Expr ( var Declaration . name ) Ċ ĉ for Stmt . initialization Ġ= ĠNode List . node List ( Variable Declaration Expr ( Ċĉĉ ĉ Variable Decl arator ( var Declaration . type . to Java (), Ġvar Declaration . name , Ġstart ))) Ċ ĉ for Stmt . set Compare ( Binary Expr ( var Reference , Ġend Exclusive , ĠBinary Expr . Operator . LESS )) Ċ ĉ for Stmt . update Ġ= ĠNode List . node List ( Unary Expr ( var Reference , ĠUnary Expr . Operator . POST FIX _ INCREMENT )) Ċ ĉ for Stmt . body Ġ= Ġblock . to Java () Ċ ĉ return Ġfor Stmt Ċ } Ċ Ċ fun ĠVar Reference . to Java (): ĠJava Parser Expression Ġ{ Ċ ĉ val Ġdeclaration Ġ= Ġthis . symbol ?. def Ċ ĉ return Ġwhen Ġ( declaration ) Ġ{ Ċĉ ĉ is ĠProperty Declaration Ġ-> ĠMethod Call Expr ( null , Ġvar Name . to Getter ()) Ċĉ ĉ is ĠVar Declaration Ġ-> Ġif Ġ( declaration . is TopLevel Declaration ) Ċĉĉ ĉ Field Access Expr ( Name Expr ( declaration . getDeclared File ()?. name ), Ġvar Name ) Ġelse Ċĉĉ ĉ Name Expr ( varName ) Ċĉ ĉ is ĠParameter Declaration Ġ-> ĠName Expr ( varName ) Ċĉ ĉ else Ġ-> Ġthrow ĠUnsupportedOperationException (" Could Ġnot Ġresolve Ġ'$ varName ' Ġat Ġ'$ position '" Ċĉĉĉ ĉ + Ġ" Ġbecause Ġno Ġdefinition Ġfound !") Ċ ĉ } Ċ } Ċ Ċ private Ġfun ĠString . to Getter () Ġ= Ġ" get " Ġ+ Ġget ( 0 ). toUpperCase () Ġ+ Ġsubstring ( 1 ) Ċ private Ġfun ĠString . to Setter () Ġ= Ġ" set " Ġ+ Ġget ( 0 ). toUpperCase () Ġ+ Ġsubstring ( 1 ) Ċ Ċ fun Ġtransform El if sTo Else If Construct s ( elif s : ĠMutable List < El if Statement >, Ġelse Statement : ĠBlock Statement ?): ĠJava Parser Statement ? Ġ{ Ċ ĉ return Ġif Ġ( elif s . isNotEmpty ()) Ġ{ Ċĉ ĉ val Ġelif Ġ= Ġelif s [ 0 ] Ċĉ ĉ If Stmt ( elif . condition . to Java (), Ġelif . then Statement . to Java (), Ċĉĉĉ ĉ transform El if sTo Else If Construct s ( elif s . sub List ( 1 , Ġelif s . size ), Ġelse Statement )) Ċ ĉ } Ġelse Ġ{ Ċĉ ĉ else Statement ?. to Java () Ċ ĉ } Ċ } Ċ Ċ fun ĠExpression . to Java (): ĠJava Parser Expression Ġ= Ġwhen Ġ( this ) Ġ{ Ċ ĉ is ĠP aren Expression Ġ-> ĠEn closed Expr ( expression . to Java ()) Ċ ĉ is ĠObject Creation Ġ-> ĠObject Creation Expr ( null , ĠJava Parser . parse Class Or Interface Type ( type . name ), ĠNode List ()) Ċ ĉ is ĠSum Expression Ġ-> ĠBinary Expr ( left . to Java (), Ġright . to Java (), ĠBinary Expr . Operator . PLUS ) Ċ ĉ is ĠSub traction Expression Ġ-> ĠBinary Expr ( left . to Java (), Ġright . to Java (), ĠBinary Expr . Operator . MINUS ) Ċ ĉ is ĠMultip lication Expression Ġ-> ĠBinary Expr ( left . to Java (), Ġright . to Java (), ĠBinary Expr . Operator . MULTI PLY ) Ċ ĉ is ĠDiv ision Expression Ġ-> ĠBinary Expr ( left . to Java (), Ġright . to Java (), ĠBinary Expr . Operator . DI VID E ) Ċ ĉ is ĠMin us Expression Ġ-> ĠUnary Expr ( value . to Java (), ĠUnary Expr . Operator . MINUS ) Ċ ĉ is ĠAnd Expression Ġ-> ĠBinary Expr ( left . to Java (), Ġright . to Java (), ĠBinary Expr . Operator . AND ) Ċ ĉ is ĠOr Expression Ġ-> ĠBinary Expr ( left . to Java (), Ġright . to Java (), ĠBinary Expr . Operator . OR ) Ċ ĉ is ĠX or Expression Ġ-> ĠBinary Expr ( left . to Java (), Ġright . to Java (), ĠBinary Expr . Operator . XOR ) Ċ ĉ is ĠEqual Expression Ġ-> Ġbuiltin To Java () Ċ ĉ is ĠU ne qual Expression Ġ-> ĠBinary Expr ( left . to Java (), Ġright . to Java (), ĠBinary Expr . Operator . NOT _ EQUAL S ) Ċ ĉ is ĠLess Equal Expression Ġ-> ĠBinary Expr ( left . to Java (), Ġright . to Java (), ĠBinary Expr . Operator . LESS _ EQUAL S ) Ċ ĉ is ĠG reater Equal Expression Ġ-> ĠBinary Expr ( left . to Java (), Ġright . to Java (), ĠBinary Expr . Operator . GRE ATER _ EQUAL S ) Ċ ĉ is ĠLess Expression Ġ-> ĠBinary Expr ( left . to Java (), Ġright . to Java (), ĠBinary Expr . Operator . LESS ) Ċ ĉ is ĠG reater Expression Ġ-> ĠBinary Expr ( left . to Java (), Ġright . to Java (), ĠBinary Expr . Operator . GRE ATER ) Ċ ĉ is ĠNot Expression Ġ-> ĠUnary Expr ( value . to Java (), ĠUnary Expr . Operator . LOG ICAL _ COMP LEMENT ) Ċ ĉ is ĠType Conversion Ġ-> ĠCast Expr ( target Type . to Java (), Ġvalue . to Java ()) Ċ ĉ is ĠInt Lit Ġ-> ĠInteger Literal Expr ( value ) Ċ ĉ is ĠDec Lit Ġ-> ĠDouble Literal Expr ( value ) Ċ ĉ is ĠBool Lit Ġ-> ĠBoolean Literal Expr ( value ) Ċ ĉ is ĠString Lit Ġ-> ĠString Literal Expr ( value ) Ċ ĉ is ĠVar Reference Ġ-> Ġto Java () Ċ ĉ is ĠThis Reference Ġ-> ĠThis Expr () Ċ ĉ is ĠCall Expression Ġ-> Ġto Java () Ċ ĉ is ĠSetter Access Expression Ġ-> ĠMethod Call Expr (). apply Ġ{ Ċĉ ĉ setName ( this @ to Java . name . to Setter ()) Ċĉ ĉ if Ġ( this @ to Java . scope Ġ!= Ġnull ) Ġset Scope ( this @ to Java . scope !!. to Java ()) Ċĉ ĉ arguments Ġ= ĠNode List . node List ( this @ to Java . expression . to Java ()) Ċ ĉ } Ċ ĉ is ĠGetter Access Expression Ġ-> ĠMethod Call Expr (). apply Ġ{ Ċĉ ĉ setName ( this @ to Java . name . to Getter ()) Ċĉ ĉ if Ġ( this @ to Java . scope Ġ!= Ġnull ) Ġset Scope ( this @ to Java . scope !!. to Java ()) Ċ ĉ } Ċ ĉ else Ġ-> Ġthrow ĠUnsupportedOperationException ( java Class . canonical Name ) Ċ } Ċ Ċ fun ĠCall Expression . to Java (): ĠMethod Call Expr Ġ= Ġwhen Ġ( this ) Ġ{ Ċ ĉ is ĠPrint Ġ-> Ġbuiltin To Java () Ċ ĉ is ĠPrint Ln Ġ-> Ġbuiltin To Java () Ċ ĉ is ĠRead Line Ġ-> Ġread lineTo Java () Ċ ĉ is ĠRandom Number Ġ-> Ġbuiltin To Java () Ċ ĉ is ĠToString Ġ-> Ġbuiltin To Java () Ċ ĉ else Ġ-> Ġcall To Java () Ċ } Ċ Ċ private Ġfun ĠCall Expression . call To Java (): ĠMethod Call Expr Ġ{ Ċ ĉ val Ġcall Name Ġ= Ġthis . name Ċ ĉ val Ġscope Expr Ġ= Ġscope ?. to Java () Ċ ĉ val Ġarguments Ġ= Ċĉĉ ĉ if Ġ( arguments . isEmpty ()) ĠNode List () Ċĉĉ ĉ else ĠNode List . node List ( arguments . map Ġ{ Ġit . to Java () Ġ}) Ċ ĉ return ĠMethod Call Expr ( scope Expr , Ġcall Name , Ġarguments ) Ċ } Ċ Ċ fun ĠType . to Java (): Ġcom . github . jav ap ar ser . ast . type . Type Ġ= Ġwhen Ġ( this ) Ġ{ Ċ ĉ is ĠInt Type Ġ-> ĠPrimitive Type . int Type () Ċ ĉ is ĠDecimal Type Ġ-> ĠPrimitive Type . double Type () Ċ ĉ is ĠBool Type Ġ-> ĠPrimitive Type . boolean Type () Ċ ĉ is Ġio . gitlab . art urb os ch . gro v lin . ast . Void Type Ġ-> ĠVoid Type () Ċ ĉ is ĠObject Or Type Type , ĠString Type Ġ-> ĠJava Parser . parse Class Or Interface Type ( name ) Ċ ĉ else Ġ-> Ġthrow ĠUnsupportedOperationException ( java Class . canonical Name ) Ċ } Ċ