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 >
Wrap
Text File
|
1998-03-01
|
6KB
|
177 lines
/*
* TSyntaxMemoParser Script
*
* Target language environment: .INI files
* Author : David Brock dbrock@cqm.co.uk
* Date : Nov 16 1997
*/
/*
* Define language 'furniture' as low-order token
* values, this way 'keywords' can be added later
* starting at a higher value.
*/
#define it_DEFAULT 0
#define it_SECTIONSTART 1
#define it_SECTIONNAME 2
#define it_KEYNAME 3
#define it_VALUE 4
#define it_EQUAL 5
#define it_COMMENT 6
#define it_BRACE 7
#define it_TEXT 8
/*
* Standard stuff
*/
#define _non_alpha_ '[^_A-Za-z0-9]'
#define _all_chars_ '[\x00-\xFF]'
#define _no_chars_ '[]'
#define _dont_care_ _all_chars_
#define _DEFAULT_BACKGROUND clWhite
#define _DEFAULT_FOREGROUND clBlack
/*
* States used as below:
*
* ss_START Default entry state
* ss_INSECTION Between '[' and ']'
*/
#define ss_START 0
#define ss_InSECTION 1
#define ss_EQUAL 2
#define ss_TEXT 3
%%language
Name = 'INIfiles'
Case = __INSENSITIVE
Options = __DEFAULT_OPTIONS
WordWrapColumn = _EDGE
Gutter = _DEFAULT_GUTTER
ExampleText = '[Section]\n\
\KeyName=Value\n'
EditableStyles ('Section', it_SECTIONSTART),
('Section name', it_SECTIONNAME),
('KeyName', it_KEYNAME),
('Value', it_VALUE),
('Equal', it_EQUAL)
%%words
//
// Section names start with '[' at beginning of line
//
'\[' _dont_care_ it_SECTIONSTART [ss_START]
'\n\[' _dont_care_ it_SECTIONSTART [ss_START]
'{' _dont_care_ it_BRACE [ss_TEXT]
'}' _dont_care_ it_BRACE [ss_TEXT]
'@' _dont_care_ it_BRACE [ss_TEXT]
//
// Properties are indicated by '=' within the line
//
'=' _dont_care_ it_VALUE [ss_START]
'=' _dont_care_ it_EQUAL [ss_EQUAL]
'\n' _dont_care_ it_KEYNAME [ss_START]
'\n;' _dont_care_ it_COMMENT [ss_START]
/*
* Handlers...
*
* '['......Everything up to next ']' or end of line
* '='......Everything up to end of line
*/
%%handler
it_SECTIONSTART _all_chars_? '[\]\n]' _use_
it_VALUE '[^\n\xFF]'? '[\n\xFF]' _discard_
it_COMMENT _all_chars_? '\n' _discard_
it_KEYNAME Match(1)
/*
* Tokens...
*
* Keyname...
*/
%%tokens
it_SECTIONNAME '[^\[\n]' '[^\]\n]' '[\]\n]' _discard_ [ss_INSECTION]
%%effects
it_DEFAULT [fsbold] clGreen _DEFAULT_BACKGROUND
it_SECTIONSTART [fsBold] clNavy _DEFAULT_BACKGROUND
it_EQUAL [fsBold] clgreen _DEFAULT_BACKGROUND
it_KEYNAME [fsBold] clMaroon _DEFAULT_BACKGROUND 'hotspot'
it_VALUE [] clNavy _DEFAULT_BACKGROUND
it_COMMENT [] clgray _DEFAULT_BACKGROUND
it_SECTIONNAME [fsBold] clBlue _DEFAULT_BACKGROUND
it_BRACE [fsBold] clRed _DEFAULT_BACKGROUND
%%map
it_DEFAULT it_DEFAULT
it_SECTIONSTART it_SECTIONSTART
it_KEYNAME it_KEYNAME
it_VALUE it_VALUE
it_EQUAL it_EQUAL
it_SECTIONNAME it_SECTIONNAME
it_COMMENT it_COMMENT
it_BRACE it_BRACE
it_TEXT it_DEFAULT
%%containers
it_SECTIONSTART (+[ss_INSECTION] -[ss_START])
it_VALUE (+[ss_EQUAL] -[ss_START])
%%states
it_TEXT (+[ss_TEXT])
it_SECTIONSTART (-[ss_TEXT])
it_KEYNAME (-[ss_TEXT])
it_COMMENT (-[ss_TEXT])
it_EQUAL (-[ss_TEXT])
it_VALUE (-[ss_TEXT])
/*
The above script uses Match(1) to identify non-key/value pair lines.
This requires code attached to the OnCustomParse event handler.
Paste the following code into the event handler:
var orgKL,
sPos : longint;
begin
//
// INI parser support functions...
//
result := true;
sPos := IStream.yypos;
orgKL := klength;
case ParseID of
1 : //
// Newline (without recognised follower)
//
// Scan until one of the following is located:
// \n ------ Return entire line as default
// = ------ Return as key name
//
with IStream do begin
while (not yyeof) and (not (yychar in [#13, '='])) do begin
yyadvance;
inc(kLength);
end;
if yyeof
then kValue := 0 else
case yychar of
#13 : if kLength > 1
then begin
kValue := 8;
kLength := orgKL;
yypos := sPos;
end
else kValue := 0;
'=' : kValue := 3; // Key token value
end;
end;
end;
end;
*/