nightshade

The nightshade programming language, compiler and tools (WIP)
Log | Files | Refs | README

nightshade.adb (1071B)


      1 with Ada.Text_IO;                   use Ada.Text_IO;
      2 with Ada.Strings.Unbounded;         use Ada.Strings.Unbounded;
      3 with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
      4 with Ada.Command_Line;              use Ada.Command_Line;
      5 with Utils;
      6 with Lexer;
      7 with Parser;
      8 
      9 procedure Nightshade is
     10 begin
     11    if Argument_Count < 1 then
     12       Put_Line ("usage: nightshade <filename>");
     13       return;
     14    end if;
     15 
     16    declare
     17       File_Name     : constant String := Argument (1);
     18       Buffer        : constant String := Utils.Load_Contents (File_Name);
     19       Src_Ref       : constant Lexer.Source_Ref := new String'(Buffer);
     20       File_Name_Ref : constant Lexer.File_Name_Ref := new String'(File_Name);
     21       L             : Lexer.Lexer := Lexer.Init (File_Name_Ref, Src_Ref);
     22    begin
     23       Lexer.Lex (L);
     24       Lexer.Print_Tokens (L);
     25       Put_Line ("done lexing");
     26 
     27       declare
     28          P : Parser.Parser := Parser.Init (File_Name_Ref, Src_Ref, L.Tokens);
     29       begin
     30          Parser.Parse(P);
     31          Parser.Print_AST (P);
     32       end;
     33    end;
     34 end Nightshade;