next up previous
Next: Values Up: The IBAL User Manual Previous: The IBAL User Manual


Lexical Conventions

Whitespace may separate any two lexical tokens. Whitespace is a sequence of space, tab and newline characters.

IBAL uses the following keywords:
Keyword Use
Bool Boolean type
Int Integer type
Symbol String type
case Case expression: conditional choice by pattern matching
data Algebraic data type (ADT) definition
decide Decision expression or declaration
discount Discount utility in expression
dist Dist expression: stochastic choice
else Else clause of if expression
error Expression signalling error condition
fix Fix expression: defines recursive function
flip Flip expression: binary stochastic choice
forall Forall type quantifier
from Choices clause of decision
fun Lambda expression: defines non-recursive function
given Information clause of decision
if If expression
in Connective in various expressions
let Let expression: defines variable
letdata ADT definition in expression
lettype Type definition in expression
obs Observation declaration or expression
observe Observation declaration or expression
of Connective in case expression
op Operator value
param Parameter definition
params Parameter definitions in expression
pdist PDist expression: stochastic choice with parameter
pragma Execution strategy declaration
private Private label on declaration
retract Retract an observation at the command line
reward Utility declaration or expression
then Then clause of if expression
type Type definition
uniform Uniform expression: stochastic choice

The keywords obs and observe are synonymous. From now on, only obs will be used in this manual.

IBAL uses the following punctuation characters. Many have multiple uses:
Character Name Use
( Left parenthesis Function arguments, and expression grouping
) Right parenthesis Ditto
{ Left brace Block delimeter, and string sets
} Right brace Ditto
[ Left square Dist clauses, and type arguments
] Right square Ditto
< Left tuple Tuple delimiter
> Right tuple Ditto
, Comma Argument and tuple element separator
; Semicolon Optional declaration separator
" Double-quote String delimiter
' Single-quote String initiator
= Equals Definitions and observations
. Dot Component access, and forall type definitions
: Colon Type assertions, and dist and case consequences
# Hash Case clauses
_ Underscore Wildcard pattern
~ Not Boolean negation
| Or Boolean disjunction
& And Boolean conjunction
+ Plus Integer addition
- Minus Integer subtraction and unary negation
* Times Integer multiplication
/ Div Integer division
% Mod Integer remainder
^ Concat String concatentation

IBAL uses the following multi-character tokens:
Token Name Use
-> MapsTo Function definition connective
== EqualsEquals Comparison
++ PlusPlus Integer increment
-- MinusMinus Integer decrement
.. DotDot Integer range

true and false, in all case combinations, are Boolean literals, standing for the Boolean constants.

An identifier is a non-empty sequence of letters, digits or the underscore character, that is not a keyword, a Boolean literal, or a single underscore. Identifiers are divided into two groups, depending on their initial character: an lident begins with a lower case character or underscore, while a uident begins with an upper case character. A longvar is a sequence of identifiers, ending with an lident, each separated by a dot. A ulongvar is similar, except that the final identifier is a uident instead of an lident.

A string literal is a sequence of characters between two double-quote characters, or an identifier following a single-quote character. The quotation marks are not considered part of the string, so ``xyz'' and 'xyz define the same string.

A natural is a sequence of digits. An integer literal is either a natural, or a minus sign followed by a natural.

A posfloat consists of zero or more digits, followed by a decimal point, followed by one or more digits. Exponent-mantissa notation is not currently supported. A float is either a posfloat, or a minus sign followed by a float.


next up previous
Next: Values Up: The IBAL User Manual Previous: The IBAL User Manual
Avi Pfeffer 2006-11-19