DOC PREVIEW
Columbia COMS W4115 - EMPATH

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

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

Unformatted text preview:

EMPATH LANGUAGE REFERENCE MANUAL Jeremy Posner jp2288 columbia edu Nalini Kartha nkk2106 columbia edu Sampada Sonalkar ss3119 columbia edu William Mee wjm2107 columbia edu COMS4115 Programming Languages and Translators 19 October 2006 Introduction This document is a formal reference for the Empath language which is designed to model living beings in a simplified form Grammar notation We use standard regular expression for expressing the production rules of the language Symbols enclosed in single quotes are terminals All other symbols are non terminals represents zero or more occurrences of the preceding expression and represents one or more occurrences represents a choice between the two expressions on either side of the character and means that the preceding expression is optional Braces are used to give precedence and denote the scope of an operator Lexical conventions Comments The character combination represents a single line comment For multi line comments the character combination indicates start of comment block and character combination indicates end of comment block The symbol sequence cannot appear within a multi line comment Tokens Tokens include identifiers keywords constants operators and punctuations Identifiers Identifiers are represented by a sequence of letters and digits starting with an alphabetic character or an underscore character An identifier represents a name for one of the following constructs variable function event trigger state digit 0 9 letter a z A Z id letter letter digit Keywords The following identifiers are reserved keywords and may not be used otherwise boolean entity event float for 2 14 if return trigger init state void int string while label tick output to range transition The keywords may only be used in the lower case alphabet The language is case sensitive so an identifier age is distinct from AGE or Age The Java convention of identifiers starting with lower case alphabet and judicious use of upper case characters as separators is encouraged Operators The language supports a small set of mathematical and logical operators for manipulating entity characteristics The precedence and associativity rules for these operators are the same as those of mainstream programming languages specifically C1 hence we will not redefine them in this manual Arithmetic operators Shorthand arithmetic operators Relational operators Logical operators Punctuation The following characters are used for punctuation in the language statement end argument list separator declaration initializer string literal range specifier range delimiter or array index delimiter function body or block statement delimiter function parameter list delimiter Constants The language defines integer constants real constants including only a fractional part no exponents boolean constants and string constants Const IntConst RealConst BoolConst StrConst IntConst digit RealConst digit digit 1 For a definition of this precedence see the C Reference Manual Ritchie available online at http cm bell labs com cm cs who dmr cman pdf 3 14 BoolConst true false StrConst letter digit A can be included within a string by escaping it with another i e Line Terminators and Whitespace ASCII spaces tabs new line carriage returns and form feeds are all considered as whitespaces Whitespace is ignored except as a token separator In built functions The following function names are not keywords but similar to the main function name in languages like C and Java if present have a special meaning for the runtime environment onClockTick onEntry onExit This is explained in more detail below 4 14 Empath Language Specification Overview An Empath program essentially consists of a description of the characteristics of an entity a finite state machine FSM for representing its lifecycle and a set of options known as events available to the user for interacting with the entity An example piece of Empath code and an accompanying FSM is given in an appendix at the end of this document to make the understanding of this language reference manual easier In general Empath is a C like language similar to Java or C in its use of curly braces operators function definitions etc The nature of the Empath language necessitates the use of such constructs for performing simple arithmetic and logical operations on entity characteristics and we did not want to reinvent the wheel in defining an unusual syntax Entity Specification The entity specification gives a name to the entity being modeled and specifies the associated variables usually characteristics of the entity functions states and transitions The entity specification may also optionally include an embedded specification for one or more of the states of the entity There can be only one entity specification in an empath program and the program must begin with it All other constructs of the empath program are embedded in the entity specification block EntitySpec entity id ProgramBody State Specification A state specification is very similar to an entity specification A simple state is one defined as an FSM without any FSMs embedded inside it and including at most one or more of the special functions onClockTick onEntry and onExit functions but no more If a state is complex with a single FSM embedded inside it to form a hierarchy it may include the above mentioned functions but also a description of the embedded FSM This distinction is important conceptually but is not part of the language specification per se Figure 1 in Appendix describes a dog entity Here Dead is a simple state The Puppy state is a complex state and includes a description of the daily activities of a puppy StateSpec ProgramBody state id ProgramBody label StrConst 5 14 Decls FuncDef States Trans StateSpec The label keyword is used to specify a string that is passed to the user interface for display purpose The id is used as an internal handle Labels are used for states and functions particularly events States This lists the names of the set of possible states that the entity can be in It works like a forward declaration for states and is helpful to the programmer while specifying the transitions The detailed definition for a state can be defined later in the StateSpec block The initial state the default state which the entity will be in at the beginning of execution of the program is marked by including the keyword init before the corresponding state name If the initial state is not thus explicitly marked then it is


View Full Document

Columbia COMS W4115 - EMPATH

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

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
Loading Unlocking...
Login

Join to view EMPATH 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 EMPATH 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?