Update
This commit is contained in:
parent
322cf64183
commit
baccabf868
19
src/main.adb
19
src/main.adb
|
@ -6,11 +6,12 @@ with Ada.Text_IO;
|
|||
with Ada.Command_Line;
|
||||
with Ada.Strings.Unbounded;
|
||||
|
||||
with Translate; use Translate;
|
||||
|
||||
-- @name Main
|
||||
-- @return
|
||||
-- @description Main Function call
|
||||
procedure Main is
|
||||
type InstructionList is array (1 .. 65_536) of String (1 .. 64);
|
||||
type ArgumentParserState is
|
||||
(PSInit, PSFilename, PSLanguage, PSRecycle, PSFinish, PSError);
|
||||
type FileList is array (1 .. 128) of Ada.Strings.Unbounded.Unbounded_String;
|
||||
|
@ -23,6 +24,9 @@ procedure Main is
|
|||
InputFileList : FileList;
|
||||
InputFileListIndex : Integer := 1;
|
||||
Argument : Ada.Strings.Unbounded.Unbounded_String;
|
||||
RawCode : Ada.Strings.Unbounded.Unbounded_String;
|
||||
TokenCode : InstructionList;
|
||||
CompiledCode : Ada.Strings.Unbounded.Unbounded_String;
|
||||
|
||||
Argumenterror : exception;
|
||||
Languageoptionerror : exception;
|
||||
|
@ -84,8 +88,19 @@ begin
|
|||
raise Languageoptionerror;
|
||||
end if;
|
||||
|
||||
-- Read code from input file list
|
||||
|
||||
-- Dissolve Language Features
|
||||
|
||||
-- Isolate Instructions
|
||||
-- Translate into target code
|
||||
|
||||
-- Translate into target code (The default is VHDL)
|
||||
if Ada.Strings.Unbounded.To_String (Language) = "C" then
|
||||
CompiledCode := translateC (TokenCode);
|
||||
else
|
||||
CompiledCode := translateVHDL (TokenCode);
|
||||
end if;
|
||||
|
||||
Ada.Text_IO.Put_Line (Ada.Strings.Unbounded.To_String (CompiledCode));
|
||||
|
||||
end Main;
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package body Tokenizer is
|
||||
function CheckSyntax
|
||||
(RawCode : Ada.Strings.Unbounded.Unbounded_String) return Boolean
|
||||
is
|
||||
Validity : Boolean := False;
|
||||
begin
|
||||
|
||||
-- Replace optional symbols with spaces
|
||||
|
||||
-- Seperate into Tokens
|
||||
|
||||
-- Run through state machine
|
||||
|
||||
return True;
|
||||
end CheckSyntax;
|
||||
|
||||
function Tokenize
|
||||
(RawCode : Ada.Strings.Unbounded.Unbounded_String)
|
||||
return Translate.InstructionList
|
||||
is
|
||||
SingleInstructions : Translate.InstructionList;
|
||||
begin
|
||||
|
||||
return SingleInstructions;
|
||||
end Tokenize;
|
||||
end Tokenizer;
|
|
@ -0,0 +1,10 @@
|
|||
with Ada.Strings.Unbounded;
|
||||
with Translate; use Translate;
|
||||
|
||||
package Tokenizer is
|
||||
function CheckSyntax
|
||||
(RawCode : Ada.Strings.Unbounded.Unbounded_String) return Boolean;
|
||||
function Tokenize
|
||||
(RawCode : Ada.Strings.Unbounded.Unbounded_String)
|
||||
return Translate.InstructionList;
|
||||
end Tokenizer;
|
|
@ -1,14 +1,46 @@
|
|||
with Ada.Unbounded;
|
||||
with Ada.Strings.Unbounded;
|
||||
|
||||
-- @name translate
|
||||
-- @return InstructionList
|
||||
-- @param PreparedCode : Unbound.Unbounded_String
|
||||
-- @description Create instruction list
|
||||
function translate
|
||||
(PreparedCode : Unbound.Unbounded_String) return InstructionList
|
||||
is
|
||||
package body Translate is
|
||||
|
||||
begin
|
||||
-- @name translateVHDL
|
||||
-- @return Unbounded.Unbounded_String
|
||||
-- @param PreparedCode : Unbound.Unbounded_String
|
||||
-- @description Create instruction list
|
||||
function translateVHDL
|
||||
(PreparedCode : Translate.InstructionList)
|
||||
return Ada.Strings.Unbounded.Unbounded_String
|
||||
|
||||
return InstructionList;
|
||||
end translate;
|
||||
is
|
||||
type Instruction is array (1 .. 1) of String (1 .. 64);
|
||||
InstructionCode : Instruction;
|
||||
CompiledCode : Ada.Strings.Unbounded.Unbounded_String;
|
||||
begin
|
||||
|
||||
CompiledCode := Ada.Strings.Unbounded.To_Unbounded_String ("");
|
||||
|
||||
-- iterate over code in newline
|
||||
|
||||
return CompiledCode;
|
||||
end translateVHDL;
|
||||
|
||||
-- @name translateC
|
||||
-- @return Unbounded.Unbounded_String
|
||||
-- @param PreparedCode : Unbound.Unbounded_String
|
||||
-- @description Create instruction list
|
||||
function translateC
|
||||
(PreparedCode : Translate.InstructionList)
|
||||
return Ada.Strings.Unbounded.Unbounded_String
|
||||
|
||||
is
|
||||
type Instruction is array (1 .. 1) of String (1 .. 64);
|
||||
InstructionCode : Instruction;
|
||||
CompiledCode : Ada.Strings.Unbounded.Unbounded_String;
|
||||
begin
|
||||
|
||||
CompiledCode := Ada.Strings.Unbounded.To_Unbounded_String ("");
|
||||
|
||||
-- iterate over code in newline
|
||||
|
||||
return CompiledCode;
|
||||
end translateC;
|
||||
end Translate;
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
with Ada.Strings.Unbounded;
|
||||
|
||||
package Translate is
|
||||
type TokenizedInstruction is record
|
||||
Instruction : String (1 .. 8);
|
||||
Operand1 : String (1 .. 16);
|
||||
Operand2 : String (1 .. 16);
|
||||
Operand3 : String (1 .. 16);
|
||||
end record;
|
||||
type InstructionList is array (1 .. 65_536) of TokenizedInstruction;
|
||||
function translateVHDL
|
||||
(PreparedCode : InstructionList)
|
||||
return Ada.Strings.Unbounded.Unbounded_String;
|
||||
function translateC
|
||||
(PreparedCode : InstructionList)
|
||||
return Ada.Strings.Unbounded.Unbounded_String;
|
||||
end Translate;
|
Loading…
Reference in New Issue