Validation

When the 4GL logic has been transformed into an XML document, syntax checking and validation will be performed. The grammar and syntax rules of the 4GL logic are outlined in a language validation file. Every 4GL logic command has an entry is this file.

The folowing example describes the syntax of the 4GL logic command "LET".

. . .
. . .
  <!-- Logic Command 5 : LET -->
  <LogicCommand Command="5">
    <MinArguments>3</MinArguments>
    <MaxArguments>999</MaxArguments>
    <Arguments>
      <Argument Step="1">
        <ArgumentStep Path="1" Style="SingleDataReferenceWrite" NextStep="2"/>
      </Argument>
      <Argument Step="2">
        <ArgumentStep Path="1" Style="Static" Value="=" NextStep="3"/>
      </Argument>
      <Argument Step="3">
        <ArgumentStep Path="1" Style="Static" Value="CALL" NextStep="10" />
        <ArgumentStep Path="2" Style="Numeric" NextStep="20" LastStep="True"/>
        <ArgumentStep Path="3" Style="SingleDataReference" NextStep="20" LastStep="True"/>
        <ArgumentStep Path="4" Style="String" NextStep="20" LastStep="True"/>
        <ArgumentStep Path="5" Style="MathFunction" NextStep="31" LastStep="True"/>
      </Argument>
                                                                                                                                        
      <!-- Logic Call -->
      <Argument Step="10">
        <ArgumentStep Path="1" Style="ObjectNameLogic" NextStep="11" LastStep="True"/>
        <ArgumentStep Path="2" Style="SingleDataReference"  NextStep="11" LastStep="True" />
      </Argument>
      <Argument Step="11">
        <ArgumentStep Path="1" Style="Numeric" NextStep="11" LastStep="True" />
        <ArgumentStep Path="2" Style="SingleDataReference"  NextStep="11" LastStep="True" />
        <ArgumentStep Path="3" Style="String"  NextStep="11" LastStep="True" />
        <ArgumentStep Path="4" Style="Static" Value="RETURNING" NextStep="12" LastStep="False" />
      </Argument>
      <Argument Step="12">
        <ArgumentStep Path="1" Style="SingleDataReferenceWrite"  NextStep="12" LastStep="True" />
      </Argument>
                                                                                                                                        
      <!-- Calculation/Concatenation -->
      <Argument Step="20">
        <ArgumentStep Path="1" Style="MathOperator" NextStep="30" />
        <ArgumentStep Path="2" Style="Numeric" NextStep="40" LastStep="True" />
        <ArgumentStep Path="3" Style="SingleDataReference"  NextStep="40" LastStep="True" />
        <ArgumentStep Path="4" Style="String"  NextStep="40" LastStep="True" />
      </Argument>

      <!-- Calculation -->
      <Argument Step="30">
        <ArgumentStep Path="1" Style="Numeric" NextStep="31" LastStep="True"/>
        <ArgumentStep Path="2" Style="SingleDataReference"  NextStep="31" LastStep="True" />
        <ArgumentStep Path="3" Style="MathFunction"  NextStep="31" LastStep="True" />
      </Argument>
      <Argument Step="31">
        <ArgumentStep Path="1" Style="MathOperator" NextStep="30" />
      </Argument>
                                                                                                                                        
      <!-- Concatenation -->
      <Argument Step="40">
        <ArgumentStep Path="1" Style="Numeric" NextStep="40" LastStep="True" />
        <ArgumentStep Path="2" Style="SingleDataReference"  NextStep="40" LastStep="True" />
        <ArgumentStep Path="3" Style="String"  NextStep="40" LastStep="True" />
      </Argument>
                                                                                                                                        
    </Arguments>
  </LogicCommand>
. . .
. . .

The first step is to check if the number of arguments is within the limit of number of expected arguments. Next the arguments will be processed one by one and tried to be matched with a path entry starting with 1. If the argument does not match a path entry, the number will be raised and will be matched against the next path entry until all arguments are processed. As soon as a path entry is matched, the argument will be validated in case it is a data reference where the value needs to be read from the Repository. To indicate that arguments can be used more than once, the setting NextStep can be used to point back to the first repeating argument. The setting LastStep indicate if the argument can be the last one.

If anything goes wrong in this whole validate process, an error will be generated and returned to the caller.

The following styles are defined :

Table 1. Validation Styles

StyleDescription
AnyName:Any object name not being a datareference or string, which can not be validated. Example: CLEAR CONTAINER Main. Main is here a container on the current screen. At validate time we don't know this name of the current screen and container 'Main' can not further be validated.
ControlFunctionName:Any name of a built-in control function. Example: CONTROL cancel
MathFunction:Math functions like sin(1) or abs(L-value)
MathOperator:Math Operators like + - >= etc.
Numeric:Any numeric value.
ObjectName NameOfObject:Validation of a base object. The name of the object will be lifted from the style name. Examples: ObjectNameDataDictionary
SingleDataReference:Any DataReference that can hold a single value. Examples: L-Value P-size(2) C-MaxWeight
SingleDataReferenceWrite:Any non-read-only SingleDataReference.
GroupDataReference:Any DataReference that can hold a group of Data Dictionaries. like Records and VariableGroups. Examples: R-Size H-Selection
GroupDataReferenceWrite:Any non-read-only GroupDataReference.
Static:Hardcoded value. An attribute "Value=" need to be added containing the value.
String:Any text between double quotes (" ").
UnsignedInteger:Any whole positive number.
Comparator:Compare values: = < <= > >= <>