DOC PREVIEW
Columbia COMS W4115 - EMPATH

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

Save
View full document
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
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
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
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
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
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 MANUALIntroductionGrammar notationLexical conventionsPunctuation Empath Language SpecificationOverviewVariable Declarations: Function DefinitionsSpecial FunctionsAppendix A: Example FSM for Dog EntityAppendix B: Example Empath Code for Dog EntityEMPATH LANGUAGE REFERENCE MANUALJeremy Posner [email protected] Kartha [email protected] Sampada Sonalkar [email protected] Mee [email protected] Programming Languages and Translators19 October 2006IntroductionThis document is a formal reference for the Empath language, which is designed to model living beings in a simplified form. Grammar notationWe 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 conventionsCommentsThe // 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. TokensTokens include identifiers, keywords, constants, operators, and punctuations.IdentifiersIdentifiers 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)* KeywordsThe following identifiers are reserved keywords and may not be used otherwise:boolean entity event float for2/14if init int label output range return state string tick to transition trigger void whileThe 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.OperatorsThe 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 delimiterConstants The language defines integer constants, real constants (including only a fractional part, no exponents), boolean constants and string constantsConst  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.pdf3/14BoolConst  ( true | false )StrConst  ‘”’ ( letter | digit | ! # % ^ & * ( ) - _ = + ~ ' “ : ; ? / | \ { } [ ] , . < > $ )* ‘”’A “ can be included within a string by escaping it with another “, i.e. “”.Line Terminators and WhitespaceASCII spaces, tabs, new line, carriage returns and form feeds are all considered as whitespaces. Whitespace is ignored except as a token separator.In-built functionsThe 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 onExitThis is explained in more detail below.4/14Empath Language SpecificationOverviewAn 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 SpecificationThe 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 ProgramBodyState SpecificationA 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.


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
Download EMPATH
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 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 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?