PDF
1Jer(1)Contents ............................................................................................... 1Jer ................................................................................................ 2 ............................................................................................... 6hello world// use jer/lang/System// javamain(args: [String) = { msg: String = "hello world!" println(msg)}使 Jer 2Jer compilationUint : importedType* declaration* EOF ;declaration : constantDeclaration | methodDeclaration | abstractDeclaration | typeDeclaration ;importedType : USE fullPath ;fullPath : (IDENTIFIER '/')* TYPE_NAME ;use java/lang/Stringuse java/util/DateTime使// com/riguz/jer/Util.jersum(a: Integer, b: Integer) -> Integer = { // ...}// com/riguz/jer/Foo.jeruse com/riguz/jer/Utilmain(args: [String) = { sum(1, 20)}constantDeclaration : CONST variableDeclaration ; Jer 3methodDeclaration : methodSignature methodImplementation? ;methodSignature : IDENTIFIER '(' formalParameters? ')' functionReturnType? ;formalParameters : formalParameter (',' formalParameter)* ;functionReturnType : TO type ;methodImplementation : '=' block ;formalParameter : IDENTIFIER ':' type ;// main(args: [String) = { msg: String = "hello world!" println(msg)}// sum(a: Integer, b: Integer) -> Integer = { return a + b}abstractDeclaration : ABSTRACT TYPE_NAME '{' propertyDeclaration* methodSignature*'}' ;typeDeclaration : TYPE TYPE_NAME typeAbstractions? '{' propertyDeclaration* constructorDeclaration* methodDeclaration*'}' ;typeAbstractions : IS TYPE_NAME (',' TYPE_NAME)* ;propertyDeclaration : IDENTIFIER ':' type ;constructorDeclaration : '(' constructorFormalArguments? ')' methodImplementation ;constructorFormalArguments Jer 4 : constructorFormalArgument (',' constructorFormalArgument)* ;constructorFormalArgument : IDENTIFIER (':' TYPE_NAME)? ;type : TYPE_NAME | arrayType ;arrayType : '[' type ;[<Type>[Integerexpression : primary | expression bop='.' ( methodCall | IDENTIFIER ) | methodCall | objectCreation ;primary : '(' expression ')' | literal | IDENTIFIER ;literal : DECIMAL_LITERAL | FLOAT_LITERAL Jer 5 | CHAR_LITERAL | STRING_LITERAL | BOOL_LITERAL | NULL_LITERAL ;methodCall : instance=IDENTIFIER? '('methodName=IDENTIFIER methodArguments? ')' ;methodArguments : expression (',' expression)* ;objectCreation : NEW '(' methodArguments? ')' ;statementblock : '{' statement* '}' ;statement : variableDeclaration | embeddedStatement ;embeddedStatement : block | assignment | expressionStatement | selectionStatement | loopStatement | returnStatement ;assignment : IDENTIFIER '=' expression ;selectionStatement : IF '(' expression ')' statement (ELSE statement)? ;loopStatement : WHILE '(' expression ')' statement ;returnStatement : RETURN expression ;expressionStatement : methodCall ;variableDeclaration : IDENTIFIER ':' type ('=' variableInitializer)? ;variableInitializer 6 : arrayInitializer | expression ;arrayInitializer : '{' variableInitializer (',' variableInitializer)* '}'use java/lang/Stringuse java/util/DateTimeconst pi: Float = 3.1415926fconst msg: String = "hello world"const kb: Integer = 1024const success: Boolean = trueconst id: Long = 12345678main(args: [String) = { (println "Hello world")}circleArea(radius: Float) -> Float = { return pi(multiply 2, radius)}abstract Movable { x: Integer y: Integer move(x1: Integer, y1: Integer)}abstract Animal { name: String sayHelloTo(person: Person) address() -> String}type Dog is Animal, Movable { (name) = { x = 0 y = 0 } sayHelloTo(person: Person) = { (println "Hello") }}

HTML view coming soon.

Download PDF for the full formatted version.