Unformatted text preview:

Abed Tony BenBrahim ba2305 columbia edu JTemplate Language Reference Manual Table of Contents 1 Introduction 4 2 Lexical Convention 4 3 2 1 Character set and whitespace 4 2 2 Comments 4 2 3 Identifiers 4 2 4 Values 5 2 4 1 Integer 5 2 4 2 Floating Point Number 5 2 4 3 String 5 2 4 4 Boolean 6 2 4 5 Function 6 2 4 6 Array 7 2 4 7 Map 7 2 4 8 NaN 7 2 4 9 Void 7 Expressions 8 3 1 Values 8 3 2 Variables and left hand side expressions 8 3 3 Arithmetic expressions 8 3 3 1 Binary arithmetic expressions 8 3 3 2 Unary arithmetic expressions 9 3 4 1 Comparison expressions 9 3 4 1 Binary comparison expressions 9 3 4 2 Ternary comparison expressions 10 3 5 Logical expressions 10 3 6 Declaration and assignment expressions 10 3 6 1 Declarations 10 3 6 2 Assignment 11 3 6 3 Combined arithmetic operation and assignment expressions 11 3 7 Index expressions 12 3 8 Member expressions 13 3 9 4 3 9 1 Function Invocation 13 3 9 2 Partial application 14 3 10 Grouping 14 3 11 Operator precedence 14 Statements 15 4 1 Statement Blocks 15 4 2 Expressions 16 4 3 Iteration statements 16 4 3 1 for loops 16 4 3 2 while loops 17 4 3 3 foreach loops 17 4 3 4 Altering loop statements control flow 18 4 4 6 if statement 19 4 4 2 switch statement 20 exception handling recovery statements 21 4 5 1 throw statement 21 4 5 2 try catch block 21 4 5 3 try finally block 22 4 6 Importing definitions 23 4 7 Template statements 24 4 7 1 template statement 24 4 7 2 instructions statement 25 4 7 3 Replacement Methodology 27 Scope 28 5 1 Program level scope 28 5 2 Statement block scope 28 5 3 Function scope 29 Object Oriented Constructs 29 6 1 2 Conditional statements 19 4 4 1 4 5 5 Function Calls 13 Prototypes 29 7 6 1 1 Semantics for non map types 29 6 1 2 Semantics for map types 30 6 2 Supporting multiple levels of inheritance 32 6 3 Implementing constructors 33 Built in Library 35 7 1 3 Built in variables 35 7 1 1 Command line arguments 35 7 1 2 Environment variables 35 7 2 System Library 35 7 3 String Library 36 7 4 I O Library 37 1 Introduction Jtemplate is a dynamically typed language meant to facilitate the generation of text from template definitions Jtemplate s support for prototypal inheritance functions as first class values and a basic library permits the development of robust applications While Jtemplate bears a strong resemblance to ECMAScript there are number of significant differences that should be noted Stronger type checking for example addition of a function and an integer valid in ECMAScript is not valid in Jtemplate mandatory declaration of variables before they are used the different implementation of prototypal inheritance and singular implementation of varargs and partial function application as well as improvements in scope visibility make Jtemplate quite distinct from ECMAScript 2 Lexical Convention 2 1 Character set and whitespace Programs in Jtemplate are written using the ASCII character set Whitespace characters serve to separate language elements except within strings and comments and consist of spaces tabs carriage returns and newlines 2 2 Comments Multiline comments begin with the first character sequence and end with the first character sequence that is encountered Single line comments begin with the character sequence and end at the end of the line Example This is a multiline comment let i 1 this is single line comment 2 3 Identifiers Identifiers begin with an uppercase or lowercase letter an underscore or a dollar sign symbol Following the first character identifiers may optionally contain any number of uppercase or lowercase letters digits 0 through 9 underscores or dollar signs The following reserved keywords may not be used as identifiers break case catch continue default else false finally for foreach function import in instructions let NaN once return use switch throw true try template var Void when while Identifiers in Jtemplate are case sensitive The identifiers foo Foo and FOO represent three different identifiers 4 2 4 Values A value in Jtemplate assumes one of the following types integer float string Boolean function array map NaN or Void 2 4 1 Integer Integers are composed one or more digits to form a whole number A single optional minus sign may precede the integer to negate its value Integers may be in the range of 1073741824 to 1073741823 inclusive 2 4 2 Floating Point Number Jtemplate supports IEEE 754 like double precision floating point numbers Floating point numbers consist of An optional minus sign that negates the value A significand consisting of either or the sequence of both of o An integer o A decimal point followed by an integer representing the fractional part An optional exponent part consisting of the character e followed by an optional or sign followed by an integer Either the exponent or fractional part of the significand or both must be specified to form a valid floating point number The following are examples of valid floating point numbers 0 123 1 23 148 23e 32 1 e 12 1e 12 Jtemplate differs from IEEE 754 in its treatment of NaN infinity and inifinity which are all converted to the non float value NaN when they occur Section 2 4 8 2 4 3 String Strings represent a sequence of ASCII characters Strings start with either a single quote or double quote delimiter and are terminated by the first non escaped matching delimiter Strings may span several lines and any newline spanned becomes part of the string Non printable characters or string delimiters may be embedded in a string by using the following escape sequences b n r t 5 backspace Newline carriage return Tab single quote double quote Backslash The following are examples of valid strings a string a multiline string another string 2 4 4 Boolean Boolean values represent the logical values true and false Boolean values consist of the two values true and false 2 4 5 Function A function represents a group of statements that can be invoked with an optional list of arguments and returns a value upon completion Functions are defined with the function keyword followed by a parenthesized list of zero or more identifiers followed by a statement block function arglist statement block arglist is a comma separated list of zero or more identifiers statement block begins with an opening brace ends with a closing brace and contains zero or more statements Statements are fully described in section 4 1 Example function statements a function with no arguments function x y statements a function with two arguments x and y The


View Full Document

Columbia COMS W4115 - JTemplate

Documents in this Course
YOLT

YOLT

13 pages

Lattakia

Lattakia

15 pages

EasyQL

EasyQL

14 pages

Photogram

Photogram

163 pages

Espresso

Espresso

27 pages

NumLang

NumLang

6 pages

EMPATH

EMPATH

14 pages

La Mesa

La Mesa

9 pages

JTemplate

JTemplate

238 pages

MATVEC

MATVEC

4 pages

TONEDEF

TONEDEF

14 pages

SASSi

SASSi

16 pages

BATS

BATS

10 pages

Synapse

Synapse

11 pages

c.def

c.def

116 pages

TweaXML

TweaXML

108 pages

Load more
Loading Unlocking...
Login

Join to view JTemplate and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view JTemplate and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?