home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 February / PCWorld_2000-02_cd.bin / Software / TemaCD / SuperIDE / Super.exe / _SETUP.1 / IniFiles.lng < prev    next >
Text File  |  1998-03-01  |  6KB  |  177 lines

  1. /*
  2.  * TSyntaxMemoParser Script
  3.  *
  4.  * Target language environment:    .INI files
  5.  * Author                     :    David Brock   dbrock@cqm.co.uk
  6.  * Date                       :    Nov 16 1997
  7.  */
  8.  
  9.  
  10.  
  11.  
  12.  
  13. /*
  14.  * Define language 'furniture' as low-order token
  15.  * values, this way 'keywords' can be added later
  16.  * starting at a higher value.
  17.  */
  18. #define it_DEFAULT                   0
  19. #define it_SECTIONSTART              1
  20. #define it_SECTIONNAME               2
  21. #define it_KEYNAME                   3
  22. #define it_VALUE                     4
  23. #define it_EQUAL                     5
  24. #define it_COMMENT                   6
  25. #define it_BRACE                     7
  26. #define it_TEXT                      8
  27.  
  28. /*
  29.  * Standard stuff
  30.  */
  31. #define _non_alpha_                  '[^_A-Za-z0-9]'
  32. #define _all_chars_                  '[\x00-\xFF]'
  33. #define _no_chars_                   '[]'
  34. #define _dont_care_                  _all_chars_
  35. #define _DEFAULT_BACKGROUND          clWhite
  36. #define _DEFAULT_FOREGROUND          clBlack
  37. /*
  38.  * States used as below:
  39.  *
  40.  *  ss_START        Default entry state
  41.  *  ss_INSECTION    Between '[' and ']'
  42.  */
  43. #define ss_START                     0
  44. #define ss_InSECTION                 1
  45. #define ss_EQUAL                     2
  46. #define ss_TEXT                      3
  47.  
  48. %%language
  49. Name                                 = 'INIfiles'
  50. Case                                 = __INSENSITIVE
  51. Options                              = __DEFAULT_OPTIONS
  52. WordWrapColumn                       = _EDGE
  53. Gutter                               = _DEFAULT_GUTTER
  54. ExampleText                          = '[Section]\n\
  55.                                        \KeyName=Value\n'
  56. EditableStyles                         ('Section',      it_SECTIONSTART),
  57.                                        ('Section name', it_SECTIONNAME),
  58.                                        ('KeyName',      it_KEYNAME),
  59.                                        ('Value',        it_VALUE),
  60.                                        ('Equal',        it_EQUAL)
  61.  
  62. %%words
  63. //
  64. // Section names start with '[' at beginning of line
  65. //
  66. '\['       _dont_care_                 it_SECTIONSTART        [ss_START]
  67. '\n\['     _dont_care_                 it_SECTIONSTART        [ss_START]
  68. '{'        _dont_care_                 it_BRACE               [ss_TEXT]
  69. '}'        _dont_care_                 it_BRACE               [ss_TEXT]
  70. '@'        _dont_care_                 it_BRACE               [ss_TEXT]
  71.  
  72. //
  73. // Properties are indicated by '=' within the line
  74. //
  75. '='        _dont_care_                 it_VALUE               [ss_START]
  76. '='        _dont_care_                 it_EQUAL               [ss_EQUAL]
  77. '\n'       _dont_care_                 it_KEYNAME             [ss_START]
  78. '\n;'      _dont_care_                 it_COMMENT             [ss_START]
  79.  
  80. /*
  81.  * Handlers...
  82.  *
  83.  *   '['......Everything up to next ']' or end of line
  84.  *   '='......Everything up to end of line
  85.  */
  86. %%handler
  87. it_SECTIONSTART    _all_chars_?                '[\]\n]'       _use_
  88. it_VALUE           '[^\n\xFF]'?                '[\n\xFF]'     _discard_
  89. it_COMMENT         _all_chars_?                '\n'           _discard_
  90. it_KEYNAME         Match(1)
  91.  
  92. /*
  93.  * Tokens...
  94.  *
  95.  * Keyname...
  96.  */
  97. %%tokens
  98. it_SECTIONNAME     '[^\[\n]'      '[^\]\n]'    '[\]\n]'      _discard_     [ss_INSECTION]
  99.  
  100. %%effects
  101. it_DEFAULT         [fsbold]                    clGreen             _DEFAULT_BACKGROUND
  102. it_SECTIONSTART    [fsBold]                    clNavy              _DEFAULT_BACKGROUND
  103. it_EQUAL           [fsBold]                    clgreen             _DEFAULT_BACKGROUND
  104. it_KEYNAME         [fsBold]                    clMaroon            _DEFAULT_BACKGROUND   'hotspot'
  105. it_VALUE           []                          clNavy              _DEFAULT_BACKGROUND
  106. it_COMMENT         []                          clgray              _DEFAULT_BACKGROUND
  107. it_SECTIONNAME     [fsBold]                    clBlue              _DEFAULT_BACKGROUND
  108. it_BRACE           [fsBold]                    clRed               _DEFAULT_BACKGROUND
  109.  
  110. %%map
  111. it_DEFAULT         it_DEFAULT
  112. it_SECTIONSTART    it_SECTIONSTART
  113. it_KEYNAME         it_KEYNAME
  114. it_VALUE           it_VALUE
  115. it_EQUAL           it_EQUAL
  116. it_SECTIONNAME     it_SECTIONNAME
  117. it_COMMENT         it_COMMENT
  118. it_BRACE           it_BRACE
  119. it_TEXT            it_DEFAULT
  120.  
  121. %%containers
  122. it_SECTIONSTART    (+[ss_INSECTION] -[ss_START])
  123. it_VALUE           (+[ss_EQUAL]     -[ss_START])
  124.  
  125. %%states
  126. it_TEXT            (+[ss_TEXT])
  127. it_SECTIONSTART    (-[ss_TEXT])
  128. it_KEYNAME         (-[ss_TEXT])
  129. it_COMMENT         (-[ss_TEXT])
  130. it_EQUAL           (-[ss_TEXT])
  131. it_VALUE           (-[ss_TEXT])
  132.  
  133. /*
  134.    The above script uses Match(1) to identify non-key/value pair lines.
  135.    This requires code attached to the OnCustomParse event handler.
  136.    Paste the following code into the event handler:
  137. var orgKL,
  138.     sPos   : longint;
  139. begin
  140.   //
  141.   // INI parser support functions...
  142.   //
  143.   result := true;
  144.   sPos   := IStream.yypos;
  145.   orgKL  := klength;
  146.   case ParseID of
  147.     1  :   //
  148.            // Newline (without recognised follower)
  149.            //
  150.            // Scan until one of the following is located:
  151.            //    \n      ------    Return entire line as default
  152.            //    =       ------    Return as key name
  153.            //
  154.            with IStream do begin
  155.              while (not yyeof) and (not (yychar in [#13, '='])) do begin
  156.                yyadvance;
  157.                inc(kLength);
  158.               end;
  159.              if yyeof
  160.               then kValue := 0 else
  161.              case yychar of
  162.                #13       : if kLength > 1
  163.                             then begin
  164.                                kValue  := 8;
  165.                                kLength := orgKL;
  166.                                yypos   := sPos;
  167.                              end
  168.                             else kValue := 0;
  169.                '='       : kValue := 3; // Key token value
  170.              end;
  171.            end;
  172.   end;
  173. end;
  174.  
  175. */
  176.  
  177.