The ParNDF language reference manual

From AOW HT Wiki


Contents

Introduction

The syntax

The ParNDF language is similar to the NDF language and is embedded in the NDF as a EDSL.

Keywords

Some constructions are specifical to the ParNDF :
SEQ, SIMU, COMPET

The basical types

The Accesseurs

An Accesseur works like a function, it returns a value when it is evaluated.
The list of Accesseur is available here: Add link

The Effets

An Effet is similar to an action, it triggers side effects.
The list of Effet is available here: Add link

Sequencing Effets

The different Effets can globaly be sequenced according to three types.

Sequential

In this case, the Effets are executed one after an other.

<ndf>
MonEffetSeq is SEQ with
[
 DebugHello is TEffetEugDebugWin32(Affichage = 'Hello'),
 DebugWorld is TEffetEugDebugWin32(Affichage = 'World')
]
</ndf>

The code above can be written by explicitely using a TEffetSequentiel :

<ndf>
MonEffetSeq is TEffetSequentiel
(
 EffetList = [
             DebugHello is TEffetEugDebug(Affichage = 'Hello'),
             DebugWorld is TEffetEugDebug(Affichage = 'World')
             ]
)
</ndf>

Writing the Effet with SEQ is more concise and allows to express the sequencing with more semantics.

Simultaneous

In this case, the Effets are executed in parallel.

<ndf>
MonEffetSim is SIMU with
[
 PingPong is SEQ with
 [
   DebugPing is TEffetEugDebugWin32(Affichage = 'Ping'),
   DebugPong is TEffetEugDebugWin32(Affichage = 'Pong')
 ],
 HelloWorld is SEQ with
 [
   DebugHello is TEffetEugDebugWin32(Affichage = 'Hello'),
   DebugWorld is TEffetEugDebugWin32(Affichage = 'World')
 ]
]
</ndf>

Executing this code gives :

 TEffetEugDebugWin32: Ping
 TEffetEugDebugWin32: Hello
 TEffetEugDebugWin32: Pong
 TEffetEugDebugWin32: World

The code above can also be written by explicitely using an TEffetSimultane:

<ndf>
MonEffetSim is TEffetSimultane
(
 EffetList = [
               PingPong is SEQ with
               [
                 DebugPing is TEffetEugDebugWin32(Affichage = 'Ping'),
                 DebugPong is TEffetEugDebugWin32(Affichage = 'Pong')
               ],
               HelloWorld is SEQ with
               [
                 DebugHello is TEffetEugDebugWin32(Affichage = 'Hello'),
                 DebugWorld is TEffetEugDebugWin32(Affichage = 'World')
               ]
             ]
)
</ndf>

As we can see, it is possible to mix the use of SEQ, SIMU and COMPET with other types.

In competition

In this case, the Effets are executed in parallel but the first Effet that ends causes the termination of the others.

<ndf>
MonEffetCompet is COMPET with
[
 EffetLong is SEQ with
 [
  Attente is TWaitPrecis(DureeEnSecondes = 5),
  Debug is TEffetEugDebugWin32(Affichage = 'I am too slow !')
 ],
 EffetCourt is TEffetEugDebugWin32(Affichage = 'I am faster !')
]
</ndf>

In the following example, the Effet Debug won't never be executed.
The Effet EffetCourt ends before the Effet Attente.
That triggers the termination of the Effet MonEffetCompet.

The code above can also be written by explicitly using an Effet TEffetCompetition :

<ndf>
MyEffetCompet is TEffetCompetition
(
 EffetList = [
               EffetLong is SEQ with
               [
                 Attente is TWaitPrecis(DureeEnSecondes = 5),
                 Debug is TEffetEugDebugWin32(Affichage = 'I am really too slow!')
               ],
               EffetCourt is TEffetEugDebugWin32(Affichage = 'I am the fastest!')
             ]
)
</ndf>

The local variables

Presentation

The Effets SEQ, SIMU and COMPET can contain local variables.

Definition

Those variables must be defined before being used to store values.
A local variable is defined by using its dedicated template TemplateVariableLocale*
Most of those templates are listed and defined in the file named VariableLocale.ndf

The supported types are :

  • Integer
  • Real
  • Boolean
  • String
  • UnitBalise
  • PositionPlancher
  • UnitBaliseList

Assignement

Assigning a value to a variable is done using the operator ":="

Example

<ndf>
MyEffet is SEQ
(
 VarLocaleList = [ locMyInteger is TemplateVariableLocaleInteger() ]
)
with
[
 locMyInteger := 322
]
</ndf>