DOC PREVIEW
Columbia COMS W4115 - The BATS Language Reference Manual

This preview shows page 1-2-3-4-5-6 out of 17 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Lexical conventions:Separators:Comments:What an Identifier Stands ForConversions between identifiersVariablesExpressionsNumber NegationBoolean NegationIncrementingDecrementingDeclarationsStatementsFunctionsArraysLinesScopeBuilt-In FunctionsDrawThe BATS Language Reference Manual Behrooz Badii(Team Leader) Aleksandr Borovinskiy Tanya Shtemberg Sui Sum Wong October 28, 2003Introduction: The BATS language, a geometric figure drawing language, was designed to be simple to use. Through its simplicity, complex figures can be drawn using complex algorithms. The language also includes loops, conditional statements, and functions to modularize a programmer’s language. These pieces of block structured programming are essential for effectively representing geometric algorithms in an understandable format. And since this is a drawing language the choice of declaring, assigning, and using lines, as will be seen, will make drawing vastly easier. BATS will use an interpreter that interprets BATS code into the target language Java. Syntax (Grammar) notation: This language reference manual uses a pseudo-ANTLR language to represent the grammar of BATS. Grammars are clearly divided from paragraphing and text to show the grammar exactly. Alternatives are separated by the ‘|’ character. Nonterminals can be placed in an optional set of parentheses, but they are also always italicized. Literals or terminals are placed in single quotes (i.e. ‘1’, ‘e’). A set of literals, such as the alphabetic set, can be placed in parentheses, where the first quoted literal is followed by two periods, which is followed by the last literal of the set in single quotes. Optional expressions are placed in parentheses followed by the questions mark character ‘?’. Iteration is placed in parentheses followed by either the kleene star ‘*’, which means that the parenthesized literals and/or syntactic categories can be matched zero or more times, or the plus character ‘+’, which means that the parenthesized literals and/or syntactic categories must be matched at least once. Epsilon is represented as /*nothing*/. So in the grammar: Yourname: Name (‘A’ . . ‘Z’)? (Name)? Name: (‘A’ .. ‘Z’) (‘a’..’z’)* Yourname is the starting symbol. The first name, or Name, is a syntactic subcategory that expands to one uppercase letter followed by any number of lowercase letters. After Name the middle initial is just an optional single uppercase letter. The last name is just Name reiterated to match a last name. Lexical conventions: The following are the tokens found in this language: identifiers, keywords, constants, operators, and separators.Separators: Blanks (the whitespace), tabs, new lines, carriage returns, and comments are ignored in token creation other than to serve the purpose of separating tokens. The input stream, which is a file containing BATS programs, is parsed so that each token is taken to include the longest string of characters which could possibly constitute a token. This means the parser will keep adding to the token until it hits a whitespace, a tab, a new line, a carriage return, or a comment. Comments: The question mark character # introduces a comment, which terminates with a new line. Another convention for comments is starting a comment with the characters #% and ending the comment with %#. Identifiers (Names) An identifier is a sequence of letters and digits where the first character must be alphabetic. The underscore ‘‘_’’ is counted as a letter. Upper and lower case letters are considered different. The following is the grammar for an identifier: Identifier: (‘A’..’Z’|’a’..’z’|’_’) (‘A’..’Z’|’a’..’z’|’0’..’9’|’_’)* These are some examples of identifier names: hello, hello1, _hi3, I_AM_A_VARIABLE The following cannot be identifiers: 1joe, thr?ee, b|leach Keywords Keywords are reserved words that aid the programmer in creating an understandable program that the compiler will accept. These keywords are used for things such as looping, conditional statements, and type declarations. To make them easier to see in a BATS text, they all start with a capital letter. No identifier can have a name identical to the following keywords: Double Int Boolean Line Point From To Draw Call Function Begin End Start Terminate While For If Else WhileEnd ForEnd IfEnd True False Do Color ThenConstants There are three different types of constants in the BATS language: integer constants, double constants, and Boolean constants. These three are defined as follows: Integers: An integer consists of a sequence of ASCII character ‘1’ to ‘9’, and that sequence of ASCII characters represents its real number value. For example, the real number value equivalent of the sequence “123” is 123 or one hundred twenty three. The following is the grammar composing an integer constant: Integer: (Digit)+ Digit: (‘0’ . . ’9’) Doubles: A double constant is a sequence of digits, followed by a mandatory ASCII decimal or dot ‘.’, which is then followed by another sequence of digits, which is then followed by an optional exponent. The exponent part of a double constant consists of an upper or lower case ‘e’, followed by an optional positive or negative sign, followed by another sequence of digits. The following is the grammar composing a double constant: Double: (Digit)+ ’.’ (Digit)+ (Exponent)? Exponent: (‘e’|’E’) (‘+’|’-‘)? [Digit]+ Notice the mandatory digit in front of the decimal. This makes the double constant found in the BATS language similar to the double values in a regular hand-held calculator. For example, the number .067 is represented as 0.067 in the BATS language, which is similar to the representation of that number in a calculator. The following are examples double constants: 145.167 145.167 E+26 0.12 e-13 The following are examples of input that can’t be a double constant: 145. .167 145. e+12 Booleans:There are only two Boolean constants in the BATS language, and they are “True” and “False”, representing the logical values of true and false, respectively. The following is the grammar for a Boolean constant: Boolean: ‘True’|’False’ What an Identifier Stands For An identifier can stand for another identifier, a constant, or a more complex set of


View Full Document

Columbia COMS W4115 - The BATS Language Reference Manual

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

JTemplate

JTemplate

39 pages

BATS

BATS

10 pages

Synapse

Synapse

11 pages

c.def

c.def

116 pages

TweaXML

TweaXML

108 pages

Load more
Download The BATS Language Reference Manual
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view The BATS Language Reference Manual 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 The BATS Language Reference Manual 2 2 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?