diff --git a/compiler/src/main/pascal/Blaise.pas b/compiler/src/main/pascal/Blaise.pas index 6c44aab..07d39e1 100644 --- a/compiler/src/main/pascal/Blaise.pas +++ b/compiler/src/main/pascal/Blaise.pas @@ -16,7 +16,7 @@ program Blaise; uses SysUtils, Classes, Process, - uLexer, uParser, uAST, uCodeGenQBE; + uLexer, uParser, uAST, uSemantic, uCodeGenQBE; const Version = '0.1.0-alpha'; @@ -272,10 +272,11 @@ var SourceFile, OutputFile: string; EmitIR: Boolean; Source: TStringList; - Lexer: TLexer; - Parser: TParser; - Prog: TProgram; - CG: TCodeGenQBE; + Lexer: TLexer; + Parser: TParser; + Prog: TProgram; + Semantic: TSemanticAnalyser; + CG: TCodeGenQBE; IR: string; IRFile: string; @@ -315,10 +316,11 @@ begin end; end; - Lexer := nil; - Parser := nil; - Prog := nil; - CG := nil; + Lexer := nil; + Parser := nil; + Prog := nil; + Semantic := nil; + CG := nil; try try Lexer := TLexer.Create(Source.Text); @@ -332,6 +334,17 @@ begin end; end; + try + Semantic := TSemanticAnalyser.Create; + Semantic.Analyse(Prog); + except + on E: ESemanticError do + begin + WriteLn(StdErr, 'Semantic error: ', E.Message); + Halt(1); + end; + end; + try CG := TCodeGenQBE.Create; CG.Generate(Prog); @@ -345,6 +358,7 @@ begin end; finally CG.Free; + Semantic.Free; Prog.Free; Parser.Free; Lexer.Free;