diff options
author | Tristan Gingold <tgingold@free.fr> | 2021-01-18 20:04:48 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2021-01-19 07:40:57 +0100 |
commit | 39dacc4e3385f36073d389c86fa5a7c6cdde450f (patch) | |
tree | 87f57ed3a9bbd2b7cef38006284c52bd394b9f8b /src/files_map.adb | |
parent | d00af0f399558b6d0d7e84ec58050921a0648204 (diff) | |
download | ghdl-39dacc4e3385f36073d389c86fa5a7c6cdde450f.tar.gz ghdl-39dacc4e3385f36073d389c86fa5a7c6cdde450f.tar.bz2 ghdl-39dacc4e3385f36073d389c86fa5a7c6cdde450f.zip |
ghdlsynth: check filename extension
Diffstat (limited to 'src/files_map.adb')
-rw-r--r-- | src/files_map.adb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/files_map.adb b/src/files_map.adb index 0693fb9db..a86809b01 100644 --- a/src/files_map.adb +++ b/src/files_map.adb @@ -536,6 +536,47 @@ package body Files_Map is Name := Get_Identifier (Filename (Separator_Pos + 1 .. Filename'Last)); end Normalize_Pathname; + function Find_Language (Filename : String) return Language_Type + is + P, E : Natural; + Ext : String (1 .. 5); + begin + P := Filename'Last; + E := Ext'Last; + loop + if P >= Filename'First + or else E < Ext'First + then + return Language_Unknown; + end if; + case Filename (P) is + when 'a' .. 'z' => + Ext (E) := Filename (P); + when 'A' .. 'Z' => + Ext (E) := Character'Val (Character'Pos (Filename (P)) + - Character'Pos ('A') + + Character'Pos ('a')); + when '.' => + if Ext (E + 1 .. Ext'Last) = "vhd" + or else Ext (E + 1 .. Ext'Last) = "vhdl" + then + return Language_Vhdl; + end if; + if Ext (E + 1 .. Ext'Last) = "v" + or else Ext (E + 1 .. Ext'Last) = "v" + or else Ext (E + 1 .. Ext'Last) = "sv" + or else Ext (E + 1 .. Ext'Last) = "svh" + then + return Language_Verilog; + end if; + when others => + return Language_Unknown; + end case; + P := P - 1; + E := E - 1; + end loop; + end Find_Language; + -- Find a source_file by DIRECTORY and NAME. -- Return NO_SOURCE_FILE_ENTRY if not already opened. function Find_Source_File (Directory : Name_Id; Name: Name_Id) |