unit -->GrammarParserComponent;

interface

uses
  Windows, Messages, SysUtils, Classes,-->GrammarParser, pbStrLib;

type
  T-->GrammarParserComponent = class(TComponent)
  private
    { Private declarations }
    F-->GrammarParser : T-->GrammarParser;
    FInput: String;
    FOutput: String;
    procedure SetInput(const Value: String);
    procedure SetOutput(const Value: String);
  protected
    { Protected declarations }
  public
    { Public declarations }
    constructor Create(Aowner : TComponent); override;
    destructor Destroy; override;
    Function Execute : Boolean;
  published
    { Published declarations }
    Property Input : String read FInput write SetInput;
    Property Output : String read FOutput write SetOutput;
  end;


Function Execute-->GrammarParser(Const sInput : String; Var sOutput : String) : Boolean;


implementation

uses -->GrammarScanner;


Function Execute-->GrammarParser(Const sInput : String; Var sOutput : String) : Boolean;
Begin
   Result := False;
   With  T-->GrammarParserComponent.Create(NIL) do
   try
     Input := sInput;
     Result := Execute;
     sOutput := Output;
   finally
     Free;
    end;
End;


{ T-->GrammarParserComponent }

constructor T-->GrammarParserComponent.Create(Aowner: TComponent);
begin
  inherited;
 F-->GrammarParser := T-->GrammarParser.Create;
end;

destructor T-->GrammarParserComponent.Destroy;
begin
    F-->GrammarParser.Free;
  inherited;
end;

function T-->GrammarParserComponent.Execute: Boolean;
begin
  F-->GrammarParser.SourceString := FInput;
  F-->GrammarParser.Parse;
  FOutput := F-->GrammarParser.lst.DataString;
  Result := F-->GrammarParser.errors = 0;
end;

procedure T-->GrammarParserComponent.SetOutput(const Value: String);
begin
  FOutput := Value;
end;

procedure T-->GrammarParserComponent.SetInput(const Value: String);
begin
  FInput := Value;
end;

end.

