SILICON
Toggle main menu visibility
Loading...
Searching...
No Matches
codeSyntax.hpp
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
18
#pragma once
19
20
#include <span>
21
#include <string>
22
#include <string_view>
23
24
namespace
SILICON::ui
{
25
26
enum class
CodeSyntaxStyle
{
27
Statement
,
28
Label
,
29
Conditional
,
30
Repeat
,
31
Todo
,
32
Operator
,
33
Comment
,
34
Global
,
35
Constant
,
36
Number
,
37
String
,
38
Escape
,
39
Directive
,
40
};
41
42
struct
CodeSyntaxKeywordGroup
{
43
CodeSyntaxStyle
style
;
44
std::span<const std::string_view>
words
;
45
};
46
47
struct
CodeSyntaxContainedRule
{
48
CodeSyntaxStyle
style
;
49
std::string_view
pattern
;
50
};
51
52
struct
CodeSyntaxMatchRule
{
53
CodeSyntaxStyle
style
;
54
std::string_view
pattern
;
55
std::span<const CodeSyntaxContainedRule>
containedRules
;
56
};
57
58
struct
CodeSyntaxRegionRule
{
59
CodeSyntaxStyle
style
;
60
std::string_view
startPattern
;
61
std::string_view
endPattern
;
62
std::string_view
skipPattern
;
63
std::span<const CodeSyntaxContainedRule>
containedRules
;
64
bool
multiline
;
65
};
66
67
struct
CodeIndentationContext
{
68
std::string_view
currentLine
;
69
std::span<const std::string_view>
previousNonBlankLines
;
70
int
indentWidth
;
71
};
72
73
using
CodeIndentationFunction
= std::string (*)(
const
CodeIndentationContext
&);
74
76
struct
CodeIndentation
{
77
CodeIndentationFunction
indentationFor
;
78
std::span<const std::string_view>
triggerPatterns
;
79
int
indentWidth
;
80
bool
expandPairsOnNewline
=
false
;
81
};
82
84
struct
CodeSyntax
{
85
std::span<const CodeSyntaxKeywordGroup>
keywordGroups
;
86
std::span<const CodeSyntaxMatchRule>
matchRules
;
87
std::span<const CodeSyntaxRegionRule>
regionRules
;
88
std::string_view
extraWordCharacters
;
89
const
CodeIndentation
*
indentation
;
90
};
91
92
extern
const
CodeSyntax
VERILOG_CODE_SYNTAX
;
93
extern
const
CodeSyntax
SISL_CODE_SYNTAX
;
94
95
}
// namespace SILICON::ui
SILICON::ui
Definition
actionGroups.hpp:14
SILICON::ui::CodeIndentationFunction
std::string(*)(const CodeIndentationContext &) CodeIndentationFunction
Definition
codeSyntax.hpp:73
SILICON::ui::CodeSyntaxStyle
CodeSyntaxStyle
Definition
codeSyntax.hpp:26
SILICON::ui::CodeSyntaxStyle::Escape
@ Escape
Definition
codeSyntax.hpp:38
SILICON::ui::CodeSyntaxStyle::Comment
@ Comment
Definition
codeSyntax.hpp:33
SILICON::ui::CodeSyntaxStyle::Directive
@ Directive
Definition
codeSyntax.hpp:39
SILICON::ui::CodeSyntaxStyle::String
@ String
Definition
codeSyntax.hpp:37
SILICON::ui::CodeSyntaxStyle::Statement
@ Statement
Definition
codeSyntax.hpp:27
SILICON::ui::CodeSyntaxStyle::Global
@ Global
Definition
codeSyntax.hpp:34
SILICON::ui::CodeSyntaxStyle::Repeat
@ Repeat
Definition
codeSyntax.hpp:30
SILICON::ui::CodeSyntaxStyle::Conditional
@ Conditional
Definition
codeSyntax.hpp:29
SILICON::ui::CodeSyntaxStyle::Label
@ Label
Definition
codeSyntax.hpp:28
SILICON::ui::CodeSyntaxStyle::Number
@ Number
Definition
codeSyntax.hpp:36
SILICON::ui::CodeSyntaxStyle::Todo
@ Todo
Definition
codeSyntax.hpp:31
SILICON::ui::CodeSyntaxStyle::Constant
@ Constant
Definition
codeSyntax.hpp:35
SILICON::ui::CodeSyntaxStyle::Operator
@ Operator
Definition
codeSyntax.hpp:32
SILICON::ui::SISL_CODE_SYNTAX
const CodeSyntax SISL_CODE_SYNTAX
Definition
sisl.cpp:101
SILICON::ui::VERILOG_CODE_SYNTAX
const CodeSyntax VERILOG_CODE_SYNTAX
Definition
verilog.cpp:437
SILICON::ui::CodeIndentationContext
Definition
codeSyntax.hpp:67
SILICON::ui::CodeIndentationContext::currentLine
std::string_view currentLine
Definition
codeSyntax.hpp:68
SILICON::ui::CodeIndentationContext::indentWidth
int indentWidth
Definition
codeSyntax.hpp:70
SILICON::ui::CodeIndentationContext::previousNonBlankLines
std::span< const std::string_view > previousNonBlankLines
Definition
codeSyntax.hpp:69
SILICON::ui::CodeIndentation
Definition
codeSyntax.hpp:76
SILICON::ui::CodeIndentation::indentationFor
CodeIndentationFunction indentationFor
Definition
codeSyntax.hpp:77
SILICON::ui::CodeIndentation::indentWidth
int indentWidth
Definition
codeSyntax.hpp:79
SILICON::ui::CodeIndentation::triggerPatterns
std::span< const std::string_view > triggerPatterns
Definition
codeSyntax.hpp:78
SILICON::ui::CodeIndentation::expandPairsOnNewline
bool expandPairsOnNewline
Definition
codeSyntax.hpp:80
SILICON::ui::CodeSyntaxContainedRule
Definition
codeSyntax.hpp:47
SILICON::ui::CodeSyntaxContainedRule::pattern
std::string_view pattern
Definition
codeSyntax.hpp:49
SILICON::ui::CodeSyntaxContainedRule::style
CodeSyntaxStyle style
Definition
codeSyntax.hpp:48
SILICON::ui::CodeSyntaxKeywordGroup
Definition
codeSyntax.hpp:42
SILICON::ui::CodeSyntaxKeywordGroup::style
CodeSyntaxStyle style
Definition
codeSyntax.hpp:43
SILICON::ui::CodeSyntaxKeywordGroup::words
std::span< const std::string_view > words
Definition
codeSyntax.hpp:44
SILICON::ui::CodeSyntaxMatchRule
Definition
codeSyntax.hpp:52
SILICON::ui::CodeSyntaxMatchRule::pattern
std::string_view pattern
Definition
codeSyntax.hpp:54
SILICON::ui::CodeSyntaxMatchRule::containedRules
std::span< const CodeSyntaxContainedRule > containedRules
Definition
codeSyntax.hpp:55
SILICON::ui::CodeSyntaxMatchRule::style
CodeSyntaxStyle style
Definition
codeSyntax.hpp:53
SILICON::ui::CodeSyntaxRegionRule
Definition
codeSyntax.hpp:58
SILICON::ui::CodeSyntaxRegionRule::containedRules
std::span< const CodeSyntaxContainedRule > containedRules
Definition
codeSyntax.hpp:63
SILICON::ui::CodeSyntaxRegionRule::startPattern
std::string_view startPattern
Definition
codeSyntax.hpp:60
SILICON::ui::CodeSyntaxRegionRule::endPattern
std::string_view endPattern
Definition
codeSyntax.hpp:61
SILICON::ui::CodeSyntaxRegionRule::style
CodeSyntaxStyle style
Definition
codeSyntax.hpp:59
SILICON::ui::CodeSyntaxRegionRule::skipPattern
std::string_view skipPattern
Definition
codeSyntax.hpp:62
SILICON::ui::CodeSyntaxRegionRule::multiline
bool multiline
Definition
codeSyntax.hpp:64
SILICON::ui::CodeSyntax
Definition
codeSyntax.hpp:84
SILICON::ui::CodeSyntax::indentation
const CodeIndentation * indentation
Definition
codeSyntax.hpp:89
SILICON::ui::CodeSyntax::extraWordCharacters
std::string_view extraWordCharacters
Definition
codeSyntax.hpp:88
SILICON::ui::CodeSyntax::matchRules
std::span< const CodeSyntaxMatchRule > matchRules
Definition
codeSyntax.hpp:86
SILICON::ui::CodeSyntax::keywordGroups
std::span< const CodeSyntaxKeywordGroup > keywordGroups
Definition
codeSyntax.hpp:85
SILICON::ui::CodeSyntax::regionRules
std::span< const CodeSyntaxRegionRule > regionRules
Definition
codeSyntax.hpp:87
src
ui
documents
code
codeSyntax.hpp
Generated by
1.17.0