Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Delphi7 -> Compilerbau -> IF ELSE ENDIF Abfrage programmieren

Empfohlene Antworten

Veröffentlicht

Hallo,

wie kann ich eine (endlos) Tiefenschleife programmieren, die

IF expr = expr

code

ELSEIF code

ELSE code

ENDIF

Programmcode ausgeben kann?

Zweck: Compilerbau, x86 32-Bit Assembler Output.

Danke für Infos und Codebeispiele

paule22

P.S: Hier der momentane Code :

function TParserClass.handle_if: Boolean;

label label_if, start_if;

var

c: char;

cs,s2: String;

l,i,b: integer;

begin

start_if:

if_counter := if_counter+1;

if_counter_tmp := if_counter;

c := skip_white_space;

if c in ['_','A'..'Z','a'..'z'] then

begin

ident_str := c;

scan_ident;

cs := ident_str;

c := skip_white_space;

if c = '=' then

begin

c := skip_white_space;

if (c >= '0') and (c <= '9') then

begin

num_str := c;

scan_num;

s2 := FActiveClass+':'+FActiveObject;

i := FEventCodeOutput.IndexOf(s2);

if i > -1 then

begin

if if_counter > 1 then

TStringList(FEventCodeOutput.Objects).Add(#9+'mov dword eax, ' + num_str);

TStringList(FEventCodeOutput.Objects).Add(#9+'cmp dword eax, [@v_' + cs + ']');

TStringList(FEventCodeOutput.Objects).Add(#9+'jne near Lv_'+inttostr(if_counter));

l := yylex;

if l = TOK_THEN then

begin

label_if:

l := yylex;

if l = TOK_ELSE then begin end else

if l = TOK_ENDIF then

begin

TStringList(FEventCodeOutput.Objects).Add('Lv_'+inttostr(if_counter)+':');

end else

if l = TOK_SHOWMESSAGE then

begin

handle_showmessage;

TStringList(FEventCodeOutput.Objects).Add('Lv_'+inttostr(if_counter)+':');

dec(if_counter);

l := yylex;

if l = TOK_ELSE then

begin

TStringList(FEventCodeOutput.Objects).Add(#9+'jmp Lv_'+inttostr(if_counter));

end else

if l = TOK_SHOWMESSAGE then showmessage('msfg') else

if l = TOK_ENDIF then

begin

TStringList(FEventCodeOutput.Objects).Add(#9+'jmp Lv_'+inttostr(if_counter));

end else handle_parser_code(l);

//goto label_if;

end;

end;

end;

end;

end;

end;

end(*handle_if*);

Ich kenne zwei ScriptEngines, die beide genauso wie Du paule vorgehene.

Schau Dir zum Beispiel mal PascalScript (jetzt) von RemObjects an.

Aber prinzipiell hab ich noch nicht ganz verstanden, was Du mit endlos IF-ELSEIF-... meinst?!

Willst Du dynamisches IF-ELSEIF in ASM abbilden?

Oder in der Hochsprache? Sowas wie ein Case-Of?

Hallo Ihr beiden,

unter

nopaste.info - free nopaste script and service

habe ich meine Bemühungen von heute morgen gepostet.

Ich meinte mit endlos Tiefe, das geschachtelte IF ELSEIF ELSE ENDIF

Anweisungen zu realisieren.

Der Code funktioniert fast, mit der Ausnahme, das unter dem

EndIF stehende Anweisungen nicht mehr behandelt werden

z.B.:

if 2 = 2

  zwei.ontimer = ok


  if 4 = 4

    vierzwei.ontimer = ok4

  else

    zweiff.ontimer = false4

  endif


  // hier wird der code irgendwie abgeschnitten

  zweidrei.ontimer = ok2

else

  zwei.ontimer = false

endif

könnt ihr mal bitte ein Auge drauf werfen?

Danke!

Die yacc Software kann unter: Albert Gräf's Homepage geladen werden.

Gruß

paule

P.S.: per yacc übersetzt, müssen ein paar Zeilen ersetzt werden ...

Zeile 65:

type YYSType = record

yylbl : lbl ;

end(*YYSType*);

Zeile 932 bis 936 auskommentieren

.... :

(*

if yysp>yymaxdepth then

begin

yyerror('yyparse stack overflow');

goto abort;

end;

*)

Und ja, Andy, ich will einen 32 Bit code basteln ... nasm.exe

Bearbeitet von paule22

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.