unit newcmd;
  {$MODE DELPHI}{$H+}
interface


implementation
uses  Controls, Dialogs,  Forms, SysUtils,  lclintf,  FileUtil, math,
  base,arithmet,texthand,variabl,struct,express,compiler,control, float,
  helpctex,textfrm, MainFrm,sconsts,supplied ;

{**************************}
{ 単純文　パラメータは数値1個と文字列1個 }
{*************************}

type
   TNewCommand=class(TStatement)

      var1,var2:TPrincipal;
      constructor create(prev,eld:TStatement);
      destructor destroy;override;
      procedure exec;override;
    end;

constructor TNewCommand.create(prev,eld:TStatement);
begin
   inherited create(prev,eld);
   var1:=NExpression;
   check(',',0);
   var2:=SExpression;
end;

destructor TNewCommand.destroy;
begin
   var1.free;
   var2.free;
   inherited destroy
end;

procedure TNewCommand.exec;
var
   x:double;
  s:string;
begin
   x:=var1.EvalF;
   s:=var2.EvalS;
  //ここで必要な処理を記述する
end;

function  NewCommandst(prev,eld:TStatement):TStatement;
begin
    NewCommandst:=TNewCommand.create(prev,eld);
end;

{****************}
{数値関数　引数は数値一つ }

{****************}
type
   TNewNFunction=Class(TMiscReal)
             exp:TPrincipal;
          constructor create;
          function evalX:extended;override;
          destructor destroy;override;
     end;

constructor TNewNFunction.create;
begin
    inherited create;
    check('(',0);
    exp:=NExpression;
    check(')',0);
end;

function TNewNFunction.evalX:extended;
var
   x, y:extended;
begin
   x:=exp.evalX;
  //ここで，xからyを求める
   evalX:=y;
end;

destructor TNewNFunction.destroy;
begin
   exp.free;
   inherited destroy;
end;

function NewNFunctionfnc:TPrincipal;
begin
   NewNFunctionfnc:=NOperation(TNewNFunction.create);
end;

{*********************}
{文字列値関数  引数は文字列1個，数値1個}
{*********************}

type
   TNewSFunction=class(TStrExpression)
             exp1,exp2:TPrincipal;
          constructor create;
          function evalS:string;override;
          destructor destroy;override;
     end;

constructor TNewSFunction.create;
begin
   inherited create;
   check('(',0);
   exp1:=SExpression;
   check(',',0);
   exp2:=NExpression;
   check(')',0);
end;

destructor TNewSFunction.destroy;
begin
   exp2.free;
   exp1.free;
   inherited destroy;
end;

function TNewSFunction.evalS:ansistring;
var
   n:longint;
   s,t:string;
begin
   s:=exp1.evalS;
   n:=exp2.evalInteger;
  //ここでs,nからtを求める
   evalS:=s;
end;

function NewSFunctionfnc:TPrincipal;
begin
   NewSFunctionfnc:=TNewSFunction.create;
end;


{**********}
{initialize}
{**********}

procedure statementTableinit;
begin
       StatementTableInitImperative('NEWCOMMAND', NewCommandst);

end;


procedure  FunctionTableInit;
begin
     SuppliedFunctionTableInit('NEWFN' , NewNFunctionfnc);
     SuppliedFunctionTableInit('NEWF$' , NewSFunctionfnc);
end;


begin
  tableInitProcs.accept(statementTableinit);
  tableInitProcs.accept(FunctionTableInit);
end.
