[Flavors] Flavors Technology, Inc.


Paracell Users' Guide

  • Table of Contents
  • Introduction
  • Programming Model
  • Elements of the Language
  • Structure of the Language
  • Elements of Variables
  • Operators
  • Appendices
  • Flavors Home
  • Flavors Product Information
  • PIM/Paracell Presentation
  • PIM Configurations
  • Product Documentation
  • PIM/Paracell Product Summary
  • Paracell User's Guide
  • Application Notes
  • Flavors Staff
  • Flavors Links
  • Flavors Download Page

  • Structure of the Language

    In English, characters are assembled to form words, words are assembled to form sentences. The English grammar defines the structure in which the sentences are constructed. This chapter describes the grammar of the Paracell language, the way in which the elements of Paracell are assembled to form sentences. Parts of this chapter may seem obvious because Paracell borrows heavily from the English grammar.

    A sentence is the smallest unit of statement. In Paracell, you can instruct PIM to carry out an action, a command, or you can assign a meaning to a name, a definition. Some sentences can depend on the state of variables; these are conditional sentences. In the current version of Paracell, only sentences that are commands or constraints can be conditional.

    Sentences contain at least one pair of a name and a verb. A pair of a name and a verb forms a clause, forming a basic unit of sentence structure. Clauses may be composed of expressions. Expressions produce values when evaluated, and form the essence of command sentences. Sentences can also have comments. Comments are notes or remarks inserted in the sentences to clarify the meaning of the sentences. Comments do not contribute to the execution of the Paracell sentences.


    Clauses

     

    As in English, a clause is a group of words containing a subject (usually a name) and a predicate (usually a verb). Clauses form sentences. A sentence may have one or more clauses.

      Set x to 5.

    Here, "x" is the subject (a variable name), and "Set" is the verb. A sentence may have many clauses.

      Assign 5 to x, 2 to y, and 3 to z.

    This has three clauses, "assign 5 to x," "2 to y," and "and 3 to z." The last two clauses are dependent clauses. A clause is said to be dependent, if the predicate is omitted and relies on the predicate of another clause. In the above example, the last two clauses, "2 to y," and "and 3 to z," rely on the predicate of the first clause, "Assign 5 to x." The first clause, "Assign 5 to x," is an independent clause because it does not rely on any other clauses. The above example can be rewritten as three sentences, each with one independent clause.

      Assign 5 to x.  
      Assign 2 to y.  
      Assign 3 to z.

    A sentence can consist of more than one independent clause. For example,

      Assign 7 to x; increment y by 2.

    The above example is one sentence containing two independent clauses. This is the same as,

      Assign 7 to x. 
      Increment y by 2.


    (Return to Top of Page)

    Expressions

     

    In English, expressions are words or phrases that communicate ideas. In Paracell, there is a more rigid definition of expressions, borrowed from other computer languages. An expression is any symbolic mathematical form, such as an equation that produces a value when evaluated. The simplest expression consists of a variable or a constant. Expressions do not require any punctuation, although punctuation is often used to separate expressions from each other.

    Here are some examples of expressions. Let's say x has a value of -10 and y has a value of 5.

      x                    // This expression has a value -10.
      abs x                // This expression has a value 10.
      x divided by y       // This expression has a value -2 because -10 divided
                           // by 5 is -2.
      abs(x) divided by y  // This expression has a value of 2 because abs(-10) 
                           // is 10, and then 10 divided by 5 is 2.

    When a set of conditions determines the evaluated value of the expression, the expression is said to be conditional. Here is an example of a conditional expression.

      if y > 0 then x else abs x

    The evaluated value of this expression depends on the value of y. The condition "y > 0" makes this expression conditional. The group of keywords "if ... then ... else" is always an indication of a conditional expression. If a conditional expression forms a sentence, accomplished by adding a period at the end of the above example, the sentence is called a conditional sentence. For more information on sentences see the next section on Sentences.


    (Return to Top of Page)

    Sentences

     

    As in English, a sentence consists of at least one subject (a noun, a name) and a verb (a keyword). A set of subject and a verb forms either a clause or an expression. A sentence is made of at least a clause or an expression, and always ends with a period. The first character of the first word in a sentence is usually capitalized in the interest of style. There are two types of sentences in Paracell: commands and definitions.

    In Paracell, sentences are often commands beginning with a verb (a keyword) and ending with a set of nouns (names). A command instructs the PIM to carry out a set of actions. For example,

      Set Generator to 1.

    The verb, "Set," commands the PIM to assign a value of 1 to the variable named "generator."

    By attaching a condition to a sentence, it is made conditional. Conditional sentences are similar to conditional expressions. A conditional sentence performs a set of actions, while a conditional expression has a value. When a condition -- such as "if x > 0 then"-- is added to the above example, the sentence becomes conditional -- or a rule.

      If x > 0 then 
        Set generator to 1.

    A sentence that is a definition assigns a meaning to a name. For example,

      Generator is a machine integer.

    Here, the variable name, "Generator," is declared to be a Machine Integer.

    The current version of Paracell does not support conditional definitions.


    (Return to Top of Page)

    Commands

     

    A command is a sentence that instructs PIM to carry out a set of actions. A command shares its sentence structure with its English equivalent, imperative sentences. In Paracell, commands are always directed at PIM -- which is the nature of all programming languages. For this reason, commands constitute majority of Paracell code.

      Set Generator to 1.

    In the above example, the verb, "Set," commands the PIM to assign a value of 1 to the variable named "generator."

    In Paracell, sentences can be conditional. To make a command conditional, you add a set of conditions under which the set of actions will be carried out. For example, above example can be made conditional by attaching a condition.

      If x > 0 then 
        Set generator to 1.

    This command will only be carried out when the condition, "x > 0," is satisfied. These conditional commands are also refered to as rules.

    Commands can also take a concise "declarative" form. For example,

      x = y + 1.

    is the condensed form of the more English-like verbose sentences,

      set x to y + 1.

    or

      assign y + 1 to x.


    (Return to Top of Page)

    Definitions

     

    A definition is a sentence that names a variable or a constant. A variable is a reference to a value stored in the PIM, and a constant is a name assigned to a number.

    A definition assigns not only the name to a variable, but also the following set of information.

    1. a type for the variable (e.g., Machine Integer or Paracell Number)
    2. a scope; for the variable (e.g., local or global)
    3. an initial value

    Here's an example.

      Generator is a machine integer initially 10.

    This example creates a variable named "Generator," assigned a type, machine integer, with an initial value of 10. If an initial value is not given, a default value of 0 is assigned. The default scope of the variable is global, i.e., Generator is a global variable.

    The action of a variable declaration takes place by in the workstation only. The result of this action is passed to other sentences that perform actions in the PIM. In the above example, these sentences will include all sentences in the application that use or change the value of Generator. Here are some more examples.

      Generator_1 and Generator_2 are Paracell numbers.
      Generator is a local machine integer. 
      Generator_1 is the local constant 5.

    The last example shows a defintion of a constant. Here Generator_1 is declared as a constant of value 5. The value of a constant can not change. In the interest of style, names of constants are spelled with all letters capitalized.


    (Return to Top of Page)

    Conditional Sentences

     

    A sentence is called conditional, if its execution depends on a set of conditions. In Paracell, a condition can evaluate to one of three values: true, false, UNKNOWN. A condition is said to be satisfied, when the stated condition evaluates to true. Because there are three possible state to a condition, a conditional sentence can have, at most, three possible sets of actions. This is called three way branching.

    Currently in Paracell only commands can be conditional (definitions cannot). A conditional command is also refered to as a rule (in the Artificial Intelligence language), or an If statement (in the Computer Science language).

    Conditional commands easily recognizable, since the sentence must begin with the keyword "If." Writing a conditional sentence can be viewed as filling in each of the three branches. The format for a conditional sentence is,

      If [set of conditions] 
      Then [set of actions] 
      Else [set of actions] 
      UNKNOWN [set of actions].

    When the above set of conditions evaluates to true, the first set of actions, following the keyword "Then," is carried out. If the set of conditions evaluates to false, the second set of actions, following the keyword "Else," is carried out. When the set of conditions evaluate to NAN (Not A Number), then the last set of actions, following the keyword "UNKNOWN," is carried out. If you wish to execute just one set of action when the condtion evaluates to true, you may simply omitted the "Else..UNKNOWN" part of the above format. For example,

      If door is OPEN
      Then set alarm to ON.

    carries out the action, "set alarm to on," when the condition, "door is open," evaluates to true. The rest of the format is filled in automatically by the Paracell Compiler to do nothing. Here is an example of a set of two conditions with two sets of actions.

      If (Door is OPEN) and (alarm is GUARD) 
      Then assign YELLOW_ALERT to alarm, 
           LOUD_1 to alarm_bell, 
           CALL_SECURITY to auto_dialer,
      Else set alarm to OFF.

    The comma after auto_dialer is optional. An example of a full three way branching,

      If flow < min_flow
      Then output = output + 5
      Else  output = min_flow
      UNKNOWN set min_flow to 1.

    Here, the keyword UNKNOWN can also be replaced by another keyword, NAN, the actual value representing the unknown condition. The concept of three way branching allows you the flexibility to respond to unanticipated conditions. When for some unforeseen reason, the condition, "flow < min_flow," evaluates to NAN, the variable "min_flow" is reset to 1. In this situation, you can still trace and analyze this unanticipated condition, without having the code break on you.

    In Paracell, there are methods provided for converting the three-way branching into the conventional two way branching. Adding "or Unknown" to the condition is one way.

      If [set of conditions] or Unknown
      Then [set of actions] 
      Else [set of actions]

    This attaches the NAN branch to the THEN branch. If the [set of conditions] evaluate to NAN, then the [set of actions] following the keyword Then is executed. To attach the NAN branch to the ELSE branch, use the following format.

      If [set of conditions] and Known
      Then [set of actions] 
      Else [set of actions]

    Here is an example of this two way branching.

      If (flow < min_flow) and Known 
      Then Increment output by 5
      Else  output = min_flow

    The variable "output" is incremented by 5, only when the condition "flow < min_flow" evaluates to true. If the condition evaluated to false or NAN, then "output" is reset to min_flow. Note that in this example, the parenthesis are required, and the variables, "flow" and "min_flow", must be Paracell Numbers (a type of Safe Numbers).


    (Return to Top of Page)

    Comments

     

    Although Paracell is a self-documenting language, there are times when you may wish to write your code in a compact form. In such cases, it may be necessary to add some explanation, notes, or comments to clarify your intention. Comments are parts of the Paracell code that are ignored. Comments do not perform any action, but exist solely for your information.

    There are two ways of writing comments. The first is to mark the beginning and the end with a set of special characters, "/*" and "*/". Here is an example,

      Assign x to y.       /*  This is a comment */

    The second way would be,

      Assign x to y.      //    This is also a comment.

    The special character, "//", signals the beginning of a comment. This comment marker assumes that the comment continues to the end of the line. Any printable characters can be used in comments.

    Comments within comments are not allowed. For example,

      /* when this type of comments /* this */ is not allowed */

    This results in mismatched comment marker. The first "/*" will be matched to the first "*/". Hence, the last part of the comment, "is not allowed */", will be considered illegal.


    Next: Elements of Variables, Top: Table of Contents


     

    Flavors Technology, Inc.
    Sunrise Labs
    5 Dartmouth Drive
    Auburn, NH 03032 USA
    Internet: info@flavors.com
    Telephone: 603-644-4500 / Fax: 603-622-9797

    Copyright© 1993-6 by Flavors Technology, Inc. All rights Reserved.