From f4de4b9a8f86a7a6d305ac6410112ef7d4b46954 Mon Sep 17 00:00:00 2001 From: yannickreiss Date: Sat, 3 Feb 2024 10:49:34 +0100 Subject: [PATCH] ignore object directory contents --- .gitignore | 1 + src/main.adb | 71 +++++++++++++++++++++++++++++++++++++++++++++++ src/translate.adb | 14 ++++++++++ 3 files changed, 86 insertions(+) create mode 100644 .gitignore create mode 100644 src/translate.adb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..94053f2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +obj/* diff --git a/src/main.adb b/src/main.adb index 5efbabe..4dab5c8 100644 --- a/src/main.adb +++ b/src/main.adb @@ -4,12 +4,83 @@ -- Content: Compiler main call with Ada.Text_IO; with Ada.Command_Line; +with Ada.Strings.Unbounded; -- @name Main -- @return -- @description Main Function call procedure Main is + type InstructionList is array(1..65536) of String(1..64); + type ArgumentParserState is + (PSInit, PSFilename, PSLanguage, PSRecycle, PSFinish, PSError); + type FileList is array(1..128) of Unbounded.Unbounded_String; + ParserState : ArgumentParserState := Init; + Filename : Unbounded.Unbounded_String := + Unbounded.To_Unbounded_String ("bin.out"); + Language : Unbounded.Unbounded_String := + Unbounded.To_Unbounded_String ("VHDL"); + Recycle : Boolean := False; + InputFileList : FileList; + InputFileListIndex : Integer := 1; + Argument : String; + Argumenterror : exception; + Languageoptionerror : exception; begin + -- Check input file limit for arguments and lowest argument + if Ada.Command_Line.Argument_Count > 128 then + Text_IO.Put_Line ("To many arguments!"); + elsif Ada.Command_Line.Argument_Count < 2 then + Text_IO.Put_Line ("Not enough arguments!"); + end if; + + for Index in 1 .. Ada.Command_Line.Argument_Count loop + Argument := Command_Line.Argument(Index); + case ParserState is + when Init => + if Argument = "-o" then + ParserState := PSFilename; + elsif Argument = "-x" then + ParserState := PSLanguage; + elsif Argument = "-r" then + ParserState := PSRecycle; + else + ParserState := PSError; + end if; + when Filename => + ParserState := PSInit; + Filename := Unbounded.To_Unbounded_String (Argument); + when Language => + ParserState := PSInit; + Language := PSUnbounded.To_Unbounded_String (Argument); + when Recycle => + ParserState := PSInit; + Recycle := True; + when PSError => + ParserState := PSError; + raise Argumenterror; + when PSFinish => + ParserState := PSFinish; + InputFileListIndex := InputFileListIndex + 1; + InputFileList(InputFileListIndex) := Argument; + when others => + ParserState := PSFinish; + InputFileListIndex := 1; + InputFileList(InputFileListIndex) := Argument; + end case; + end loop; + + -- Check the language for correct values + if not (Language = "VHDL" or Language = "C") then + Text_Io.Put_Line + ("ERROR: The language " & Unbounded.To_String (Language) & + " is not available!"); + raise Languageoptionerror; + end if; + + -- Dissolve Language Features + -- Isolate Instructions + -- Translate into target code + end Main; diff --git a/src/translate.adb b/src/translate.adb new file mode 100644 index 0000000..183c17f --- /dev/null +++ b/src/translate.adb @@ -0,0 +1,14 @@ +with Ada.Unbounded; + +-- @name translate +-- @return InstructionList +-- @param PreparedCode : Unbound.Unbounded_String +-- @description Create instruction list +function translate + (PreparedCode : Unbound.Unbounded_String) return InstructionList +is + +begin + + return InstructionList; +end translate;