diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-05-30 14:36:33 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-05-30 14:36:33 +0200 |
commit | ce315116b6b9360659511eb23f7dfb231921327e (patch) | |
tree | 336f758890e772116b47d104c23ad230eb6218d2 /src/ghdldrv | |
parent | ad46e4bed268a9c4faefb503deec7dc5603a9be2 (diff) | |
download | ghdl-ce315116b6b9360659511eb23f7dfb231921327e.tar.gz ghdl-ce315116b6b9360659511eb23f7dfb231921327e.tar.bz2 ghdl-ce315116b6b9360659511eb23f7dfb231921327e.zip |
vhdl: add code formatter (WIP)
Diffstat (limited to 'src/ghdldrv')
-rw-r--r-- | src/ghdldrv/ghdlprint.adb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ghdldrv/ghdlprint.adb b/src/ghdldrv/ghdlprint.adb index 6d1d8d5e5..d7293a778 100644 --- a/src/ghdldrv/ghdlprint.adb +++ b/src/ghdldrv/ghdlprint.adb @@ -38,6 +38,7 @@ with Vhdl.Sem_Lib; use Vhdl.Sem_Lib; with Ghdlmain; use Ghdlmain; with Ghdllocal; use Ghdllocal; with Vhdl.Prints; +with Vhdl.Formatters; with Vhdl.Elocations; package body Ghdlprint is @@ -959,6 +960,7 @@ package body Ghdlprint is -- Command Reprint. type Command_Reprint is new Command_Lib with record Flag_Sem : Boolean := True; + Flag_Format : Boolean := False; end record; function Decode_Command (Cmd : Command_Reprint; Name : String) return Boolean; @@ -993,6 +995,9 @@ package body Ghdlprint is if Option = "--no-sem" then Cmd.Flag_Sem := False; Res := Option_Ok; + elsif Option = "--format" then + Cmd.Flag_Format := True; + Res := Option_Ok; else Decode_Option (Command_Lib (Cmd), Option, Arg, Res); end if; @@ -1045,7 +1050,9 @@ package body Ghdlprint is Next_Unit := Get_Chain (Unit); if Errorout.Nbr_Errors = 0 then - Vhdl.Prints.Disp_Vhdl (Unit); + if not Cmd.Flag_Format then + Vhdl.Prints.Disp_Vhdl (Unit); + end if; if Cmd.Flag_Sem then Set_Chain (Unit, Null_Iir); Libraries.Add_Design_Unit_Into_Library (Unit); @@ -1058,6 +1065,10 @@ package body Ghdlprint is if Errorout.Nbr_Errors > 0 then raise Errorout.Compilation_Error; end if; + + if Cmd.Flag_Format then + Vhdl.Formatters.Format (Design_File); + end if; end loop; end Perform_Action; |