Deceit




Contents


Introduction

With deceit it is possible to create datasets without the need to do any programming.  Within the constraints of the DAL data model, datasets of any complexity can be created.  The datasets are described with a high level specification which may be thought of as a template. All the features of the DAL Data Model are supported. The template approach has the additional advantage of documenting the dataset structure.

Data contained in ASCII  files is used to populate the arrays and columns of a dataset.

Deceit is an interpreter, so there is no need for the compile-link build procedure often associated with program development.

It is assumed throughout this document that the reader has a basic understanding of the DAL data model and the FITS file format.
 

Getting started

If the file HelloWorld contains the following simple deceit template

# File: HelloWorld
#
# HelloWorld is the simplest case of a deceit template
dataset "HelloWorld.dat"
then running the command:

                    deceit -infile=HelloWorld

will give rise to the dataset HelloWorld being created. It will contain no arrays, tables or attributes. The first three comment lines, which are skiped by the deceit interpreter, are not mandatory. This is essentially the simplest case of a deceit dataset specification, and gives rise to the simplest DAL dataset. The DAL supports both FITS and DAL file formats, but it is anticipated that deceit will be principally used to build FITS files.

Any number of dataset specifications may appear in a deceit template.

NB Deceit is a dataset creation tool and cannot be used to modify exisiting files.
 

Deceit Command Line Arguments

The deceit interpreter is invoked with the command

        deceit [options] [--]

where

    Options:
      --help  | -h
      --param | -p
      --trace | -t
      --noclobber | -c
      --version | -v
      --verbosity <level> | -V <level>
      --<param>=<value>
      --

The available parameters are

    Parameters:
    infile:
      type    = filename
      default = ""
    perllib: ./deceit [options] [--]

and the available options are

    Options:
      --help  | -h
      --param | -p
      --trace | -t
      --noclobber | -c
      --version | -v
      --verbosity <level> | -V <level>
      --<param>=<value>
      --
 

The deceit interpreter

Essentially white space (space, tabs, carriage-return and newline characters) and comments are skipped by the interpreter.

Comments are denoted by #, and include all text up to the end of the line. It is therefore not possible to place comments in the middle of a line.

There are some restrictions on the textual layout of a deceit template, imposed by the deceit parser (rather than by the deceit grammer). For instance, in the HelloWorld example above, the text

                dataset "HelloWorld"

must appear by itself on the line. If the template had been written as

                dataset
                    "HelloWorld"

deceit would not be able to correctly interpret the dataset name "HelloWorld". In addition, a dataset body, if present, must begin on a new line i.e.

dataset "HelloWorld"
< ... dataset items ...
> This header-body layout restriction applies to every specification in a deceit template i.e. dataset, table, array, column and attribute specifications.

Expressions, rather than literal values, are allowed in many of the item specifications. For example, the HelloWorld program could have been writtern as

                    # File: HelloWorld
                    #
                    # HelloWorld rewritten using an expression to construct the dataset name
                    # The built-in function param() is used to get the value of the parameter infile.
                    dataset param( "infile" ) + ".dat"

A number of built-in functions and  variables (which must never be redefined) may be used in expressions.  The syntax of expressions, together with a description of the built-in functions and variables is described later in this document.

The predefined variables are also described in each of the relevant sections.
 

Datasets

Essentially a deceit template comprises zero or more dataset specifications. The dataset specifications are placed into a file, and do not appear in the body of any other specification. There is no limit to the number of dataset specifications which may appear in a deceit template, but each dataset name must be unique (within the deceit template).

The general form of a dataset specification is as follows:

dataset dataset-name optional-expresionopt
< ... dataset item specifications ... >
where, The header part of the dataset specification (dataset dataset-name optional-expression) must be placed onto a single line.  For example, the following will not be interpreted correctly because the dataset's name does not appear on the same line as the dataset keyword:

        dataset
        "set1"
        <
            ... dataset item specifications ...
        >

In addition, the subsequent dataset body, which is delimited by < and >, is optional but, if present, must begin on a new line.

The value of dataset-name will be the name of the created file. If a file with the name already exists, it will be overwritten.

The dataset body comprises zero or more of the following specifications:

There is no limit to the number of items which may appear in a dataset specification.

The following are legal dataset specifications:

        # Examples of a dataset specifications
        dataset "ds1"        // Simplest case

       dataset "ds2"        // Empty body, which is quivalent to simplest case
        <
        >

       dataset "ds3"        // Several dataset items
       <
           attribute "att1"  int 10 "integer attribute" "m"
           attribute "att2" real 1.2 "real attribute" "m"
           array(5,4,2) "arr1"  int32 "integer array" "m"
           array(1024,1024) "arr2"  real64 "real array" "m"
           table "tab1" 10
           table "tab2" 20
       >

The variable dat is a predefined variable, the value of which is a pointer to the dataset and may be referenced in the optional expression, and also in the expressions of the dataset item specifications.  For example,

       dataset "ds1" fillDataSet( dat )
       <
       >

However, the optional expression will not usually be required  for datasets.
 

Tables

Table specifications may only appear in the body of a dataset specifcation. There is not limit to the number of table specifications which may appear in a dataset specification, but each specification should have a unique (within the dataset) name.

The general form of a table specification is as follows:

            table table-name rows optional-expressionopt
                <
                    ... table item specifications ...
                >

where,

The header part of the table specification (table table-name optional-expression) must be placed onto a single line.    For example the following will not be interpreted correctly because the table's name and rows value do not appear on the same line as the table keyword:

        dataset "set1"
        <
           table
                "tab1" 100
            <
            >
        >

In additon,the subsequent table body, which is delimited by < and >, is optional but, if present, must begin on a new line.

The table specification body comprises zero or more of the following specification:

There is no limit to the number of items which may appear in a table specification.

The following are legal table specifications:

           dataset "set1"
            <
            table "tab1" 10
            table "tab2" 20
              <
                attribute "att1" int 10 "integer attribute" "m"
                column "col1" int32 "integer column" "m"
                column "col2" int32 "integer column" "m"
              >
            table "tab3" 20
              <
                attribute "att1" real -10.12 "real attribute" "Nm"
                column "col1" real32 "real column" "Nn"
                column "col2" real64 "real column" "Nm"
              >
            >

The optional expression allows the table to be filled with data.

The variable tab is a pointer to the table and may be referenced in the expression. For example,

           dataset "ds1"
            <
               table "tab1" 100 fillTable( tab )
                <
                   column "col1" int16 "integer column" "Nm"
                   column "col2" int8 "integer column" "Nm"
                >
            >
 

Columns

Column specifications may only appear in the body of a table specification. There is no limit to the number of column specifications which may appear in the table body, but each column name must be unique (within the table).

The general form of a column specification is given by

       column column-dimensionsopt column-name data-type label units optional-expressionopt
        <
            ... column item specifications ...
        >

where,

The header part of the column specification (column column-name optional-expression) must be placed onto a single line.   For example the following example will not be interpreted correctly, because the column's name, data type, label and units do not appear on the same line as the column keyword:

        dataset "set1"
        <
           table "tab1" 100
            <
               column
                    "col1" int32 "a column" "m"
            >
        >

In addition, the subsequent body, which is delimited by < and >, is optional but, if present, must begin on a new line.

The column specification body comprises zero or more of the following specifications:

Scalar, multi-dimensional and variable length columns are all supported.

Scalar and multi-dimensional columns have fixed length.

Variable length columns are created by setting the column-dimensions to (0).

The optional expression allows the column to be filled with data.

The variable col is a pointer to the column and may be referenced in the expression. For example,

    dataset "ds1"
    <
       table "tab1" 100
       <
           column "col1" int32 "integer column" "m" fillColumn( col, "data.dat", 0 )
           column "col2" real64 "real column" "m" fillColumn( col, "data.dat", 1 ) )
           column(0) "col3" bool "bool column" "" fillColumn( col, "vardata.dat", 0 )        // variable size column
        >
    >
 

Arrays

Array specifications  may only appear in the body of dataset specifications. There is no limit to the number of array specifications which may appear in the array specification body, but each must have a unique name (within the dataset).

The general form of an array specification is given by

    array array-dimensions name array-data-type label units optional-expressionopt
    <
        ... array item specifications ...
    >

    where,

The header part of the array specification (array array-dimensions name array-data-type label units optional-expression) must be placed onto a single line.    For example the following will not be interpreted correctly because the array's name, data type, label and units do not appear on the same line as the table keyword:

        dataset "set1"
        <
                array(10,20)
                "arr1" int8 "an array" "Nm"
            <
            >
        >

In addition, the subsequent body, which is delimited by < and >, is optional but, if present, must begin on a new line.

The array specification body comprises zero or more of the following specification:

The optional expression allows the array to be filled with data.

The variable arr is a pointer to the array and may be referenced in the expression. For example,

    dataset "ds1"
    <
        array(10,20) "arr1" int32 "an integer array" "m" fillArray( arr )
        <
           attribute "att1" int 10 "an integer attribute" "Nm"
        >
    >
 

Attributes

Attribute specifications may appear in dataset, array, table and column body specifications.  There is no limit to the number of specifications which may appear in each of the allowed specification bodies, but each attribute specfication must have a unique name (within each of the body sections).

The general form of an attribute specification is given by

    attribute attribute-name attribute-data-type value label units optional-expressionopt
    <
        ... attribute item specifications ...
    >

where,

In general the body of an attribute will not be needed. The body may only contain the following specifications: For example, the following are all legal attribute specifications:

    attribute "att1" int 10 "an integer attribute" "m"
    attribute "att2" real 10.12 "a real attribute" "m"
    attribute "att3" bool  0 "a boolean attribute" "m"
    attribute "att4" bool  true "a boolean attribute" "m"
    attribute "att5" string 10 "a string attribute" "m"
 

History

History specifications may appear in the body of dataset, table and array specifications.  There is no limit to the number of history specifications which may appear in each of the allowed specification bodies.

There are two allowed formats for the history specification.

The first is the single string form whose general format is given by

         history string

where

The second form is given by

        history < free-format-text >

where


For example

    dataset "ds1"
    <
        history "Updated on 31/12/99"
        history <
           Updated on 1/12/99
        >
        table "tab1" 100
        <
            history "Updated by a.n.other"
        >
    >
 

Comment

Comment specifications may appear in the body of dataset, table and array specifications.  There is no limit to the number of comment specifications which may appear in each of the allowed specification bodies.

There are two allowed formats for the comment specification.

The first is the single string form whose general format is given by

         comment string

where

The second form is given by

        comment < free-format-text >

where


For example

    dataset "ds1"
    <
        comment "Updated on 31/12/99"
        comment <
           Updated on 1/12/99
        >
        table "tab1" 100
        <
            comment "Updated by a.n.other"
        >
    >
 

Execute Dal Block

The execute_dal block construction allows a group of arbitrary expressions to be executed. The general form is given by

        execute_dal < list_of_ expressions >

where


It may appear in a deceit template, or the bodies of dataset, table, array, column or attribute specifications.

There is no limit to the number of expressions in the block.
 

Execute Perl Block

The text contained in an execute_perl block is paased to the Perl interpreter as is.
 

Execute Post Block

The execute_post block is the same as the execute_dal block execept that it:

If multiple execute_post blocks appear in the same body, they a essentially concatenated (in order they appear).
 

Expressions
 

Literal Values


Operators
 
 
Operator
Priority
Description
+ plus 1
  • addition of numeric values
  • concatenation of string values
- minus 1 subtraction of numeric values
* multilpy 2 multiplication of numeric values
/ divide 2 division of numeric values
+ unary plus 3 unary plus of numeric values
- unary minus 3 unary minus of numeric values
++ post increment 4 post increment of numeric variables
-- post-decrement 4 post decrement of numeric variables
() parenthesis 5 parenthesis

Functions

The general form of a function call is given by

    function-name ( parameter-list )

where


Built-in Functions
 
 
FUNCTION OR VARIABLE
DESCRIPTION
void fillColumn(
    Column * column,
    String       fileName,
    int            columnNumber )
Copies the (ASCII) data from the column with position columnNumber (zero indexing)  in file fileName to the specified column. 
void fillTable(
    Table *      table
     String      fileName )
Copies the (ASCII) data from file fileName to the specified column.
String getenv( string name ) Returns the value, as a string, of the specified environment variable.
String param( String parameterName ) Returns the value, as a string, of the specified parameter.
int rows( Table * table) Returns the number of rows in the specified table.
Array * arr The value of arr is a pointer to the current Array being constructed.
Attribute * att The value of att is a pointer to the current Attribute being constructed.
Column * col The value of col is a pointer to the current Column being constructed.
DataSet * dat The value of dat is a pointer to the current DataSet being constructed.
bool false Boolean value of false.
Table * tab The value of tab is a pointer to the current Table being constructed.
bool true Boolean value of true.

 

DAL Interface

The functions C interface dal_c.h are all available from deceit.
 

Grammer

deceit-unit:
    deceit-specification

deceit-specification:
    dataset-block deceit-specification
    include-statement deceit-specification
    dal-block deceit-specification
    perl-block deceit-specification

dataset-block:
    dataset string-expression expressionopt dataset-block-bodyopt

dataset-body:
    < dataset-body-item >

dataset-body-item:
    table-specification dataset-body-item
    array-specification dataset-body-item
    attribute-specification dataset-body-item
    include-statement dataset-body-item
    history-specification dataset-body-item
    comment-specification dataset-body-item
    dal-block dataset-body-item
    perl-block dataset-body-item
    post-block dataset-body-item

attribute-specification:
    attribute string-expression attribute-data-type string-expression string-expresson expressionopt attribute-bodyopt

attribute-body:
    < attribute-body-item >

attribute-body-item:
    dal-block attribute-body-item
    perl-block attribute-body-item
    post-block attribute-body-item

attribute-data-type:
    int
    real
    bool
    string

table-specification:
    table string-expression integer-expression string-expression expressionopt table-bodyopt

table-body:
    < table-body-item >

table-body-item:
    column-specification table-body-item
    attribute-specification table-body-item
    include-statement table-body-item
    history-specification dataset-body-item
    comment-specification dataset-body-item
    dal-block table-body-item
    perl-block table-body-item
    post-block table-body-item

array-specification:
    array array-size-specification string-expression array-data-type string-expression string-expression expressionopt array-bodyopt

array-body:
    < array-body-item >

array-body-item:
    attribute-specification array-body-item
    Include-statement array-body-item
    history-specification dataset-body-item
    comment-specification dataset-body-item
    dal-block array-body-item
    perl-block array-body-item
    post-block array-body-item

array-data-type:
    int8
    int16
    int32
    real32
    real64
    bool

column-specification:
    column array-size-specificationopt string-expression column-data-type expressionopt column-bodyopt

column-body:
    < column-body-item >

column-body-item:
    attribute-specification column-body-item
    include-statement column-body-item
    dal-block column-body-item
    perl-block column-body-item
    post-block column-body-item

column-data-type:
    int8
    int16
    int32
    real32
    real64
    boolean
    string

array-size-specification:
    ( array-size-item )

array-size-item:
    integer-expression
    integer-expression , array-size-item

dal-block:
    execute_dal dal-block-body

dal-block-body:
    < dal-block-item >

dal-block-item:
    expression-statement dal-block-item

perl-block:
    execute_perl < free-text >

post-block:
    execute_post post-block-body

post-block-body:
    < post-block-item >

post-block-item:
    expression-statement post-block-item

include-statement:
    include string

string-expression:
    expression

integer-expression:
    expression

expression-statement:
    expression ;

expression:
    assignment-expression

assignment-expression:
    plus-expression
    plus-expression = assignment-expression
    plus-expression

plus-expression:
    plus-expression + mult-expression
    plus-expression - mult-expression

mult-expression:
    unary-expression
    mult-expression * unary-expression
    mult-expression / unary-expression

unary-expression:
    postfix-expression
    & unary-expression
    ! unary-expression
    + unary-expression
    - unary-expression
    * unary-expression

postfix-expression:
    primary-expression
    postfix-expression ( expression-listopt )
    array-expression
    postfix-expression++
    postfix-expression--

primary-expresson:
    integer
    real
    string
    identifier
    character
    ( expression )
    compound-statement

compound-statement:
    < compound-statement-item >

compound-statement-item:
    expression-statement compound-statement-item

block-statement:
    < block-statement-item >

block-statement-item:
    expression-statement block-statement-item

history-specification:
    history text

comment-specification:
    comment text

text:
    string
    < free-format-text >