commit 5eaf405ca9f6878402d817c2dd3dc429eb25c88c
Author: citbl <citbl@citbl.org>
Date: Fri, 29 May 2026 19:29:34 +1000
init
Diffstat:
8 files changed, 98 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,6 @@
+bin/
+.DS_Store
+*.o
+*.ali
+
+
diff --git a/makefile b/makefile
@@ -0,0 +1,10 @@
+.SILENT:
+default: fmt
+ mkdir -p ./bin/
+ gnatmake -o bin/nightshade src/nightshade.adb
+ rm -rf *.o *.ali
+ ./bin/nightshade test.txt
+
+fmt:
+ gnatformat src/*.adb src/*.ads
+
diff --git a/src/lexer.adb b/src/lexer.adb
@@ -0,0 +1,7 @@
+package Lexer is
+ procedure Lex (L : in out Lexer) is
+ begin
+
+ end;
+
+end Lexer;
diff --git a/src/lexer.ads b/src/lexer.ads
@@ -0,0 +1,18 @@
+package Lexer is
+
+ type Token_Type is
+ (Ident, Float_Literal, Int_Literal, Str_Literal, Bool_Literal, Unknown);
+
+ type Token is record
+ Kind : Token_Type;
+ Lexeme : String;
+ Line, Col : Positive;
+ end record;
+
+ type Lexer is record
+ Source : String;
+ File_Name : String;
+
+ end record;
+ procedure Lex (L : in out Lexer);
+end Lexer;
diff --git a/src/nightshade.adb b/src/nightshade.adb
@@ -0,0 +1,20 @@
+with Ada.Text_IO; use Ada.Text_IO;
+with Utils; use Utils;
+with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
+with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
+with Ada.Command_Line; use Ada.Command_Line;
+
+procedure Nightshade is
+begin
+ if Argument_Count < 1 then
+ Put_Line ("usage: nightshade <filename>");
+ return;
+ end if;
+
+ declare
+ File_Name : constant String := Argument (1);
+ File_Contents : constant String := Utils.Load_Contents (File_Name);
+ begin
+ Put_Line (File_Contents);
+ end;
+end Nightshade;
diff --git a/src/utils.adb b/src/utils.adb
@@ -0,0 +1,28 @@
+with Ada.Text_IO; use Ada.Text_IO;
+with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
+with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
+
+package body Utils is
+ function Load_Contents (File_Name : String) return String is
+ F : File_Type;
+ Content : Unbounded_String := Null_Unbounded_String;
+ begin
+ Open (F, In_File, File_Name);
+
+ while not End_Of_File (F) loop
+ declare
+ Line : Unbounded_String;
+ begin
+ Get_Line (F, Line);
+ Append (Content, Line);
+ end;
+ if not End_Of_file (F) then
+ Append (Content, ASCII.LF);
+ end if;
+ end loop;
+ close (F);
+
+ return To_String (Content);
+
+ end Load_Contents;
+end Utils;
diff --git a/src/utils.ads b/src/utils.ads
@@ -0,0 +1,3 @@
+package Utils is
+ function Load_Contents (File_Name : String) return String;
+end Utils;
diff --git a/test.txt b/test.txt
@@ -0,0 +1,6 @@
+This is some text to be injected.
+
+Hello world. I am sam.
+
+I am not sam, but for the sake of this example, I am Andre.
+