commit 15bd18352c4405d2e5095d27ef93386b71763aee
parent 435311d4cb4af862914c64989e7e4ecf14ccf7c3
Author: citbl <citbl@citbl.org>
Date: Tue, 9 Jun 2026 22:03:50 +1000
fix warnings
Diffstat:
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/parser.adb b/src/parser.adb
@@ -1,15 +1,13 @@
-with Lexer; use Lexer;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed;
-use Ada.Strings.Fixed;
package body Parser is
function Init
(File_Name : File_Name_Ref; Source : Source_Ref; Tokens : Token_Vector.Vector) return Parser
is
- P : Parser :=
+ P : constant Parser :=
(Source => Source,
File_Name => File_Name,
Tokens => Tokens,
@@ -61,9 +59,9 @@ package body Parser is
& " but found: "
& Token_Kind'Image (T.Kind)
& " at L"
- & Fixed.Trim(Positive'Image (T.Line), Left)
+ & Fixed.Trim (Positive'Image (T.Line), Left)
& ":"
- & Fixed.Trim(Positive'Image (T.Col), Left);
+ & Fixed.Trim (Positive'Image (T.Col), Left);
end if;
end if;
@@ -150,17 +148,17 @@ package body Parser is
function Parse_Statement (P : in out Parser) return Stmt_Ref is
T : Token;
begin
+ T := Peek (P);
loop
- Skip_New_Lines(P);
T := Peek (P);
+ Skip_New_Lines (P);
exit when T.Kind = EOF or (T.Kind = Keyword and T.Lexeme = "end");
Put_Line ("Parse_Statement");
if T.Kind = Ident and Peek2 (P).Kind = L_Paren then
return Parse_Call_Statement (P);
end if;
-
end loop;
-
+ raise Program_Error with "Parse Statement failed: unknown token " & Token'Image (T);
end;
---------------------
@@ -173,7 +171,6 @@ package body Parser is
Param_Name : Unbounded_String;
Param_Kind : Unbounded_String;
Public : Boolean := false;
- Func : Func_Decl;
Stmts : Stmt_Vectors.Vector;
Pa : Param;
Params : Param_Vectors.Vector;
@@ -186,11 +183,11 @@ package body Parser is
Public := true;
end if;
Name := Match (P, Ident).Lexeme;
- Put_Line("name: " & To_String(Name));
- T := Peek(P);
- Put_Line(Token'Image(T));
+ Put_Line ("name: " & To_String (Name));
+ T := Peek (P);
+ Put_Line (Token'Image (T));
T := Match (P, L_Paren); -- (
- Put_Line("woefijweoif");
+ Put_Line ("woefijweoif");
loop
-- func decl params
@@ -223,6 +220,7 @@ package body Parser is
Func_Decl'
(Name => Name,
Params => Params,
+ Public => Public,
Return_Kind => To_Unbounded_String (""),
Stmts => Stmts));
diff --git a/src/parser.ads b/src/parser.ads
@@ -101,6 +101,7 @@ package Parser is
Params : Param_Vectors.Vector;
Return_Kind : Unbounded_String;
Stmts : Stmt_Vectors.Vector;
+ Public : Boolean;
end record;
type Decl_Kind is (Function_Kind);