//------------------------------------- // stream out //------------------------------------- procedure app(S:String); var i:integer; begin for i:=1 to Length(S) do
os.WriteBuffer(S[i], 1); end;
//------------------------------------- // stream out //------------------------------------- function colorof(H:Highlite):String; var i:Highlite;R:String; begin
R:='1'; for i:=low(Opt.r.Highlites) toHigh(Opt.r.Highlites) do if i=H then
R:= inttostr(ord(i)+1);
R:='\cf'+R+' \f1 ';
colorof:=R end;
//------------------------------------- // stream out //------------------------------------- function endline():String; var S:String;i:integer; begin
S:=''; for i:=1 to indent do S:=S+' ';
endline:='\par '+S; end;
//------------------------------------- // express //------------------------------------- procedure rtfheader; var
Header : String ;
h : Highlite; C:TColor;
rgb, r, g, b : integer; Fsk : String;
ThisFont:String; begin
ThisFont:='Fixedsys'; //set rtf header
Header := '{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 '+ThisFont+';}'+ '{\f1\fmodern\fprq1\fcharset0 '+ThisFont+';}';
Header := Header + '{\colortbl;'; for h:= low(Highlite) tohigh(Highlite) dobegin
C := opt.r.Highlites[h];
rgb := ColorToRGB(C);
b := rgb mod 256;rgb := rgb div 256;
g := rgb mod 256;rgb := rgb div 256;
r := rgb;
Header := Header + '\red' + Inttostr(r);
Header := Header + '\green'+ IntToStr(g);
Header := Header + '\blue' + IntToStr(b);
Header := Header + ';'; end;
Header := Header + '}';
Fsk:=''; if fsbold in Opt.R.FontStyle then Fsk := Fsk + '\b '; if fsunderline in Opt.R.FontStyle then Fsk := Fsk + '\u '; if fsitalic in Opt.R.FontStyle then Fsk := Fsk + '\i ';
Header := Header + '{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\lang1031'+
Fsk+'\f0\fs'+
inttostr(Opt.r.fontsize*2)+'}';
app(Header) end;
//------------------------------------- // class header //------------------------------------- procedure fileheader(S:String); var T:String; begin
indent := 0;
T:=colorof(H_Keyword)+'import '+endcolor;
T:=T+colorof(H_Identifier)+'java.io.*'+endcolor;
T:=T+colorof(H_String)+';'+endcolor;
app(T+endline);
T:=colorof(H_Keyword)+'import '+endcolor;
T:=T+colorof(H_Identifier)+'com.ibm.math.*'+endcolor;
T:=T+colorof(H_String)+';'+endcolor;
app(T+endline+endline); end;
//------------------------------------- // class header //------------------------------------- procedure classheader(S:String); var T:String; begin
indent := 0;
T:=colorof(H_Keyword);
T:=T+'public class ';
T:=T+endcolor;
app(T);
app(colorof(H_Identifier)+Stripof(S)+endcolor);
app(colorof(H_String)+' \{'+endcolor);
indent := indent+indepth;
app(endline());
State:=s_null; end;
//------------------------------------- // parse //------------------------------------- function expression(tn:TTreeNode):String; var S, R:String;tc:TTreeNode; begin
expression:=''; if tn<>nilthenbegin
S := tn.Text;R:=''; if (S=':=') or (S='+') or (S='-') or (S='*') or (S='/') or (S='<') or (S='<=') or (S='==') or (S='>=') or (S='>') or (S='<>') or (S='**') or (S='rem') thenbegin
tc:=tn.getFirstChild; if S=':='then S:=' = ';
R:=expression(tc)+colorof(H_String)+' '+S+endcolor+' '; while tc<>nildobegin
tc:=tc.getNextSibling;
R:=R+expression(tc) end endelseif (S='Test') thenbegin
tc:=tn.getFirstChild;
R:=expression(tc)+' '; while tc<>nildobegin
tc:=tc.getNextSibling;
R:=R+expression(tc) end endelse
R := colorof(H_Identifier)+S+endcolor;
expression:=R end end;
//------------------------------------- // append to list //------------------------------------- procedure append(var S:String;T:String); begin if S=''then S:=T elsebegin
S:=S+','+T end end;
//------------------------------------- // express //------------------------------------- function definitions(tn:TTreeNode;Sep:char;wrap:boolean):String; var L, T, B, S, R, D:String; begin if tn<>nilthenbegin if wrap then Listcounter := Listcounter+1;
L := Longeur(TVL,tn);
T := getpar(S_Typ,L);
B := getpar(S_Bas,L); if B='decimalbase'thenbegin
R:=colorof(H_Keyword)+'long ' +endcolor+Functor(L);
append(Values,inttostr(Random(GetCurrentTime MOD 29))); endelseif B='binarybase'thenbegin
R:=colorof(H_Keyword)+'long ' +endcolor+Functor(L);
append(Values,inttostr(Random(GetCurrentTime MOD 29))); endelseif B='octetbase'thenbegin
R:=colorof(H_Keyword)+'String '+endcolor+Functor(L);
append(Values,inttostr(Random(GetCurrentTime MOD 29))); endelsebegin
R:=colorof(H_Identifier)+S+endcolor end; if wrap and (Listcounter>=3) thenbegin R:=endline()+R;ListCounter:=0 end;
D:=definitions(tn.getNextSibling(),Sep,wrap); if (D<>'') then definitions:=R+Sep+D elseif (Sep=';') then definitions:=R+Sep+D else definitions:=R end else definitions:=''; end;
//------------------------------------- // express //------------------------------------- procedure traverse(tn:TTreeNode); var tc:TTreeNode;S :String;komma:boolean; begin if tn<>nilthenbegin
S := tn.Text; if S='Data'thenbegin
tc:=tn.getFirstChild(); while tc<>nildobegin
traverse(tc);
tc:=tc.getNextSibling end endelseif S='Working-Storage'thenbegin
Listcounter:=0;
Values:='';
Working:=definitions(tn.getFirstChild(),';',true); endelseif S='Linkage'thenbegin
Listcounter:=0;
Values:='';
Linkage:=definitions(tn.getFirstChild(),',',false);
Actuals:=Values; endelseif S='Procedure'thenbegin if Linkage<>''thenbegin
app('('+Linkage+')'+colorof(H_String)+' \{'+endcolor+endline()); endelse
app(colorof(H_String)+'() \{'+endcolor+endline);
app(Working);
traverse(tn.getFirstChild());
indent:=indent-indepth; endelseif S='If'thenbegin
tc:=tn.getFirstChild();
app(expression(tc)+endline());
traverse(tc.getNextSibling) endelseif S=':='thenbegin
S:=expression(tn);
app(endline+S+';');
tc:=tn.Parent.GetNextChild(tn);
traverse(tc); endelseif (S='interface') thenbegin
tc:=tn.getFirstChild;
S:=expression(tc); if tc.Text='display'then
S:=StringReplace(S,'display','System.out.println',[rfReplaceAll]);
app(endline+S+'(');
tc:=tc.getNextSibling;
komma:=false; while tc<>nildobegin if komma then app(colorof(H_String)+'+'+endcolor);
komma:=true;
S:=expression(tc);
app(S);
tc:=tc.getNextSibling; end;
app(colorof(H_String)+')'+endcolor+';') endelseif S='branch'thenbegin endelseif S='perform'thenbegin
app(endline+colorof(H_Keyword)+'while'+endcolor+colorof(H_String)+' (!('+endcolor);
indent:=indent+indepth;
tc:=tn.getFirstChild();
app(expression(tc));
app(colorof(H_String)+')) \{'+endcolor);
tc:=tc.getNextSibling();
traverse(tc);
indent:=indent-indepth;
app(colorof(H_String)+'\}'+endcolor);
tc:=tn.Parent.GetNextChild(tn);
traverse(tc); endelsebegin
tc:=tn.getFirstChild(); while tc<>nildobegin
traverse(tc);
tc:=tc.getNextSibling end end end end;
//------------------------------------- // JavaConvert //------------------------------------- procedure MakeJava(FN:String;SO:TTreeView;var TR:TRichEdit); var
streamout:TMemoryStream;
Save_Cursor:TCursor; begin
TR.Lines.Clear;
streamout := TMemoryStream.Create;
streamout.SetSize(SO.Items.Count*32);
streamout.Position := 0;
os:=streamout;
Save_Cursor := Screen.Cursor;
Screen.Cursor := crHourGlass; // now output JAVA program
RtfHeader;
fileheader(LowerCase(Application.Title));
classheader(Fn);
methodheader(SO.TopItem.Text);
traverse(SO.TopItem);
methodtrailer(SO.TopItem.Text);
classtrailer(Fn); // and load it to richedit
streamout.Position := 0;
TR.Lines.LoadFromStream(streamout);
Screen.Cursor := Save_Cursor;
streamout.Destroy end;
{------------------------------------------------------------------}
{- execute JAVA artefact -}
{- -}
{------------------------------------------------------------------} procedure CompileLinkGo(Hand:THandle;SDir,SClass:String); var Fse: text;CmdFile, Umleitung:String;H:Cardinal; begin
CmdFile:=SDir+SClass+'.cmd';
Umleitung := '>'+StripOf(SClass)+'.txt'; try
AssignFile (Fse,CmdFile);
Rewrite(fse);
writeln(fse,'javac '+SClass+' 2'+Umleitung);
writeln(fse,'java -cp . '+StripOf(SClass)+' 1'+Umleitung);
writeln(fse,'pause');
CloseFile(fse); except
On E:Exception do error(em+53,'unable to create '+sdir+SMAcOut
+' Dir='+SDir+' Msg='+E.Message); end;
{------------------------------------------------------------------}
{- -}
{- Ende dieser Quelle -}
{- -}
{------------------------------------------------------------------} end.
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.