Autor Beitrag
YiB
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 22

Win XP Pro, Knoppix

BeitragVerfasst: Do 11.05.06 20:03 
Hi! Delphi gibt mir bei dem folgenden Source diesen Fehler:
"[Fehler] UParser.pas(34): E2018 Record, Objekt oder Klassentyp erforderlich"

UParser.pas sieht so aus:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
unit UParser;

interface

uses
  UScanner;


type TParser = class
  private
    Symbols: array of TPublicSymbol;

  public
    procedure CheckSyntax();
end;


implementation

procedure TParser.CheckSyntax();
var
  Scanner: TScanner;

begin
  (***** Symbole laden *****)
  while Scanner.GetSym() do
  begin
    SetLength(Symbols, Length(Symbols) + 1);
    Symbols.SymType := Scanner.Symbol.SymType
  end
end;


end.



TPublicSymbol ist in UScanner.pas im Interfaceteil deklariert, also sollte es daran nicht liegen.

Kann mir evtl. so schon jemand sagen woher der Fehler kommt oder braucht ihr mehr Infos?


Danke schonmal im Vorraus für jede Hilfe!

MfG, YiB
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 11.05.06 20:06 
was steht bei dir in Zeile 34

_________________
Markus Kinzler.
YiB Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 22

Win XP Pro, Knoppix

BeitragVerfasst: Do 11.05.06 20:08 
Steht doch im Post oben ;)
Nur "end."
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 11.05.06 20:13 
Irgend wie fehlt da baer was. Du deklarierst Scanner, erzeugst aber nie eine Instanz davon.

_________________
Markus Kinzler.
YiB Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 22

Win XP Pro, Knoppix

BeitragVerfasst: Do 11.05.06 20:16 
Hast Recht ^^
Aber wenn ich vor die Whileschleife ein Scanner.create() setz kommt derselbe Fehler...
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 11.05.06 20:26 
Nicht Scanner.create( ...) sondern Scanner := TScanner.Create( ...);

Wie ist Scanner deklariert?

_________________
Markus Kinzler.
YiB Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 22

Win XP Pro, Knoppix

BeitragVerfasst: Do 11.05.06 20:28 
Ändert leider auch nichts...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
type TScanner = class
  private
    var
      InFile: file;
      cLine: integer;
      Ch: char;
      PrevCh: char;
      Sym: TSymbol;
      SymStr: string;
      bUCase: boolean;
  public
    Symbol: TPublicSymbol;

    constructor create(sInFile: string);
    function GetSym(): boolean;
end;
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 11.05.06 20:44 
In Zeile 28 vergrößerst du zawr dein Array, die sich darin befindlichen Referenzen von TPublicSymbol müssen aber ja auch gesetzt werden. Der Fehler wird höchstwahrscheinlich in Zeile 29 ausgelöst es das symbols ja ein array ist und deshalb keien Eigenschaft .Symtype hat. Was macht die Klasse TScanner eigentlich?

_________________
Markus Kinzler.
YiB Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 22

Win XP Pro, Knoppix

BeitragVerfasst: Fr 12.05.06 12:25 
Oh Mann, ich hab den Fehler, und es war wie fast immer ein extrem dummer -.-
Ich hab nur den Index bei Symbols.SymType vergessen :oops:

TPublicSymbol ist ein Record, da muss man doch keinen Constructor oder sowas aufrufen oder? oO

> Was macht die Klasse TScanner eigentlich?
Der zerlegt eine Datei in Tokens, irgendwann solls mal ein Interpreter werden ^^


Vielen Dank dass du mir geholfen hast! :D