master
Switch branches/tags
Could not load branches
Nothing to show
{{ refName }}1 branch 0 tags
Code
-
Clone
Use Git or checkout with SVN using the web URL.
- Open with GitHub Desktop
- Download ZIP
Latest commit
Git stats
- 15 commits
Files
PermalinkFailed to load latest commit information.
Type
Name
Latest commit message
Commit time
.gitignore
Makefile
Pascal.g4
README.txt
main.py
requirements.txt
test1.pas
test2.pas
test3.pas
test5.pas
README.txt
# pascal2python Конвертер кода из паскаля в питон. sudo apt install antlr4 git clone //github.com/fox0/pas2py.git cd pas2py virtualenv venv . venv/bin/activate pip install -r requirements.txt make Использование: ./main.py test.pas
syntax highlight
time limit: 5s 15s
What is Ideone?
Ideone is an online compiler and debugging tool which allows you to compile source code and execute it online in more than 60 programming languages.
How to use Ideone?
Choose a programming language, enter the source code with optional input data... and you are ready to go!
Having problems?
Check the samples to see how to write code which works correctly.To find out more visit our FAQ section.
Sphere Engine™
We are proud to present our Sphere Engine™ technology, which allows you to execute programs on a remote serverin a secure way within a complete runtime environment. Visit the Sphere Engine™ website to find out more.
Follow us
I understand. But how can I understand the datastructure of the binary data set, that is only accessible through the program? Are there any tools that could "guess" the structure of such a dataset, written i pascal (presumably)?
In the code I only find a reference to the data source (redbas.dat) in the following snippet and I assume it is this Procedure I want. Is it possible, as in Python, to run just this procedure and get an output in lets say a Python Pandas dataframe?
Procedure TDialog_05.StartSimulate; { Use data, and simulate here }
label ut;
begin
SimNxt := 0;
Assign(RedBasFile,'redbas.dat');
{$I-} reset(RedBasFile); {$I+}
if IOresult <> 0 then
begin
MessageBox(0,'Cannot open "redbas.dat"','File read error',mb_iconhand or mb_OK);
exit;
end;
if filesize(RedBasFile)<1 then
begin
MessageBox(0,'Empty file, "redbas.dat"','File size error',mb_iconhand or mb_OK);
goto ut;
end;
repeat
{$I-} read(RedBasFile,RedBasData); {$I+}
if IOresult <> 0 then goto UT; { Read error??? }
if ThisOK then PlotIt;
until eof(RedBasFile);
ForcePaint(RegHw); { Repaint with all simulate data }
if Chk_Var_05[6] then { list results also }
ListSim;
if Chk_Var_05[5] then { to printer also }
PrintRW(0);
UT:
{$I-} close(RedBasFile); {$I+}
if IOresult <> 0 then;
MessageBeep(0);
Chk_Var_05[5] := false; { Print once only }
Chk_Var_05[6] := false; { List once only }
SetChkRad(Hwindow,Chk_Var_05[5],Chk_id_05[5]); { brukes til chec'boxer }
SetChkRad(Hwindow,Chk_Var_05[6],Chk_id_05[6]);
end;
I have the following Pascal routine:
function TForm1.ldExtractFromLine (ldline: String; Post: Integer): String; var s: String; t: array[1..15] of String; i, iT: Integer; begin s := Trim(ldline); iT := 1; while s <> '' do begin s := Trim(s) + ' '; i := 1; while s[i] <> ' ' do Inc(i); t[iT] := Copy(s, 1, i-1); Inc(iT); s := Copy(s, i, Length(s)); end; ldExtractFromLine := ''; if Post < iT then ldExtractFromLine := t[Post]; end;I am trying to convert to Python. Here is what I have so far:
def ldExtractFromLine (ldline, post): post -= 1 # mjh t = [] s = ldline.strip() iT = 0; # mjh while s <> '': s = s.strip() + ' ' i = 0 # mjh while s[i] <> ' ': i += 1 # t[iT] = Copy(s, 1, i-1) # function Copy(const S: string; From: integer = 1; Count: integer = MaxInt): string; t.insert(iT, s[0:i-1+1]) # mjh iT += 1 s = s[i:(i+len(s)+1)] print "lala" result = '' if post < iT: result = t[post] # mjh return resultHowever, executing the routine results in endless "lala" printed to stdout. The problem is that Pascal lists start with index 1 and Python lists start with index 0. This is really confusing me. Can anyone find my error? The variable post is an integer generally less than 20. The variable ldline is a string that looks somewhat like "1 0 60 -24 -160 1 0 0 0 1 0 0 0 1 3001.dat".
[edit]
The entire script can be viewed here:
//github.com/Jeremy1980/LDBoxer
Here is some example input data:
0 Safe House 0 Name: building_013_safehouse.ldr 0 Author: Kevin Loch 0 ROTATION CENTER 0 0 0 1 "Custom" 0 ROTATION CONFIG 0 0 1 0 60 -24 -160 1 0 0 0 1 0 0 0 1 3001.dat 1 0 60 -24 -160 1 0 0 0 1 0 0 0 1 3001.dat 1 0 -20 -24 -160 1 0 0 0 1 0 0 0 1 3001.dat 1 0 -20 -24 -160 1 0 0 0 1 0 0 0 1 3001.dat 1 0 -100 -24 -160 1 0 0 0 1 0 0 0 1 3001.dat 1 0 -100 -24 -160 1 0 0 0 1 0 0 0 1 3001.dat 1 0 -180 -24 -160 1 0 0 0 1 0 0 0 1 3001.dat 1 0 -180 -24 -160 1 0 0 0 1 0 0 0 1 3001.datMore examples of input data can be found here:
//github.com/Jeremy1980/LDBoxer/issues/4