home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / EXAMPLES / SUPERLIN / SUPERLIN.DOC < prev    next >
Text File  |  1996-06-04  |  55KB  |  1,958 lines

  1.  
  2. ____________________________________________________________________________
  3.  
  4.                                SuperLint
  5. ____________________________________________________________________________
  6.  
  7.                     A generator of C source analyzers
  8. ____________________________________________________________________________
  9.  
  10. Author   : Arnaud Venet
  11. Date     : Feb 19th 1994
  12. Modified : Mar  4th 1994
  13. Version  : 0.3
  14. ____________________________________________________________________________
  15.  
  16.               (C) Digital Equipment Corporation 1993 - 1994  
  17. ____________________________________________________________________________
  18.  
  19. This document gives a rapid description of the SuperLint package. 
  20. SuperLint is a real application written in LIFE allowing the user to build 
  21. lint-like tools for K&R and ANSI C programs. The user can enter rules 
  22. written in a simple C-like language which will be automatically applied or,
  23. if he is ambitious, write a real program in LIFE, using directly the
  24. syntactic structures provided by the integrated C parser.
  25. This tool is a prototype.  All comments, suggestions and bug reports are
  26. welcome.
  27. ____________________________________________________________________________
  28.  
  29. An extended example of use is in the file 'rules.lf' of the package
  30. ____________________________________________________________________________
  31.  
  32.  
  33.  
  34. Overview
  35. ========
  36.  
  37. SuperLint is built on top of a parser which produces a rich representation
  38. of C code (a fully annotated syntax tree). Building an analyzer consists
  39. in writing a set of rules that use the syntactic structures produced by the
  40. parser.
  41.  
  42. In the most general case, the difficulty is that the user must write his
  43. own procedure exploring the syntactic tree and collecting the needed
  44. information, which may be very tedious.
  45.  
  46. It turns out that in most cases the verifications are local in the sense
  47. that the user only needs the information reachable from one or more
  48. particular nodes. A characteristic example is an analyzer that checks a C
  49. program with regard to a set of style rules. In this case a rule only needs 
  50. the lexical information contained in the node to which it applies.
  51.  
  52. Therefore we provided SuperLint with a C-like language which allows the 
  53. user to write easily a set of verification rules, each rule being only 
  54. applicable to some syntactic structures. Then a procedure can be called 
  55. which automatically explores all the nodes of the tree and for each one
  56. invokes the appropriate rules.
  57.  
  58. But actually SuperLint is much more than a simple C-code verifier. It is
  59. a real programming environment entirely dedicated to the manipulation of 
  60. C-programs, ranging from stylistic verifications to code rewriting or static
  61. analysis. The C-like rules specification language is expanded into LIFE
  62. code, and it is possible to mix in a same file parts of code written in
  63. this language and real LIFE code. Thus one can take advantage of all the
  64. functionalities and tools offered by Wild_LIFE, like the X Window interface
  65. for example.  A typical use consists in writing libraries of functions and
  66. procedures which involve complex manipulations in LIFE and the analyzers
  67. specifications in C-like code.   We illustrate this with a small toolkit that
  68. is provided with SuperLint and which is systematically imported by each
  69. analyzer.  Moreover modules are fully supported. It is thus possible to
  70. construct complete encapsulated programming libraries devoted to the purpose
  71. of the SuperLint user.
  72.  
  73. We will first give a brief description of the syntactic structures produced 
  74. by the parser, then we will explain how to write analyzers.
  75.  
  76.  
  77.  
  78.  
  79. I. Syntactic structures
  80. =========================
  81.  
  82. 0 - Notations
  83. -------------
  84.  
  85. The syntactic and lexical structures are represented by psi-terms,
  86. that is, by flexible records.  The record type is called the "root sort"
  87. of the psi-term.  The field names are called "features".  We use the
  88. following notation to describe the psi-term with root sort PsiTerm and
  89. the features Feature1, ..., FeatureN :
  90.  
  91.  PsiTerm
  92.  -------
  93.   o Feature1 : 
  94.       description of Feature1
  95.       .
  96.       .
  97.       .
  98.   o FeatureN : 
  99.       description of FeatureN
  100.  
  101. Several symbols separated by commas may sometimes be written in place of
  102. 'PsiTerm' above. This simply means that several psi-terms with different
  103. root sorts share the same features with identical meanings.
  104. In the following we will use the term 'structure' to denote psi-terms.
  105.  
  106. The parser was built upon the grammar specified in Kernighan & Ritchie :
  107. "The C programming language", 2nd edition.
  108.  
  109.  
  110. 1 - Tokens
  111. ----------
  112. All tokens have the common features :
  113.  
  114.  o file : 
  115.      the name of the file in which the token was found
  116.  
  117.  o line : 
  118.      the line number of the token in its file
  119.  
  120.  o column : 
  121.      the column number of the token in its file
  122.  
  123.  o white_spaces : 
  124.      a string containing all the white spaces (blank, tab, newline) 
  125.      preceding the current token
  126.  
  127.  o previous : 
  128.      the token preceding the current one
  129.  
  130.  o next : 
  131.      the token following to the current one
  132.  
  133.  o first : 
  134.      the first token in the file
  135.  
  136.  o last : 
  137.      the last token in the file
  138.  
  139. The tokens are :
  140.  
  141.  
  142. nothing
  143. -------
  144.  The empty token. Actually, the value of the 'previous' feature of the
  145.  first token and the 'next' feature of the last token in a file.
  146.  
  147.  
  148. identifier
  149. ----------
  150.  o id : 
  151.      the string representing the identifier
  152.  
  153.  
  154. characters_string
  155. -----------------
  156.  o string : 
  157.      the string itself, all escape characters being processed
  158.  
  159.  o extended : 
  160.      a boolean telling whether the string is extended (i.e. preceded
  161.      by an uppercase 'L' letter)
  162.  
  163.  
  164. character
  165. ---------
  166.  o char : 
  167.      the string representing the character, all escape characters 
  168.      being processed
  169.  
  170.  o extended : 
  171.      a boolean telling whether the character is extended (i.e. preceded
  172.      by an uppercase 'L' letter)
  173.  
  174.  
  175. number
  176. ------
  177.  o num : 
  178.      the description of the number. It may be :
  179.    
  180.      - int
  181.        ---
  182.         o value : 
  183.             the string representing the integer
  184.  
  185.         o base : 
  186.             the base of the integer. It may be
  187.             - octal
  188.             - decimal
  189.             - hexadecimal
  190.  
  191.         o signed : 
  192.             a boolean telling whether a 'S' suffix was present
  193.  
  194.         o long : 
  195.             a boolean telling whether a 'L' suffix was present
  196.  
  197.      - float
  198.        -----
  199.         o integer_part : 
  200.             the string representing the integer part of the float
  201.  
  202.         o decimal_part : 
  203.             the string representing the decimal part of the float 
  204.             ("0" if none)
  205.  
  206.         o exponential_part : 
  207.             It is
  208.  
  209.             exponential_part
  210.             ----------------
  211.              o value : 
  212.                  the string representing the exponential part of the float 
  213.                  ("0" if none)
  214.             
  215.              o sign : 
  216.                  the sign of the exponential part. It may be :
  217.                  - positive
  218.                  - negative
  219.  
  220.         o type : 
  221.             depending on the eventual suffix. It may be :
  222.             - float
  223.             - double
  224.             - long_double
  225.  
  226.  
  227. The vararg token : '...'
  228. ------------------------
  229.  
  230.  
  231. An operator symbol
  232. ------------------
  233. It may be : '+', '-', '*', '/', '<', '>', '&', '|', '!', '%', '^', 
  234.             '~', '<<', '>>', '=', '+=', '-=', '*=', '/=', '%=', '&=', 
  235.             '^=', '|=', '<<=', '>>=', '!=', '?', '.', '->'
  236.  
  237.  
  238. A separator symbol
  239. ------------------
  240. It may be : ',', ';', ':', '(', ')', '{', '}', '[', ']'
  241.  
  242.  
  243. A keyword
  244. ---------
  245. It may be :
  246.  
  247. auto         break         case         char
  248. const        continue      default      do
  249. double       else          enum         extern
  250. float        for           goto         if
  251. int          long          register     return
  252. short        signed        sizeof       static
  253. struct       switch        typedef      union
  254. unsigned     void          volatile     while
  255.  
  256.  
  257. NOTE : When you access a token name from within an analyzer the root sort
  258. ----   of a token is always converted into a string because some
  259.        symbols like '(', '{', ...etc are difficult to handle explicitly
  260.        in LIFE code (parse problems). In all cases you'd better use the
  261.        'string2id' function (see section 3, part II).
  262.  
  263.  
  264. 2 - Types
  265. ---------
  266.  
  267. We note simple types :
  268.  - void, char
  269.  - the numerical types
  270.  - the structures and unions
  271.  - the enumerations
  272. The complex types are the pointers, arrays, tags and types between 
  273. parentheses.
  274.  
  275. All simple types have these common features :
  276.  
  277.  o qualification : 
  278.      It may be
  279.      - const
  280.      - volatile
  281.      - nothing
  282.      The case nothing occurs when no qualifier was specified.
  283.  
  284.  o store_class : 
  285.      It may be
  286.      - auto
  287.      - register
  288.      - static
  289.      - extern
  290.      - nothing
  291.      The case nothing occurs when no store class was specified.
  292.  
  293.  o specifiers : 
  294.      it is the list of the lexical type specifiers. They are keyword tokens 
  295.      like 'int', 'const', ...etc and also :
  296.  
  297.      - type_alias
  298.        ----------
  299.         It represents an identifier previously aliased to a type in a 'typedef'
  300.         statement. Its only feature is :
  301.          o name : the corresponding identifier token
  302.  
  303.      - struct_name, union_name, enum_name
  304.        ----------------------------------
  305.         It represents an identifier designing a structured or enumerated type. 
  306.         Its features are :
  307.         o name : 
  308.             the identifier token representing the name of the complex type
  309.  
  310.         o keyword : 
  311.             the keyword coming with the identifier. It is one of the tokens : 
  312.             struct, union, enum
  313.  
  314.      - struct, union, enum
  315.        -------------------
  316.         It is the case of an anonymous struct definition. See below for further
  317.         details.
  318.  
  319.  
  320. 2.1 Simple types
  321. ----------------
  322.  
  323. void
  324. ----
  325.  
  326.  
  327. char, int, short_int, long_int, float, double, long_double
  328. ----------------------------------------------------------
  329.  o signed : 
  330.      a boolean which is true when type is signed
  331.  
  332.  o inserted : 
  333.      this feature is optional. It's present for a type 'int' which has been 
  334.      inserted by the parser when he encounters a function declaration without 
  335.      a return type (i.e. for external and local declarations and for function
  336.      definitions).
  337.  
  338.  
  339. struct, union
  340. -------------
  341.  o keyword : 
  342.      one of the tokens : struct, union
  343.  
  344.  o body : 
  345.      the body of the struct or union type specification. It is
  346.  
  347.      struct_body, union_body
  348.      -----------------------
  349.       o left_brace : the token "{" beginning the body definition
  350.       o fields :
  351.           It is a structure of root sort 'fields' containing as features 
  352.           the names of all the fields of the C structure or union. These names 
  353.           are strings. The name of an anonymous tag is "tag*N" where N is an 
  354.           integer (it tells that it's the Nth anonymous tag encountered in the
  355.           structure).
  356.           It has the extra feature 'first_member' which gives the first field
  357.           in the C structure or union.
  358.           The structure of a field is :
  359.  
  360.           field
  361.           -----
  362.            o name : 
  363.                the identifier token of the field name or the structure :
  364.  
  365.                anonymous_tag
  366.                -------------
  367.                 o id : the tag name generated by the parser
  368.  
  369.                in the case of an anonymous tag.
  370.  
  371.            o type : 
  372.                the type of the field
  373.  
  374.            o initialization : 
  375.                an initialization expression (see section 6.7 for further 
  376.                details)
  377.  
  378.            o separator : 
  379.                the separator token at the end of the field specification 
  380.                (namely a semicolon)
  381.  
  382.            o first : 
  383.                the first field in the structure
  384.  
  385.            o last : 
  386.                the last field in the structure
  387.  
  388.            o previous : 
  389.                the previous field (if any, nothing otherwise)
  390.  
  391.            o next : 
  392.                the next field (if any, nothing otherwise)
  393.  
  394.       o right_brace : the token "}" ending the body definition
  395.  
  396.  
  397. enum
  398. ----
  399.  o keyword : 
  400.      the token enum
  401.  
  402.  o body : 
  403.      the body of the enum type specification. It is
  404.  
  405.      enum_body
  406.      ---------
  407.       o left_brace : 
  408.           the token "{" beginning the body definition
  409.  
  410.       o enumerators :
  411.           It is a structure of root sort 'enumerators' containing as features 
  412.           the names of all the enumerators defined in the enum statement.
  413.           These names are strings. It also has the feature 'first_member' 
  414.           which gives the first enumerator specified.
  415.           The structure of an enumerator is :
  416.  
  417.           enumerator
  418.           ----------
  419.            o name : 
  420.                the identifier token of the enumerator
  421.  
  422.            o initialization : 
  423.                an initialization expression (see section 6.7 for further 
  424.                details)
  425.  
  426.            o separator : 
  427.                the separator token at the end of the field specification 
  428.                (namely a comma) or nothing
  429.  
  430.            o initialization : 
  431.                an initialization expression (see section 6.7 for further 
  432.                details) setting the value of the enumerator
  433.  
  434.            o first : 
  435.                the first enumerator in the enumeration
  436.  
  437.            o last : 
  438.                the last enumerator in the enumeration
  439.  
  440.            o previous : 
  441.                the previous enumerator (if any, nothing otherwise)
  442.  
  443.            o next : 
  444.                the next enumerator (if any, nothing otherwise)
  445.  
  446.       o right_brace : the token "}" ending the body definition
  447.  
  448.  
  449. 2.2 Complex types
  450. -----------------
  451.  
  452. protected_type 
  453. --------------
  454. Case of a type between parentheses
  455.  o left_parenthesis : 
  456.      the token "("
  457.  
  458.  o type : 
  459.      the type between parentheses
  460.  
  461.  o right_parenthesis : 
  462.      the token ")"
  463.  
  464.  
  465. pointer
  466. -------
  467.  o to : 
  468.      the type the pointer points to
  469.  
  470.  o star : 
  471.      the token "*" appearing in the type specification
  472.  
  473.  o qualification : 
  474.      the pointer's qualification, the same as for simple types.
  475.  
  476.  
  477. array
  478. -----
  479.  o of : 
  480.      the type of the elements of the array
  481.  
  482.  o dimensions : 
  483.      the dimensions of the array. It is
  484.  
  485.      dimensions
  486.      ----------
  487.       o dimensions_number : 
  488.           the number of dimensions of the array
  489.  
  490.       o features 1..dimensions_number : 
  491.           they are the dimensions of the array.
  492.           A dimension is 
  493.     
  494.           dimension
  495.           ---------
  496.            o left_bracket : 
  497.                the token "["
  498.  
  499.            o size : 
  500.                the constant expression defining the size of the dimension
  501.                or 'nothing' if unspecified.
  502.  
  503.            o right_bracket : 
  504.                then token "]"
  505.  
  506.  
  507. tag
  508. ---
  509.  o type : 
  510.      the type of the tag
  511.  
  512. You must note that in this case the size of the tag is put in the
  513. initialization feature of the associated declarations (see section 6.7).
  514. This enables an homogeneous presentation of the declarations.
  515.  
  516.  
  517. function
  518. --------
  519.  o return_type : 
  520.      the return type of the function
  521.  
  522.  o left_parenthesis : 
  523.      the token "(" preceding the parameters specification
  524.  
  525.  o parameters : 
  526.      It is 'nothing' (if no parameter is specified) or
  527.  
  528.      parameters
  529.      ----------
  530.       o parameters_number : 
  531.           number of parameters
  532.  
  533.       o vararg : 
  534.           this boolean is true when the function accepts a variable
  535.           number of arguments (in this case, 'parameters_number' is the number
  536.           of parameters explicitly declared).
  537.  
  538.       o suspension_points : 
  539.           this feature exists only if 'vararg' is true. It contains the token 
  540.           '...' which appears at the end of the parameters specification.
  541.  
  542.       o the features 1..parameters_number : 
  543.           Each feature contains a parameter specification, namely
  544.  
  545.           parameter
  546.           ---------
  547.            o name : 
  548.                the corresponding identifier token if any, or an 'anonymous'
  549.                structure :
  550.  
  551.                anonymous
  552.                ---------
  553.                 o file :
  554.                     the name of the file in which the parameter's specification
  555.                     occurs
  556.  
  557.                 o line :
  558.                     the corresponding line number in the previous file
  559.  
  560.                 o white_spaces :
  561.                     the empty string : ""
  562.  
  563.                This case is related to ANSI function prototypes where the
  564.                types of the arguments appear without any name.
  565.  
  566.            o type : 
  567.                the parameter type
  568.  
  569.           or
  570.  
  571.           label_parameter
  572.           ---------------
  573.            It only occurs in K&R C function definition : only the names of
  574.            parameters appear in the function head. Their types are specified
  575.            at the beginning of the function body.
  576.             o label : 
  577.                 the corresponding identifier token
  578.  
  579.           Both kinds of parameters have the common features :
  580.  
  581.            o separator : 
  582.                the comma following the parameter, if not the last one, 
  583.                'nothing' otherwise (for an explication of the semicolon
  584.                case see 'parameters_declarations' in section 3.2).
  585.  
  586.            o previous : 
  587.                the previous parameter, if any, 'nothing' otherwise
  588.  
  589.            o next : 
  590.                the next parameter, if any, 'nothing' otherwise
  591.  
  592.            o first : 
  593.                the first parameter in the specification
  594.  
  595.            o last : 
  596.                the last parameter in the specification
  597.  
  598.  o right_parenthesis : 
  599.      the token ")" ending the parameters declaration
  600.  
  601.  
  602. 3 - Type and Function Definitions
  603. ---------------------------------
  604.  
  605. 3.1 Type definitions
  606. --------------------
  607.  
  608. All type definitions have the common features :
  609.  
  610.  o previous : 
  611.      the previous statement, i.e., type definition, declaration or
  612.      function definition depending on the location of the current type
  613.      definition (external, local declaration)
  614.  
  615.  o next : 
  616.      the next statement
  617.  
  618.  o first : 
  619.      the first statement in the type definition's scope
  620.  
  621.  o last : 
  622.      the last statement in the type definition's scope
  623.  
  624.  
  625. type_definition
  626. ---------------
  627.  o keyword : 
  628.      the token typedef
  629.  
  630.  o type : 
  631.      the type being defined
  632.  
  633.  o name : 
  634.      the corresponding identifier
  635.  
  636.  o separator : 
  637.      the comma or semicolon token ending the type definition
  638.  
  639.  
  640. struct_definition, union_definition, enum_definition
  641. ----------------------------------------------------
  642.  o keyword : 
  643.      a keyword token among struct, union, enum
  644.  
  645.  o name : 
  646.      the corresponding identifier
  647.  
  648.  o body : 
  649.      the body of the compound type (see previous section)
  650.  
  651.  
  652. 3.2 Function definitions
  653. ------------------------
  654.  
  655. function_definition
  656. -------------------
  657.  o type : 
  658.      a 'function' type describing the function head
  659.  
  660.  o name : 
  661.      the corresponding identifier token
  662.  
  663.  o style : 
  664.      it is 'old' for a K&R's style function definition, 'modern' for
  665.      an ANSI definition
  666.  
  667.  o parameters_declarations : 
  668.      it is
  669.   
  670.      parameters_declarations
  671.      -----------------------
  672.       o ParameterDeclaration1
  673.           .
  674.           .
  675.           .
  676.       o ParameterDeclarationN
  677.  
  678.       o parent_declarations :
  679.           the 'toplevel' declarations (see section 4.1)
  680.  
  681.       o first_declaration
  682.  
  683.      The features names ParameterDeclarationX are string corresponding to the
  684.      parameters names (if any). They contain :
  685.  
  686.      parameter_declaration
  687.      ---------------------
  688.       o parameter : 
  689.           a 'parameter' structure (see 'function' type, section 2).
  690.           For K&R function definitions this structure refers to the
  691.           corresponding declaration between the function's head and body.
  692.  
  693.       o previous : 
  694.           the previous parameter declaration if any, 'nothing' otherwise
  695.  
  696.       o next : 
  697.           the next parameter declaration if any, nothing otherwise
  698.  
  699.       o first : 
  700.           the first parameter declaration
  701.  
  702.       o last : 
  703.           the last parameter declaration
  704.  
  705.       o scope : 
  706.           it is
  707.  
  708.           function_head
  709.           -------------
  710.            o function_name : 
  711.                a string representing the function's name where the parameter 
  712.                declaration appears
  713.  
  714.      The feature first_declaration contains the first parameter declaration
  715.      if any, 'nothing' otherwise.
  716.      Note that a 'parameter_declaration' structure can be inserted by the
  717.      parser when a parameter figures in the head of a K&R function definition
  718.      but is not declared thereafter. In this case the type of the parameter
  719.      is by default set to 'int'. 
  720.  
  721.  o body : 
  722.      the function body. It's a 'block' instruction (see section 5)
  723.  
  724.  
  725. 4 - Declarations
  726. ----------------
  727.  
  728. 4.1 The toplevel declarations
  729. -----------------------------
  730.  
  731. This structure is the root of the syntactic tree :
  732.  
  733.  
  734. toplevel
  735. --------
  736.  o parent_declarations : 
  737.      nothing
  738.  
  739.  o type_definitions : 
  740.      a term of root sort 'type_definitions'. The features are strings 
  741.      representing the names of the type aliases. Each feature contains a 
  742.      'type_definition' term (see section 3.1)
  743.  
  744.  o struct_definitions : 
  745.      a term of root sort 'struct_definitions'. The features are strings 
  746.      representing the names of the structures defined. Each feature contains 
  747.      a 'struct_definition' term (see section 3.1)
  748.  
  749.  o union_definitions : 
  750.      on the same model as struct_definitions
  751.  
  752.  o enum_definitions : 
  753.      on the same model as struct_definitions
  754.  
  755.  o struct_declarations : 
  756.      a term of root sort 'struct_declarations'. The features are strings 
  757.      representing the names of the structures declared. Each feature contains
  758.      a 'struct_declaration' term (see section 4.3)
  759.  
  760.  o union_declarations : 
  761.      on the same model as struct_declarations
  762.  
  763.  o enum_declarations : 
  764.      on the same model as struct_declarations
  765.  
  766.  o external_declarations : 
  767.      a term of root sort 'external_declarations'. The features are strings 
  768.      representing the names of the identifiers declared. Each feature contains
  769.      an 'external_declaration' (see section 4.3)
  770.  
  771.  o function_definitions :
  772.      a term of root sort 'function_definitions'. The features are strings 
  773.      representing the names of the functions defined. Each feature contains
  774.      a 'function_definition' term (see section 3.2)
  775.  
  776.  o files :
  777.      it is
  778.   
  779.      files
  780.      -----
  781.       o files_number : 
  782.           the number of files that have been parsed when SuperLint was called
  783.  
  784.       o 1 .. file_number :
  785.           each feature contains a 'file_info' structure, namely :
  786.  
  787.         file_info
  788.         ---------
  789.          o name :
  790.              a string representing the name of the file as he was typed on
  791.              the command line when SuperLint was called
  792.  
  793.          o first_token :
  794.              the first token in the file
  795.  
  796.  
  797. 4.2 Block declarations
  798. ----------------------
  799.  
  800. These are the declarations appearing at the beginning of a block { ... } :
  801.  
  802.  
  803. block_declarations
  804. ------------------
  805.  o parent_declarations :
  806.      it may be a structure
  807.      - 'parameters_declarations' for a function body (see section 3.2)
  808.      - 'block_declarations' for a nested block
  809.  
  810.  o local_declarations : 
  811.      a term of root sort 'local_declarations'. The features are strings 
  812.      representing the names of the identifiers declared in the block. 
  813.      Each feature contains a 'local_declaration' (see section 4.3)
  814.  
  815.  o type_definitions :
  816.      the same as for toplevel
  817.  
  818.  o struct_definitions :
  819.      the same as for toplevel
  820.  
  821.  o enum_definitions :
  822.      the same as for toplevel
  823.  
  824.  o union_definitions :
  825.      the same as for toplevel
  826.  
  827.  o struct_declarations :
  828.      the same as for toplevel
  829.  
  830.  o enum_declarations :
  831.      the same as for toplevel
  832.  
  833.  o union_declarations :
  834.      the same as for toplevel
  835.  
  836.  
  837. 4.3 Single declarations
  838. -----------------------
  839.  
  840. All single declarations have the common features :
  841.  
  842.  o scope :
  843.      the declarations which the declaration belongs to. It may be
  844.      'toplevel' or 'block_declarations'
  845.  
  846.  o previous : 
  847.      the previous statement (declaration, function definition, type definition,
  848.      according to the context) in the declaration's scope
  849.  
  850.  o next : 
  851.      the next statement in the declaration's scope
  852.  
  853.  o first : 
  854.      the first statement in the declaration's scope
  855.  
  856.  o last : 
  857.      the last statement in the declaration's scope
  858.  
  859. Logically the parameter_declaration structure should figure here.
  860. However for clarity we described it with the function_definition structure.
  861.  
  862. The single declarations are :
  863.  
  864.  
  865. external_declaration, local_declaration
  866. ---------------------------------------
  867.  o type : 
  868.      the type of the declared identifier
  869.  
  870.  o name : 
  871.      the corresponding identifier token
  872.  
  873.  o initialization : 
  874.      the initialization expression if any (see section 6.7), 'nothing' 
  875.      otherwise
  876.  
  877.  o separator : 
  878.      a comma or semicolon token ending the declaration
  879.  
  880.  
  881.  
  882. struct_declaration, union_declaration, enum_declaration
  883. -------------------------------------------------------
  884.  o keyword : 
  885.      a token among struct, union, enum
  886.  
  887.  o name : 
  888.      the corresponding identifier token
  889.  
  890.  o semi_colon : 
  891.      the semicolon token ending the declaration
  892.  
  893. Several verifications are performed at parse time :
  894.  . an incomplete struct or union declaration without a corresponding
  895.    struct or union definition in the same scope is stated as an error
  896.  . an enum declaration which does not correspond to a visible definition
  897.    is also stated as an error
  898.  
  899.  
  900. 5 - Instructions
  901. ----------------
  902.  
  903. All instructions have the common features :
  904.  
  905.  o scope : 
  906.      the scope of the current instruction. It may be
  907.      - function_body(FunctionName) where FunctionName is a string. 
  908.        This form occurs for a block instruction which is the body of the 
  909.        function FunctionName (see section 3.2)
  910.      - block : the block which the current instruction belongs to
  911.      - then_body : it is
  912.         
  913.          then_body
  914.          ---------
  915.           o instruction :
  916.               the 'if' instruction which executes the current instruction
  917.               when the expression in the condition is not zero
  918.  
  919.      - else_body : it is
  920.         
  921.          else_body
  922.          ---------
  923.           o instruction :
  924.               the 'if' instruction which executes the current instruction
  925.               when the expression in the condition is zero
  926.  
  927.      - labeled_instruction, case, default, switch, while, for, do_while :
  928.        the instruction which embodies the current one
  929.  
  930.  o next : 
  931.      the next instruction in the current block if any, 'nothing' otherwise
  932.  
  933.  o previous : 
  934.      the previous instruction in the current block if any, 'nothing' otherwise
  935.  
  936.  o first : 
  937.      the first instruction in the current block
  938.  
  939.  o last :
  940.      the last instruction in the current block
  941.  
  942. NOTE : a single instruction which is the body of a labeled instruction,
  943. ----   case, default, if, switch, while, for or do..while instruction has
  944.        no previous nor next instruction. In these cases the features previous
  945.        and next contain 'nothing' while the features first and last contain
  946.        the instruction itself.
  947.  
  948.  
  949. 5.1 Labeled instructions
  950. ------------------------
  951.  
  952. labeled_instruction
  953. -------------------
  954.  o label :
  955.      the identifier token corresponding to the instruction's label
  956.  
  957.  o colon :
  958.      the colon token separating the label and the instruction
  959.  
  960.  o body :
  961.      the labeled instruction
  962.  
  963.  
  964. case
  965. ----
  966.  o keyword ;
  967.      the token 'case'
  968.  
  969.  o condition :
  970.      the expression of the case statement
  971.  
  972.  o colon :
  973.      the colon token separating the condition and the instruction
  974.  
  975.  o body :
  976.      the corresponding instruction
  977.  
  978.  
  979. default
  980. -------
  981.  o keyword ;
  982.      the token 'default'
  983.  
  984.  o colon :
  985.      the colon token separating the keyword 'default' and the instruction
  986.  
  987.  o body :
  988.      the corresponding instruction
  989.  
  990.  
  991. 5.2 Compound instruction
  992. ------------------------
  993.  
  994. block
  995. -----
  996.  o left_brace :
  997.      the "{" token corresponding to the brace beginning the block
  998.  
  999.  o block_declarations :
  1000.      a 'block_declarations' structure corresponding to the local
  1001.      declarations and definitions made within the block (see section 4.2)
  1002.  
  1003.  o instructions :
  1004.      the list of instructions of the block (see section II for a description
  1005.      of the list data type)
  1006.  
  1007.  o right_brace :
  1008.      the "}" token corresponding to the brace ending the block
  1009.  
  1010.  
  1011. 5.3 Expression instruction
  1012. --------------------------
  1013.  
  1014. expression_instruction
  1015. ----------------------
  1016.  o expression :
  1017.      the corresponding expression (see section 6)
  1018.  
  1019.  o semi_colon :
  1020.      the semicolon token ending the instruction
  1021.  
  1022.  
  1023. 5.4 Selection instructions
  1024. --------------------------
  1025.  
  1026. if
  1027. --
  1028.  o keyword :
  1029.      the token 'if'
  1030.  
  1031.  o left_parenthesis :
  1032.      the token "(" beginning the condition
  1033.  
  1034.  o condition :
  1035.      the corresponding expression (see section 6)
  1036.  
  1037.  o right_parenthesis :
  1038.      then token ")" ending the condition
  1039.  
  1040.  o then_body :
  1041.      the corresponding instruction
  1042.  
  1043.  o else_keyword :
  1044.      the token 'else' if any, 'nothing' otherwise
  1045.  
  1046.  o else_body :
  1047.      the instruction corresponding to the 'else' case if any, 'nothing'
  1048.      otherwise
  1049.  
  1050.  
  1051. switch
  1052. ------
  1053.  o keyword :
  1054.      the token 'switch'
  1055.  
  1056.  o left_parenthesis :
  1057.      the token "(" beginning the condition
  1058.  
  1059.  o condition :
  1060.      the corresponding expression (see section 6)
  1061.  
  1062.  o right_parenthesis :
  1063.      then token ")" ending the condition
  1064.  
  1065.  o body :
  1066.     a block instruction containing a sequence of 'case' statements.
  1067.     There is currently no verification of the coherence of this block
  1068.     at parse time.
  1069.  
  1070.  
  1071. 5.5 Iteration instructions
  1072. --------------------------
  1073.  
  1074. while
  1075. -----
  1076.  o keyword :
  1077.      the token 'while'
  1078.  
  1079.  o left_parenthesis :
  1080.      the token "(" beginning the loop condition
  1081.  
  1082.  o condition :
  1083.      the corresponding expression (see section 6)
  1084.  
  1085.  o right_parenthesis :
  1086.      then token ")" ending the loop condition
  1087.  
  1088.  o body :
  1089.      the instruction corresponding to the body of the loop
  1090.  
  1091.  
  1092. do_while
  1093. --------
  1094.   o do_keyword :
  1095.      the token 'do'
  1096.  
  1097.  o body :
  1098.      the instruction corresponding to the body of the loop
  1099.  
  1100.  o while_keyword :
  1101.      the token 'while'
  1102.  
  1103.  o left_parenthesis :
  1104.      the token "(" beginning the loop condition
  1105.  
  1106.  o condition :
  1107.      the corresponding expression (see section 6)
  1108.  
  1109.  o right_parenthesis :
  1110.      then token ")" ending the loop condition
  1111.  
  1112.  o semi_colon :
  1113.      the semicolon token endin the instruction
  1114.  
  1115.  
  1116. for
  1117. ---
  1118.  o keyword :
  1119.      the token 'for'
  1120.  
  1121.  o left_parenthesis :
  1122.      the token "(" beginning the for 
  1123.  
  1124.  o initialization :
  1125.      the initialization expression of the loop if any (see section 6), 
  1126.      'nothing' otherwise
  1127.  
  1128.  o first_semi_colon :
  1129.      the semicolon token following the initialization
  1130.  
  1131.  o condition :
  1132.      the expression corresponding to the loop condition if any (see section 6),
  1133.      'nothing' otherwise
  1134.  
  1135.  o second_semi_colon :
  1136.      the semicolon token following the condition
  1137.  
  1138.  o step :
  1139.      the last expression of the 'for' statement if any (see section 6), 
  1140.      'nothing' otherwise
  1141.  
  1142.  o right_parenthesis :
  1143.      the token ")" ending the for
  1144.  
  1145.  o body :
  1146.      the instruction corresponding to the body of the loop
  1147.  
  1148.  
  1149. 5.6 Jump instructions
  1150. ---------------------
  1151.  
  1152. continue, break
  1153. ---------------
  1154.  o keyword :
  1155.      the corresponding keyword token
  1156.  
  1157.  o semi_colon :
  1158.      the semicolon token ending the instruction
  1159.  
  1160.  
  1161. goto
  1162. ----
  1163.  o keyword :
  1164.      the token 'goto'
  1165.  
  1166.  o label :
  1167.      the identifier token corresponding to the goto label
  1168.  
  1169.  o semi_colon :
  1170.      the semicolon token ending the instruction
  1171.  
  1172.  
  1173. return
  1174. ------
  1175.  o keyword :
  1176.      the token 'return'
  1177.  
  1178.  o value :
  1179.      the returned expression
  1180.  
  1181.  o semi_colon :
  1182.      the semicolon token ending the instruction
  1183.  
  1184.  
  1185. 5.7 Void instruction
  1186. --------------------
  1187.  
  1188. void_instruction
  1189. ----------------
  1190.  o semi_colon :
  1191.      the semicolon token in which this instruction consists
  1192.  
  1193.  
  1194. 6 - Expressions
  1195. ---------------
  1196.  
  1197. 6.1 Primary expressions
  1198. -----------------------
  1199.  
  1200. Primary expressions are the identifier, number, characters_string and 
  1201. character tokens. We must add to this list the parenthesized expressions 
  1202. which have the following structure :
  1203.  
  1204. protected_expression
  1205. --------------------
  1206.  o left_parenthesis :
  1207.      the token "("
  1208.  
  1209.  o expression :
  1210.      the parenthesized expression
  1211.  
  1212.  o right_parenthesis :
  1213.      the token ")"
  1214.  
  1215.  
  1216. All non primary expressions have the common features :
  1217.  
  1218.  o operator :
  1219.      an operator token corresponding to the expression's one if any,
  1220.      'nothing' otherwise
  1221.  
  1222.  o mode :
  1223.      it may be :
  1224.       - prefix
  1225.       - postfix
  1226.       - infix
  1227.       - special
  1228.      since the expression's operator is prefix, postfix, infix or has
  1229.      a special behaviour. When describing an operator we will systematically
  1230.      give its mode.
  1231.  
  1232.  
  1233. 6.2 Unary expressions
  1234. ---------------------
  1235.  
  1236. The root sort of unary expressions is the corresponding unary operator's 
  1237. symbol. They have one common feature :
  1238.  
  1239.  o expression :
  1240.      it contains the expression which is applied to the unary operator
  1241.  
  1242. The unary expressions are
  1243.  
  1244.  
  1245. Incrementation expression
  1246. -------------------------
  1247.  
  1248. The operator is '++' or '--'. Their mode feature contains 'prefix' or 
  1249. 'postfix', according to the position of the operator.
  1250.  
  1251.  
  1252. Unary arithmetic expression
  1253. ---------------------------
  1254.  
  1255. The operator is '+', '-' or '~' and the mode is 'prefix'.
  1256.  
  1257.  
  1258. Unary logical expression
  1259. ------------------------
  1260.  
  1261. The operator is '!' and the mode is 'prefix'.
  1262.  
  1263.  
  1264. Pointer reference
  1265. -----------------
  1266.  
  1267. The operator is '*' and the mode is 'prefix'.
  1268.  
  1269.  
  1270. Address value
  1271. -------------
  1272.  
  1273. The operator is '&' and the mode is 'prefix'.
  1274.  
  1275.  
  1276. Size of expression
  1277. ------------------
  1278.  
  1279. The operator is 'sizeof' and the mode is 'prefix'.
  1280.  
  1281.  
  1282. 6.3 Binary expressions
  1283. ----------------------
  1284.  
  1285. The root sort of binary expressions is the corresponding binary operator's 
  1286. symbol.
  1287.  
  1288. The binary expressions are
  1289.  
  1290.  
  1291. Regular binary expressions
  1292. --------------------------
  1293.  
  1294. Their mode is always 'infix'. They have two common features :
  1295.  
  1296.  o left_expression :
  1297.      it contains the expression on the left side of the operator
  1298.  
  1299.  o right_expression :
  1300.      it contains the expression on the right side of the operator
  1301.  
  1302. The operator is one of : '+', '-', '*', '/', '<', '>', '|', '%', '^', '<<', 
  1303.                          '>>', '=', '+=', '-=', '*=', '/=', '%=', '&=', '^=', 
  1304.                          '|=', '<<=', '>>=', '!=', '.', '->', ','
  1305.  
  1306. The array reference is a binary expression, but it has a particular
  1307. representation since its operator is discontinuous  : [ ... ]
  1308.  
  1309.  
  1310. array_reference
  1311. ---------------
  1312.  o array :
  1313.      the expression corresponding to the array
  1314.  
  1315.  o mode :
  1316.      'special'
  1317.  
  1318.  o operator :
  1319.      'nothing'
  1320.  
  1321.  o left_bracket :
  1322.      the token "[" preceding the element's index in the array
  1323.  
  1324.  o index :
  1325.      the expression corresponding to the element's index in the array
  1326.  
  1327.  o right_bracket :
  1328.      the token "[" following the element's index in the array
  1329.  
  1330.  
  1331. 6.4 Conditional expression
  1332. --------------------------
  1333.  
  1334. The root sort of this expression is '?'. The feature mode contains 'special'
  1335. and the feature operator the token of the corresponding question mark.
  1336. Its features are :
  1337.  
  1338.  o condition :
  1339.      the expression corresponding to the test
  1340.  
  1341.  o then :
  1342.      the resulting expression if condition evaluates to non zero value
  1343.  
  1344.  o colon :
  1345.      the colon token of the expression
  1346.  
  1347.  o else :
  1348.      the resulting expression if condition evaluates to zero
  1349.  
  1350.  
  1351. 6.5 Function call
  1352. -----------------
  1353.  
  1354. function_call
  1355. -------------
  1356.  o call :
  1357.      the expression corresponding to the function being called
  1358.  
  1359.  o left_parenthesis :
  1360.      the token "(" beginning the arguments list
  1361.  
  1362.  o arguments :
  1363.      the arguments of the call. It is
  1364.  
  1365.      arguments
  1366.      ---------
  1367.       o arguments_number :
  1368.           the number of arguments
  1369.  
  1370.       o 1 .. arguments_number :
  1371.           the arguments (if arguments_number is not 0). Each feature
  1372.           contains an expression. All arguments have the common features :
  1373.           
  1374.            o previous : 
  1375.                the previous argument
  1376.  
  1377.            o next : 
  1378.                the next argument
  1379.  
  1380.            o first : 
  1381.                the first argument
  1382.  
  1383.            o last :
  1384.                the last argument
  1385.  
  1386.  o right_parenthesis :
  1387.      the token "(" ending the arguments list
  1388.  
  1389.  
  1390. 6.6 Cast expression
  1391. -------------------
  1392.  
  1393. cast
  1394. ----
  1395.  o left_parenthesis :
  1396.      the token "(" at the beginning of the type specification
  1397.  
  1398.  o type :
  1399.      the cast type (see section 2)
  1400.  
  1401.  o right_parenthesis :
  1402.      the token ")" at the end of the type specification
  1403.  
  1404.  o expression :
  1405.      the cast expression
  1406.  
  1407.  
  1408. 6.7 Initialization expressions
  1409. ------------------------------
  1410.  
  1411. They are expressions which set the initial value of an identifier within
  1412. its declaration.
  1413.  
  1414.  
  1415. setting
  1416. -------
  1417.  o keyword :
  1418.      a token ":" (for the size of a tag) or a token "=" for the classical 
  1419.      initialization of an identifier in its declaration.
  1420.  
  1421.  o setting :
  1422.      the initalization expression. It's either a constant expression
  1423.      either a complex initialization (e.g. the initialization of the elements
  1424.      of an array). In the latter case the expression is
  1425.  
  1426.      complex_initialization
  1427.      ----------------------
  1428.       o left_brace :
  1429.           the token "{" beginning the initialization
  1430.  
  1431.       o body :
  1432.           the initialization expression (a constant expression or a
  1433.           sequence of expressions with perhaps complex initializations inside)
  1434.  
  1435.       o right_brace :
  1436.           the token "}" ending the initialization
  1437.  
  1438.  
  1439.  
  1440.  
  1441. II. Building analyzers
  1442. ======================
  1443.  
  1444. 1 - Principles
  1445. --------------
  1446.  
  1447. A shell script named 'slc' is provided with the SuperLint package. It
  1448. automatically calls the rules compiler and produces an analyzer from
  1449. one or several files containing the analyzer's specification.
  1450.  
  1451. After creating an analyzer from a rules file, you can run the analyzer
  1452. on C files using the 'sl' shell script. See the README file in the
  1453. SuperLint package for complete information concerning the use of sl and
  1454. slc.
  1455.  
  1456.  
  1457. 2 - Description of the rules specification language
  1458. ---------------------------------------------------
  1459.  
  1460. 2.1 Analyzer's design
  1461. ---------------------
  1462.  
  1463. An analyzer's specification consists of one or several files which may contain
  1464. verification rules, functions or procedures written in the C-like language
  1465. as well as pure LIFE code.
  1466. The entry point of the analyzer is a procedure (see section 2.4) called
  1467. 'main' which is invoked when the analyzer is launched with 'sl'. The parse
  1468. of the C files specified on the command line is automatically effected and
  1469. the result stored in the global variable named 'syntactic_tree' which
  1470. contains a 'toplevel' structure (see section 4.1).
  1471. When the procedure 'main' is absent, SuperLint launches an automatic
  1472. verification of all the rules of the analyzer's specification. But if you 
  1473. write your own main procedure you have to handle by yourself all the 
  1474. verification operations.
  1475.  
  1476.  
  1477. 2.2 Structures and aliases
  1478. --------------------------
  1479.  
  1480. A structure is designed by an alphanumerical name always beginning by
  1481. a lower case letter. You don't need to declare structures like in C since 
  1482. they don't have predefined fields, i.e. you can add as many features
  1483. to your structure as you want. You access the features of a structure with
  1484. the '.' operator, just like in C. When you try to get the value of a
  1485. nonexisting feature an error occurs.
  1486. You add a new feature to a structure with the 'set_feature' procedure.
  1487. This assignment is destructive, in the sense that if you set a preexisting
  1488. feature with 'set_feature', the previous value of the feature is lost.
  1489. Note that a structure ought not to have any feature. In the following we
  1490. will name identifiers such featureless structures.
  1491.  
  1492. The basic way to pass arguments or to denote particular structures in
  1493. SuperLint is to use aliases. An alias is an alphanumerical name beginning
  1494. by an uppercase letter or an underscore. You don't need to declare aliases.
  1495. You set an alias value using the '=' operator. Once declared an alias cannot
  1496. be reassigned. The scope of an alias is the rule/procedure/function in which
  1497. it is declared. It is destroyed when exiting the scope.
  1498. An alias is much like a local variable in C, but with restrictions in the way
  1499. is is assigned.
  1500.  
  1501. Example :
  1502.  
  1503.      MyStructure = my_structure,
  1504.      set_feature(name, "Mr. Struct", MyStructure),
  1505.      set_feature(foo, bar, MyStructure),
  1506.      X = MyStructure.foo,
  1507.      set_feature(foo, nothing, MyStructure)
  1508.  
  1509. These operations declare that the alias MyStructure designs the structure
  1510. 'my_structure', which has two features : name and foo with the initial
  1511. values "Mr. Struct" and 'bar'. X is an alias for the feature foo of
  1512. MyStructure. At this moment the value of X is 'bar'. But after the destrcutive
  1513. reassignment : 'set_feature(foo, nothing, MyStructure)' the value of X is
  1514. 'nothing'. The alias X doesn't design the structure 'bar' but the feature
  1515. foo of MyStructure independently of its content.
  1516.  
  1517.  
  1518. Note for the purpose of the LIFE programmer :
  1519. ---------------------------------------------
  1520.  
  1521. Structures are actually psi-terms and aliases logical variables. The 
  1522. 'set_feature' operation is the non-backtrackable assignment '<<-'. 
  1523. It's not dangerous to use it for all the syntactic structures produced by 
  1524. the parser are persistent.
  1525. It will not cause any problem as long as the user who programs with the C-like
  1526. language, programs *effectively* like in C and doesn't mix both imperative and
  1527. declarative styles.
  1528.  
  1529.  
  1530. 2.3 Rules
  1531. ---------
  1532.  
  1533. A rule is a specific procedure which is called for each node during the 
  1534. automatic scanning of the syntactic tree.
  1535.  
  1536. A rule specification has the following form :
  1537.  
  1538. [ rule ] <RULE NAME> (<NODE NAME>, <DOMAIN NAME>) :->
  1539. {
  1540.   entry_test(<ENTRY TEST>),
  1541.   <RULE BODY>
  1542. }.
  1543.  
  1544.  o <RULE NAME> is an identifier. Two different rules cannot have the same
  1545.    name
  1546.  
  1547.  o <NODE NAME> is an alias designing the syntactic node currently scanned
  1548.  
  1549.  o <DOMAIN NAME> is an identifier designing a set of rules. This can
  1550.    be useful when using libraries of rules since it's possible to tell 
  1551.    SuperLint to perform verifications only for particular rules sets.
  1552.    See section 3 for further details.
  1553.  
  1554.  o <ENTRY TEST> is a logical expression selecting the nodes to which the
  1555.    rule must apply. If the expression is true the rule's body is executed
  1556.    else the verification process continues with another rule or another node.
  1557.    See section 2.6 for further details on logical expressions.
  1558.  
  1559.  o <RULE BODY> is a sequence of instructions constituting the body of the
  1560.    rule. See section 2.5 for further details on instructions.
  1561.  
  1562. NOTE : the keyword 'rule' before the rule's name is optional.
  1563. ----
  1564.  
  1565.  
  1566. 2.4 Procedures and functions
  1567. ----------------------------
  1568.  
  1569. Procedures and functions behave much like in C. Their syntax is :
  1570.  
  1571. procedure <PROCEDURE NAME> (<PARAMETER 1>, ..., <PARAMETER N>) :->
  1572. {
  1573.   <PROCEDURE BODY>
  1574. }.
  1575.  
  1576.  o <PROCEDURE NAME> is an identifier.
  1577.  
  1578.  o <PARAMETER 1>, ..., <PARAMETER N> are aliases designing the parameters
  1579.    of the procedure.
  1580.  
  1581.  o <PROCEDURE BODY> is a sequence of instructions constituting the body of 
  1582.    the procedure. See section 2.5 for further details on instructions.
  1583.  
  1584.  
  1585. function <FUNCTION NAME> (<ARGUMENT 1>, ..., <ARGUMENT N>) :->
  1586. {
  1587.   <FUNCTION BODY>
  1588. }.
  1589.  
  1590.  o <FUNCTION NAME> is an identifier.
  1591.  
  1592.  o <ARGUMENT 1>, ..., <ARGUMENT N> are aliases designing the arguments
  1593.    of the procedure.
  1594.  
  1595.  o <FUNCTION BODY> is a sequence of instructions constituting the body of 
  1596.    the function. If you forget to specify a return value for the function,
  1597.    the identifier 'unknown' is returned. See section 2.5 for further details
  1598.    on instructions.
  1599.  
  1600. NOTE : If you call a function or a procedure with aliases which have not
  1601. ----   been previously set you are in deep trouble. Currently there is no
  1602.        runtime verification insuring that all the arguments of a procedure
  1603.        or function call are defined.
  1604.  
  1605.  
  1606. Note for the purpose of the LIFE programmer :
  1607. ---------------------------------------------
  1608.  
  1609. Functions are actually translated into LIFE functions and procedures into 
  1610. predicates.
  1611.  
  1612.  
  1613. 2.5 Instructions
  1614. ----------------
  1615.  
  1616. An instruction may be :
  1617.  
  1618.  o A block instruction : { ... }
  1619.    It contains a sequence of instructions, two instructions being separated
  1620.    by a comma.
  1621.   
  1622.    Example :
  1623.  
  1624.      {
  1625.        X = f(1, name),
  1626.        Y1 = X.field1,
  1627.        Y2 = X.field2,
  1628.        p(Y1.foo, Y2)
  1629.      }
  1630.  
  1631.    WARNING : Aliases defined within a block are NOT local to this block.
  1632.    -------   Remember that the scope of an alias is the rule/function/procedure
  1633.              in which it appears.
  1634.  
  1635.  o An alias definition (see section 2.2) :
  1636.  
  1637.      <ALIAS NAME> = <EXPRESSION>
  1638.  
  1639.    See section 2.6 for further details on expressions.
  1640.  
  1641.  o A procedure call :
  1642.   
  1643.      <PROCEDURE NAME> (<PARAMETER 1>, ..., <PARAMETER N>)
  1644.  
  1645.    where <PARAMETER 1>, ..., <PARAMETER N> are expressions.
  1646.  
  1647.  o A 'donothing' instruction which does nothing.
  1648.  
  1649.  o A 'return' statement :
  1650.  
  1651.      return <EXPRESSION>
  1652.  
  1653.    where <EXPRESSION> is an expression.
  1654.    It can only occur in a function body for it is intended to specify the
  1655.    return value of the function.
  1656.  
  1657.    WARNING : Unlike in C the function doesn't return after the 'return' has 
  1658.    -------   been executed. If there are other instructions following the 
  1659.              'return' instruction they are executed in turn.
  1660.  
  1661.  o An 'if' statement :
  1662.  
  1663.      if(<CONDITION>) then
  1664.        <FIRST CASE>
  1665.      [ else
  1666.         <SECOND CASE> ]
  1667.  
  1668.    where <CONDITION> is a logical expression an <FIRST CASE> and <SECOND CASE>
  1669.    are instructions.
  1670.  
  1671.    When <CONDITION> is true <FIRST CASE> is executed, <SECOND CASE> otherwise.
  1672.    The <SECOND CASE> specification is optional.
  1673.  
  1674.    WARNING : Because of the method used to parse LIFE (operator's precedence)
  1675.    -------   it is difficult to parse correctly nested if...then...else 
  1676.              statements. Currently if one of the <FIRST CASE> or <SECOND CASE>
  1677.              instructions needs to be an if statement, it MUST be protected
  1678.              in a block instruction.
  1679.  
  1680.              Example :
  1681.   
  1682.                if(...) then {
  1683.                  if(...) then
  1684.                    ...
  1685.                } else {
  1686.                  if (...) then
  1687.                    ...
  1688.                  else
  1689.                    ...
  1690.                }
  1691.  
  1692.              Moreover the symbol 'if' being defined as an operator of the
  1693.              SuperLint rules language, you must put in between parentheses
  1694.              if you want to use it as an identifier (when handling an 'if'
  1695.              syntactic node produced by the parser, for example). Otherwise
  1696.              it will be parsed incorrectly by Wild_LIFE.
  1697.              This remark remains true for the 'return' symbol.
  1698.  
  1699.  o A 'switch' statement :
  1700.  
  1701.      switch(<EXPRESSION>) {
  1702.        case(<CASE 1>, <INSTRUCTION 1>),
  1703.           .
  1704.           .
  1705.           .
  1706.        case(<CASE N>, <INSTRUCTION N>) [,
  1707.        default(<DEFAULT INSTRUCTION>) ]
  1708.      }
  1709.    
  1710.    where <EXPRESSION> is an expression and <INSTRUCTION 1> ... <INSTRUCTION N>
  1711.    and <DEFAULT INSTRUCTION> are instructions.
  1712.    The <CASE 1> .. <CASE N> are either expressions or multiple choice cases,
  1713.    namely :
  1714.  
  1715.      { <EXPRESSION 1>, ..., <EXPRESSION M> }
  1716.  
  1717.    where <EXPRESSION 1>, ..., <EXPRESSION M> ar expressions.
  1718.  
  1719.    When executing this instruction <EXPRESSION> is first evaluated and
  1720.    its value V compared with each case.
  1721.    If i is the least integer in 1..N such that V is equal to the value of 
  1722.    <CASE i>, if this one is an expression, or V is equal to the value of one 
  1723.    of the <EXPRESSION j>, if <CASE i> is a multiple choice case, then 
  1724.    <INSTRUCTION i> is executed and the execution of the 'switch' is over.
  1725.    If there is a 'default' case, the <DEFAULT INSTRUCTION>  is executed when
  1726.    the i defined above doesn't exist.
  1727.  
  1728.  
  1729. 2.6 Expressions
  1730. ---------------
  1731.  
  1732. 2.6.1 Standard expressions
  1733. --------------------------
  1734.  
  1735. A standard expression may be
  1736.  
  1737.  o a structure with or without features
  1738.  
  1739.  o a number
  1740.  
  1741.  o a boolean value : true or false
  1742.  
  1743.  o a string
  1744.  
  1745.  o a function call. Note that any LIFE function may be used in a function
  1746.    call. Therefore we encourage you to search in the Wild_LIFE manual for
  1747.    the built-in function that you may need.
  1748.  
  1749.  o a feature access with the '.' operator
  1750.  
  1751.    Example :
  1752.  
  1753.      MyStruct.the_feature
  1754.      X.tree.node.label
  1755.  
  1756.  o an arithmetical expression with operators : '+', '*', '-', '/', '^'
  1757.  
  1758.  o a boolean expression with operators : 'or', 'and', 'not' or a comparison
  1759.    expression.
  1760.  
  1761.    A comparison expression is a binary expression whose operator may be
  1762.    '==', '<>', '<', '=<', '>' or '>=' and whose operands are standard
  1763.    expressions.
  1764.    The '==' operator is the same as in C, except that it can be used with
  1765.    structures. For example :
  1766.  
  1767.      X == foo
  1768.  
  1769.    evaluates to 'true' iff X designs a structure named foo, independently
  1770.    from its features.
  1771.    The '<>' operator is the negative form of the precedent. It's much like
  1772.    the '!=' operator in C.
  1773.  
  1774.  
  1775. 2.6.2 Logical expressions
  1776. -------------------------
  1777.  
  1778. A logical expression is an expression occuring only in an 'entry_test' or 'if'
  1779. statement. A logical expression may be :
  1780.  
  1781.  o a boolean expression
  1782.  
  1783.  o a binary expression with operators '&&' or '||'
  1784.    They have the same meaning as the corresponding ones in C.
  1785.    BUT you cannot use them in a boolean expression. The major difference
  1786.    comes from the evaluation's order. These operators evaluate from left to
  1787.    right. The boolean operators 'and' and 'or' have no insured evaluation's
  1788.    order.
  1789.  
  1790.  
  1791. 3 - The toolkit
  1792. ---------------
  1793.  
  1794. SuperLint comes with several built-in structures, functions and procedures.
  1795.  
  1796.  o Lists
  1797.    -----
  1798.    A list may be given by :
  1799.  
  1800.     o [] : the empty list with no elements
  1801.  
  1802.     o newlist(E, L) : where E is a structure and L a list (it's the lists
  1803.       constructor function)
  1804.  
  1805.    A non empty list has two features :
  1806.  
  1807.     o first_element : the first element in the list (corresponding to the
  1808.       structure designed by E above)
  1809.  
  1810.     o tail : the list except its first element (corresponding to the
  1811.       list designed by L above)
  1812.  
  1813.    A list may be specified extensively by giving all its elements
  1814.  
  1815.    Example :
  1816.  
  1817.      L = [1, 2, 3],
  1818.      E = L.tail.first_element,
  1819.      L2 = newlist("hello", L)
  1820.      
  1821.  
  1822.    In this example the value of E is 2 and the value of L2 is 
  1823.    ["hello", 1, 2, 3].
  1824.  
  1825.  
  1826.  o features_list(What)
  1827.    -------------------
  1828.    Function returning the list of features of the structure designed by
  1829.    'What' if any, [] otherwise.
  1830.  
  1831.  
  1832.  o has_feature(Feature, What)
  1833.    --------------------------
  1834.    Tells if the structure designed by 'What' has the feature designed by
  1835.    'Feature'.
  1836.    May only be used in a logical expression.
  1837.  
  1838.  
  1839.  o syntactic_tree
  1840.    --------------
  1841.    This function returns the 'toplevel' structure of the syntactic tree.
  1842.  
  1843.    Note for the purpose of the LIFE programmer :
  1844.    ---------------------------------------------
  1845.    Actually it's not a function but a persistent variable. This information
  1846.    is however meaningless for the user of the C-like language.
  1847.  
  1848.  
  1849.  o parse_tree(Operation, Node)
  1850.    ---------------------------
  1851.    This procedure scans the syntactic tree from the node 'Node' applying
  1852.    to each of its subtrees the operation 'Operation' which must be a procedure
  1853.    with one parameter.
  1854.    In fact the procedure 'Operation' is applied twice on the node :
  1855.  
  1856.     o when the node is encountered for the first time
  1857.  
  1858.     o when the operation has been applied to all the subtrees of the node
  1859.  
  1860.    To distinguish these two cases the function 'parse_mode' is provided.
  1861.    In the first case it returns 'prefix', in the second case it returns
  1862.    'postfix'.
  1863.  
  1864.    Three other functions are provided :
  1865.   
  1866.     o current_declaration : the declaration whose subtrees are currently
  1867.       explored, 'nothing' otherwise (see section 4, part I).
  1868.  
  1869.     o current_block : the block whose subtrees are currently explored,
  1870.       'nothing' otherwise (see section 5, part I).
  1871.  
  1872.     o current_instruction : the instruction whose subtrees are currently 
  1873.       explored, 'nothing' otherwise (see section 5, part I).
  1874.  
  1875.  
  1876.  o scan_tree [ ({ <DOMAIN 1>, ..., <DOMAIN N> }) ]
  1877.    -----------------------------------------------
  1878.    This operation launches the scanning of the syntactic tree from the
  1879.    'toplevel' node, applying the rules whose domain is one of :
  1880.    <DOMAIN 1>, ..., <DOMAIN N>.
  1881.    If no domain name is specified all the rules are applied : it's the
  1882.    default behaviour of an analyzer.
  1883.    This procedure uses 'parse_tree', therefore all the associated functions
  1884.    are available.
  1885.  
  1886.    
  1887.  o error_msg(Message [, Token])
  1888.    ----------------------------
  1889.    This procedure writes the error message 'Message', giving informations 
  1890.    about file and line from the token 'Token' (see section 1, part I).
  1891.    The second argument is optional.
  1892.    This procedure can only be called in a rule or in a function/procedure
  1893.    which is accessed from a rule.
  1894.    The name of the rule in which this procedure is called is also displayed.
  1895.    You can retrieve this option by adding the directive :
  1896.  
  1897.      display_rules(no).
  1898.  
  1899.    in one of your rules files.
  1900.  
  1901.  
  1902.  o is_token(What), is_not_token(What)
  1903.    ----------------------------------
  1904.    Tells whether the structure designed by 'What' is a token or not.
  1905.    May only be used in a logical expression.
  1906.  
  1907.  
  1908.  o is_operator(What)
  1909.    -----------------
  1910.    Tells if 'What' designed by 'What' is an operator or not, i.e. an 
  1911.    expression (see section 6, part I).
  1912.    May only be used in a logical expression.
  1913.  
  1914.  
  1915.  o is_assignment_operator, is_logical_operator, is_arithmetic_operator, 
  1916.    is_relation_operator, is_conditional_operator, is_unary_operator, 
  1917.    is_struct_reference, is_assignment :
  1918.    
  1919.    Like the previous one, but for specific expressions (see section 6, part I).
  1920.    They may only be used in a logical expression.
  1921.  
  1922.  
  1923.  o expand_type(Type)
  1924.    -----------------
  1925.    This function returns the expanded form of the type structure designed
  1926.    by 'Type' (see section 3, part I), i.e. the equivalent type where all
  1927.    the type names defined in a typedef statement have been recursively 
  1928.    replaced by their equivalent type.
  1929.  
  1930.  
  1931.  o basename(FilePath)
  1932.    ------------------
  1933.    'FilePath' designing an absolute UNIX path of a file, this function
  1934.    returns the single file name.
  1935.  
  1936.  
  1937.  o file_extension(FilePath)
  1938.    ------------------------
  1939.    'FilePath' designing an absolute UNIX path of a file, this function
  1940.    returns the extension of the file name if any, the empty string ""
  1941.    otherwise.
  1942.  
  1943.  
  1944.  o writeln
  1945.    -------
  1946.    This procedure writes all its arguments in the standard output, the last
  1947.    being followed by a newline.
  1948.  
  1949.  
  1950.  o string2id(Identifier)
  1951.    ---------------------
  1952.    This function transforms the string 'Identifier' into an identifier of
  1953.    same name. This function is useful when handling structures names which
  1954.    cannot be literally written because they would cause problems to the
  1955.    LIFE parser (e.g. '!', '(', ...etc).
  1956.    You should always use this function when using non alphanumerical structures
  1957.    names like the tokens or expressions nodes (see section 1 and 6, part I).
  1958.