commit 2f35ebb4da864399090c6e923425b560ae04aa7b
parent 69e640d695bb5b9a554393e7bb8be60830a9ab28
Author: citbl <citbl@citbl.org>
Date: Fri, 12 Jun 2026 20:44:39 +1000
minor cleanups
Diffstat:
2 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/src/lexer.adb b/src/lexer.adb
@@ -16,6 +16,16 @@ package body Lexer is
end Init;
+ ---------------
+ -- add token --
+ ---------------
+
+ procedure Add_Token (L : in out Lexer; T : Token) is
+ begin
+ L.Tokens.Append (T);
+ end Add_Token;
+
+
function Peek (L : in Lexer) return Character is
begin
if L.Pos > L.Source'Length then
@@ -34,7 +44,9 @@ package body Lexer is
return C;
end;
- -- nudge
+ -----------
+ -- nudge --
+ -----------
procedure Nudge (L : in out Lexer) is
C : Character;
@@ -49,7 +61,9 @@ package body Lexer is
L.Pos := L.Pos + 1;
end;
- -- skip spaces
+ ----------------------------
+ -- handle space comments --
+ ----------------------------
procedure Handle_Space_Comments (L : in out Lexer) is
C : Character;
@@ -87,7 +101,9 @@ package body Lexer is
end loop;
end Handle_Space_Comments;
- -- make ident
+ ----------------
+ -- make ident --
+ ----------------
function Make_Ident (L : in out Lexer) return Token is
T : Token;
@@ -149,7 +165,9 @@ package body Lexer is
return T;
end Make_Ident;
- -- make number
+ -----------------
+ -- make number --
+ -----------------
function Make_Number (L : in out Lexer) return Token is
T : Token;
@@ -188,7 +206,9 @@ package body Lexer is
return T;
end Make_Number;
- -- make string
+ -----------------
+ -- make string --
+ -----------------
function Make_String (L : in out Lexer) return Token is
C : Character;
@@ -220,7 +240,9 @@ package body Lexer is
return T;
end Make_String;
- -- next token
+ ----------------
+ -- next token --
+ ----------------
function Next_Token (L : in out Lexer) return Token is
T : Token;
@@ -300,13 +322,6 @@ package body Lexer is
return T;
end Next_Token;
- -- add token
-
- procedure Add_Token (L : in out Lexer; T : Token) is
- begin
- L.Tokens.Append (T);
- end Add_Token;
-
procedure Lex (L : in out Lexer) is
Tok : Token;
begin
@@ -319,6 +334,10 @@ package body Lexer is
end Lex;
+ ------------------
+ -- print tokens --
+ ------------------
+
procedure Print_Tokens (L : in out Lexer) is
I : Natural := 0;
Total : constant Natural := Natural (L.Tokens.Length);
diff --git a/src/lexer.ads b/src/lexer.ads
@@ -46,7 +46,6 @@ package Lexer is
function Init (File_Name : File_Name_Ref; File_Contents : Source_Ref) return Lexer;
- procedure Add_Token (L : in out Lexer; T : Token);
procedure Print_Tokens (L : in out Lexer);
procedure Lex (L : in out Lexer);