                               Parser : Syntax

 1.  Expressions

XEMP has a very powerfull  highlight  expression  mechanism.
Practically everything you want to hightlight can be entered
as an expression.  The expression parser will identify vari-
ables  like  civilians  or  food  and substitute it with the
actual value from the sector currently being examined.

                     December 10, 1991

                               Parser : Syntax

An expression is build up by compare  expressions  seperated
by the Boolean operators and and or. And has a higher prior-
ity than or, so the expression 0 and 0 or 1 will  be  parsed
as  ((0  and 0) or 1) which evaluates to 1 whereas you might
have expected it would be parsed as (0 and (0 or  1))  which
evaluates  to  0.  Both sides of an Boolean operator must be
either boolean or Numeric, where a  non-zero  Numeric  value
means TRUE and a zero numeric value means FALSE.
The exceptional case of an expression is the one with only a
compare expression, without Boolean operator. Therefore thew
expression can either assume a Numeric or a Boolean type.

A compare expression consists of a term optionally  followed
by  a  compare  operator and another term. Compare operators
are '>', '<=', '=', etc.  where both sides  of  the  compare

                     December 10, 1991

                               Parser : Syntax

operator must be of the same type.
The exceptional case of a compare  expressions  is  the  one
with  only  a  term,  without  operator. Therefore a compare
expression can either assume a Numeric or a Boolean type;
A special type compare operator is '~'  which  accepts  only
strings.  It  will  match the left hand side string with the
right hand side string and evaluates to 1 if either the left
hand side string as a whole is a part of the right hand side
or vica versa.

Terms are normal everyday Numeric expressions like 1 + 2 * 4
etc. with the usual operator precedence.

Every subexpression (a expression between brackets)  can  be
predeceded by a expression modifier. Each of these modifiers

                     December 10, 1991

                               Parser : Syntax

identifies the object to which  the  variablkes  within  the
expressions  references.  Valid modifiers are "sector(...)",
"ship(...)", "plane(...)" and "nuke(...)". Variables in  the
most  outer  layer  (no  modifiers  given)  are  taken to be
referencing the sector.
Example:

plague_stage <> healty
Evaluates to TRUE if the sector is infected.

occupied and (mil < (civ / 20))
Evaluates to TRUE if the sector is  occupied  and  does  not
have enough military in it to control it.

ship(name ~ "cargo")

                     December 10, 1991

                               Parser : Syntax

Evaluates to the number of ships in the current sector which
name begins with "cargo".

ship(name ~ "cargo" and mob > 0) == 2 Evaluates to  TRUE  if
the  sector  contains  exactly  two ships whose names starts
with "cargo" and have some mobility left.

plane((name ~ "transport") && (mobility > 0)) > 10 && mil  >
100
Evaluates to TRUE if there are at least  10  planes  in  the
sector  whose  name  start  with  "transport"  and have some
mobility left. The sector must contain at  least  100  mili-
tary.
N.B. Note that the "plane(...)" modifier only  examines  the
planes in the sector and not planes on ships in the sector.

                     December 10, 1991

                               Parser : Syntax

ship(military > 100 && plane(name ~ "transport"))
Evaluates to TRUE if there is a ship in the sector with more
than  100  military  and  contains a plane which name starts
with "transport".
N.B.  Note  that  the  "plane(...)"  modifier   within   the
"ship(...)"  modifier  only  looks at the planes of the ship
and not the planes of the sector.

ship(plane(nuke(name = "10 kt fission")))
Evaluates to the number of ships that carries at  least  one
plane that is loaded with a 10 kt fission nuclear warhead.

XEMP has a lot of variables  predefined.  Below  are  tables
explaining   all   valid  variables  and  characters  within

                     December 10, 1991

                               Parser : Syntax

expressions. The alias field can contain another name, which
denotes the same variable.

2.  Expression keywords.

Expressions can be entered in C, PASCAL or  mixed  style.  I
would  suggest  you use either C or PASCAL and not a mixture
of both.

                     December 10, 1991

                               Parser : Syntax

Table 1:  -=[* Expression Keywords *]=-

         Name            Alias                Description
______________________________________________________________________
'c'                              Character constant <c>
"<text>"                         String constant <text>
<constant>                       Numerical constant
*                                Times operator
+                                Plus operator
-                                Minus/negate operator
/                                Divide operator
=                        ==      Equals operator
<>                       !=      Does not equal operator
<                                Smaller then operator
>                                Larger then operator
<=                               Smaller or equal operator

9                     December 10, 1991

                               Parser : Syntax

>=                               Larger or equal operator
and                      &&      Boolean and
or                       ||      Boolean or
not                      !       Boolean not
true                             Boolean true
false                            Boolean false
population               pop     (civs + mils + uws) of sector
current_sector           @       Stands for current sector coordinates
warehouse                        Current sector's warehouse
[<expr>, <expr>]                 Specifies sector coordinates
threshold(commodity)     t()     Returns commodity threshold
resource(resource_val)   r()     Returns resouce_val value
round(expr)                      Round off number
floor(expr)                      Round off to nearest lowest integer
ceil(expr)                       Round off to nearest highest integer

                     December 10, 1991

                               Parser : Syntax

______________________________________________________________________
7                       |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|

                               |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|

9

                     December 10, 1991

                               Parser : Syntax

Table 2:  -=[* Resource and Commodity variables *]=-

 Name            Alias           Is resource
____________________________________________
ura      uranium
food                             x
dust     gold_dust               x
oil                              x
iron     iron_ore                x
uw       uncompensated_workers
guns
bars     gold_bars
petrol   petroleum
lcms     lcm
hcms     hcm
she      shells

9                     December 10, 1991

                               Parser : Syntax

rads     radioactive
____________________________________________
7       |7|7|7|7|7|7|7|7|7|7|7|7|7|7|

                               |7|7|7|7|7|7|7|7|7|7|7|7|7|7|

9

                     December 10, 1991

                               Parser : Syntax

Table 3:  -=[* Sector census values *]=-

     Name         Alias               Type
____________________________________________________
xloc                        Numeric
yloc                        Numeric
owner                       String
designation      des        Character (see table 10)
newdesignation   newdes     Character
efficiency       eff        Numeric
work                        Numeric
available        avail      Numeric
mobility         mob        Numeric
civilians        civ/civs   Numeric
militairs        mil/mils   Numeric
planes                      Numeric

9                     December 10, 1991

                               Parser : Syntax

ships                       Numeric
nukes                       Numeric
distribute       dist       Coords
occupied         occ        Boolean
owned                       Boolean
coast                       Boolean
food_used                   Numeric
starvation                  Boolean
mines                       Boolean
territory        terr       Numeric
plague                      Numeric
plague_stage     pstage     Plague (see table 4)
happy                       Boolean
happiness        hstate     Happy (see table 5)
____________________________________________________
7               |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|

                          |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|

9

                     December 10, 1991

                               Parser : Syntax

Table 4:  -=[* Plague Type Constants *]=-

  Name            Description
____________________________________
healthy    Sector not infected
infected   Sector is battling plague
dying      Sector has plague deaths
____________________________________
7         |7|7|7|7|

                     December 10, 1991

                               Parser : Syntax

Table 5:  -=[* Happiness Type Constants *]=-

     Name         Alias               Description
____________________________________________________________
loyal                      Sector population is loyal to you
unrest                     Sector has unrest
revolutionaries   revol    Sector has revolutionaries
terrorists        terror   Sector has terrorists
guerrillas        guerre   Sector has guerillas
____________________________________________________________
7                |7|7|7|7|7|7|

                         |7|7|7|7|7|7|

                     December 10, 1991

                               Parser : Syntax

Table 6:  -=[* Variables  valid  within  nuke(...)  modifier
*]=-

  Usage                Result type
______________________________________________
xloc        Numeric
yloc        Numeric
______________________________________________
name        String
type        Numeric (index in nuke type table)
stockpile   Numeric
______________________________________________
7          ||7|7|7|7|7|7|

9

9

                     December 10, 1991

                               Parser : Syntax

Table 7:  -=[* Variables  valid  within  ship(...)  modifier
*]=-

  Usage              Alias                        Result type
__________________________________________________________________________
xloc                                 Numeric
yloc                                 Numeric
owner                                String
owned                                Boolean
efficiency   eff                     Numeric
mobility     mob                     Numeric
civilians    civ/civs                Numeric
militairs    mil/mils                Numeric
__________________________________________________________________________
food                                 Numeric
dust         gold_dust               Numeric

                     December 10, 1991

                               Parser : Syntax

oil                                  Numeric
iron         iron_ore                Numeric
uw           uncompensated_workers   Numeric
guns                                 Numeric
bars         gold_bars               Numeric
petrol       petroleum               Numeric
lcms                                 Numeric
hcms                                 Numeric
she          shells                  Numeric
rads         radioactive             Numeric
population   pop                     Numeric ((civs + mils + uws) of ship)
planes                               Numeric
food_used                            Numeric
starvation                           Boolean
__________________________________________________________________________
fleet                                Character

9                     December 10, 1991

                               Parser : Syntax

name                                 String
type                                 Numeric (index in ship table)
technology   tech                    Numeric
number                               Numeric
radar                                Numeric
sonar                                Numeric
moves                                Numeric
__________________________________________________________________________
7           |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|

                                   |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|

9

                     December 10, 1991

                               Parser : Syntax

Table 8:  -=[* Variables valid  within  plane(...)  modifier
*]=-

  Usage      Alias            Result type
___________________________________________________
xloc                 Numeric
yloc                 Numeric
efficiency   eff     Numeric
mobility     mob     Numeric
___________________________________________________
wing                 Character
name                 String
type                 Numeric (index in plane table)
number               Numeric
technology   tech    Numeric
maxrange             Numeric

                     December 10, 1991

                               Parser : Syntax

max_range            Numeric
attack               Numeric
defense              Numeric
harden               Numeric
load                 Numeric
___________________________________________________
7           ||7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|

9                   ||7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|

9

9

                     December 10, 1991

                               Parser : Syntax

Table 9:  -=[* Empire constants *]=-

     Usage          Alias                        Description
________________________________________________________________________________
secs_per_etu       spe       Seconds per Empire Time Unit (etu)
etus_per_update    epu       ETU's per update
interest_rate      irate     Interest per gold bar
civ_tax_rate       ctrate    Income per civilian
uw_tax_rate        utrate    Income per uncompensated worker
active_mil_cost    amcrate   Cost per active militair
reserve_mil_cost   rmcrate   Cost per militair on reserve
fertility_rate     frate     Food a non-aggi sector can grow per fertility unit
harvest_rate       hrate     Amount of food a one civilian will harvest
civ_birth_rate     cbrate    Number of babies one civilian will make
uw_birth_rate      ubrate    Number of babies one uncompensated worker will make
eat_rate           erate     Amount of food a grownup will eat

9                     December 10, 1991

                               Parser : Syntax

baby_eat_rate      berate    Amount of food a baby will eat
________________________________________________________________________________
7                 |7|7|7|7|7|7|7|7|7|7|7|7|7|7|

                           |7|7|7|7|7|7|7|7|7|7|7|7|7|7|

9

                     December 10, 1991

                               Parser : Syntax

Table 10:  -=[* Designation characters *]=-

Character       Description
_______________________________
?           Unknown
.           Sea
^           Mountain
s           Sanctuary
            Wasteland
-           Wilderness
c           Capital
u           Uranium mine
p           Park
d           Defense plant
i           Shell industry
m           Mine

9                     December 10, 1991

                               Parser : Syntax

g           Gold mine
h           Harbor
w           Warehouse
*           Airfield
a           Agribusiness
o           Oil field
j           Light manufacturing
k           Heavy manufacturing
f           Fortress
t           Technical center
r           Research lab
n           Nuclear plant
l           Library/school
+           Highway
)           Radar installation

                     December 10, 1991

                               Parser : Syntax

!           Weather stn
#           Bridge head
=           Bridge span
b           Bank
%           Refinery
e           Enlistment center
_______________________________
7          |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|

9

                     December 10, 1991

