| Class TAwkParser (unit MiniAwk) |
TObject
15feb96 kci -- develop TAwkParser, a simple awk-like line parser notes 24feb96 kci This awk object is but a limited subset of a real awk system, but does provide the basic "parse-input-into-fields" that is a key part of awk. Example using MiniAwk: var arg: TAwkParser; ... arg := TAwkParser.Create; arg.FS := ';'; // otherwise FS defaults to '', which matches any number of spaces arg.Parse('any text; to be parsed; on the FS delimiter'); // arg.CreateParse(';', 'any text; ...'); // would be equivalent to get to this point write('the entire input string was "' + arg[0] + '"'); for i := 1 to arg.NF do write('field #' + i + ' is "' + arg[i] + '"'); arg.Free; Possible directions: * support stream i/o * re-parse if any input field is assigned-to * support regular expressions * support other awkish behavior
| Constructors |
constructor CreateParse(const fs, line: string);| Functions |
procedure Parse(const Line: string);
function GetArg(n: byte): string;| Properties |
property Arg : string
property FS : string
property NF : byte| Events |
| Variables |
Count : array[0..255] of integer;
FieldSep : string;
FLine : string;
NumFields : byte;| Constructors |
constructor CreateParse(const fs, line: string);| Functions |
procedure Parse(const Line: string);count[n] is assumed to contain a valid count, at least 1!
function GetArg(n: byte): string;| Properties |
property Arg : string
property FS : string
property NF : byte| Events |
| Variables |
Count : array[0..255] of integer;
FieldSep : string;
FLine : string;
NumFields : byte;