SILICON
Loading...
Searching...
No Matches
codeFilePresentation.cpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2026. Giulio Cocconi
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
19
20#include <array>
21#include <ranges>
22#include <stdexcept>
23
24namespace SILICON::ui {
25namespace {
26
27 constexpr std::array PRESENTATIONS{
29 .displayName = "Verilog",
30 .syntax = &VERILOG_CODE_SYNTAX,
31 .architectureTabName = nullptr},
33 .displayName = "SISL",
34 .syntax = &SISL_CODE_SYNTAX,
35 .architectureTabName = "Instruction format"}};
36
37} // namespace
38
39std::span<const CodeFilePresentation> codeFilePresentations()
40{
41 return PRESENTATIONS;
42}
43
45{
46 const auto it = std::ranges::find(PRESENTATIONS, type, &CodeFilePresentation::type);
47 if (it == PRESENTATIONS.end())
48 throw std::invalid_argument("Unknown code-file presentation");
49 return *it;
50}
51
52} // namespace SILICON::ui
const CodeFilePresentation & codeFilePresentation(const project::DocumentType type)
std::span< const CodeFilePresentation > codeFilePresentations()
const CodeSyntax SISL_CODE_SYNTAX
Definition sisl.cpp:101
const CodeSyntax VERILOG_CODE_SYNTAX
Definition verilog.cpp:437
SILICON::project::DocumentType type