65 QStringList reservedWordPattern;
66 QStringList unitPattern;
67 QStringList datatypePattern;
68 QStringList directivePattern;
69 QStringList functionPattern;
70 QStringList commentPattern;
74 reservedWordPattern <<
"\\babs\\b" <<
"\\baccess\\b" <<
"\\bafter\\b" <<
"\\balias\\b" <<
"\\ball\\b" <<
"\\band\\b" <<
75 "\\barchitecture\\b\\b"<<
"\\barray\\b"<<
"\\bassert\\b" <<
"\\battribute\\b"<<
76 "\\bbegin\\b\\b"<<
"\\bblock\\b"<<
"\\bbody\\b"<<
"\\bbuffer\\b"<<
"\\bbus\\b"<<
77 "\\bcase\\b"<<
"\\bcomponent\\b"<<
"\\bconfiguration\\b"<<
"\\bconstant\\b"<<
78 "\\bdisconnect\\b"<<
"\\bdownto\\b"<<
79 "\\belse\\b"<<
"\\belsif\\b"<<
"\\bend\\b"<<
"\\bentity\\b"<<
"\\bexit\\b"<<
80 "\\bfile\\b"<<
"\\bfor\\b"<<
"\\bfunction"
81 "\\bgenerate\\b"<<
"\\bgeneric\\b"<<
"\\bgroup\\b"<<
"\\bguarded"
82 "\\bif\\b"<<
"\\bimpure\\b"<<
"\\bin\\b"<<
"\\binertial\\b"<<
"\\binout\\b"<<
"\\bis\\b"<<
83 "\\blabel\\b"<<
"\\blibrary\\b"<<
"\\blinkage\\b"<<
"\\bliteral\\b"<<
"\\bloop\\b"<<
84 "\\bmap\\b"<<
"\\bmod\\b"<<
85 "\\bnand\\b"<<
"\\bnew\\b"<<
"\\bnext\\b"<<
"\\bnor\\b"<<
"\\bnot\\b"<<
"\\bnull"
86 "\\bof\\b"<<
"\\bon\\b"<<
"\\bopen\\b"<<
"\\bor\\b"<<
"\\bothers\\b"<<
"\\bout\\b"<<
87 "\\bpackage\\b"<<
"\\bport\\b"<<
"\\bpostponed\\b"<<
"\\bprocedure\\b"<<
"\\bprocess\\b"<<
"\\bpure\\b"<<
88 "\\brange\\b"<<
"\\brecord\\b"<<
"\\bregister\\b"<<
"\\breject\\b"<<
"\\brem\\b"<<
"\\breport\\b"<<
"\\breturn\\b"<<
"\\brol\\b"<<
"\\bror\\b"<<
89 "\\bselect\\b"<<
"\\bseverity\\b"<<
"\\bshared\\b"<<
"\\bsignal\\b"<<
"\\bsla\\b"<<
"\\bsll\\b"<<
"\\bsra\\b"<<
"\\bsrl\\b"<<
"\\bsubtype\\b"<<
90 "\\bthen\\b"<<
"\\bto\\b"<<
"\\btransport\\b"<<
"\\btype\\b"<<
91 "\\bunaffected\\b"<<
"\\bunits\\b"<<
"\\buntil\\b"<<
"\\buse\\b"<<
93 "\\bwait\\b"<<
"\\bwhen\\b"<<
"\\bwhile\\b"<<
"\\bwith\\b"<<
94 "\\bxnor\\b"<<
"\\bxor\\b";
96 unitPattern <<
"\\bfs\\b"<<
"\\bps\\b"<<
"\\bns\\b"<<
"\\bus\\b"<<
"\\bms\\b"<<
"\\bsec\\b"<<
"\\bmin\\b"<<
"\\bhr\\b";
98 datatypePattern <<
"\\bbit\\b"<<
"\\bbit_vector\\b"<<
"\\bboolean\\b"<<
"\\bstd_logic\\b"<<
"\\bstd_logic_vector\\b"<<
"\\bstd_ulogic\\b"<<
"\\bstd_ulogic_vector\\b"<<
"\\bsigned\\b"<<
"\\bunsigned\\b"<<
"\\binteger\\b"<<
"\\breal\\b"<<
"\\btime\\b"<<
"\\bcharacter\\b"<<
"\\bnatural\\b";
100 directivePattern <<
"\\bactive\\b"<<
"\\bascending\\b" <<
106 "\\blast_active\\b"<<
"\\blast_event\\b"<<
"\\blast_value\\b"<<
"\\bleft\\b"<<
"\\bleftof\\b"<<
"\\blength\\b"<<
"\\blow\\b" <<
107 "\\bpos\\b"<<
"\\bpred\\b"<<
109 "\\brange\\b"<<
"\\breverse_range\\b"<<
"\\bright\\b"<<
"\\brightof\\b"<<
110 "\\bstable\\b"<<
"\\bsucc\\b"<<
111 "\\btransaction\\b"<<
112 "\\bval\\b"<<
"\\bvalue\\b";
114 commentPattern <<
"--[^\n]*";
119 reservedWordPattern <<
"\\balways\\b"<<
"\\band\\b"<<
"\\bassign\\b"<<
"\\battribute\\b"<<
120 "\\bbegin\\b"<<
"\\bbuf\\b"<<
"\\bbufif0\\b"<<
"\\bbufif1\\b"<<
121 "\\bcase\\b"<<
"\\bcasex\\b"<<
"\\bcasez\\b" <<
"\\bcmos\\b"<<
122 "\\bdeassign\\b"<<
"\\bdefault\\b"<<
"\\bdefparam\\b"<<
"\\bdisable\\b"<<
123 "\\bedge\\b"<<
"\\belse\\b"<<
"\\bend\\b"<<
"\\bendattribute\\b"<<
"\\bendcase\\b"<<
"\\bendfunction\\b"<<
"\\bendmodule\\b"<<
"\\bendprimitive\\b"<<
"\\bendspecify\\b"<<
"\\bendtable\\b"<<
"\\bendtask\\b"<<
"\\bevent\\b"<<
124 "\\bfor\\b"<<
"\\bforce\\b"<<
"\\bforever\\b"<<
"\\bfork\\b"<<
"\\bfunction\\b"<<
125 "\\bhighz0\\b"<<
"\\bhighz1\\b"<<
126 "\\bif\\b"<<
"\\bifnone\\b"<<
"\\binitial\\b"<<
"\\binout\\b"<<
"\\binput\\b"<<
129 "\\bmedium\\b"<<
"\\bmodule\\b"<<
"\\bmacromodule\\b"<<
130 "\\bnand\\b"<<
"\\bnegedge\\b"<<
"\\bnmos\\b"<<
"\\bnor\\b"<<
"\\bnot\\b"<<
"\\bnotif0\\b"<<
"\\bnotif1\\b"<<
131 "\\bor\\b"<<
"\\boutput\\b"<<
132 "\\bpmos\\b"<<
"\\bposedge\\b"<<
"\\bprimitive\\b"<<
"\\bpull0\\b"<<
"\\bpull1\\b"<<
"\\bpulldown\\b"<<
"\\bpullup\\b"<<
133 "\\brcmos\\b"<<
"\\brelease\\b"<<
"\\brepeat\\b"<<
"\\brnmos\\b"<<
"\\brpmos\\b"<<
"\\brtran\\b"<<
"\\brtranif0\\b"<<
"\\brtranif1\\b"<<
134 "\\bscalared\\b"<<
"\\bsigned\\b"<<
"\\bsmall\\b"<<
"\\bspecify\\b"<<
"\\bstrength\\b"<<
"\\bstrong0\\b"<<
"\\bstrong1\\b"<<
135 "\\btable\\b"<<
"\\btask\\b"<<
"\\btran\\b"<<
"\\btranif0\\b"<<
"\\btranif1\\b"<<
138 "\\bwait\\b"<<
"\\bweak0\\b"<<
"\\bweak1\\b"<<
"\\bwhile\\b"<<
139 "\\bxnor\\b"<<
"\\bxor\\b";
141 directivePattern <<
"\\breset_all\\b"<<
"\\btimescale\\b"<<
"\\bdefine\\b"<<
"\\binclude\\b"<<
"\\bifdef\\b"<<
"\\belse\\b"<<
"\\bendif\\b"<<
142 "\\bcelldefine\\b"<<
"\\bendcelldefine\\b"<<
"\\bdefault_nettype\\b"<<
"\\bunconnected_drive\\b"<<
143 "\\bnounconnected_drive\\b"<<
"\\bdelay_mode_zero\\b"<<
"\\bdelay_mode_unit\\b"<<
144 "\\bdelay_mode_path\\b"<<
"\\bdelay_mode_distributed\\b"<<
"\\buselib\\b";
146 datatypePattern <<
"\\breg\\b"<<
"\\binteger\\b"<<
"\\btime\\b"<<
"\\breal\\b"<<
"\\brealtime\\b"<<
"\\bwire\\b"<<
"\\btri\\b"<<
"\\bwor\\b"<<
147 "\\btrior\\b"<<
"\\bwand\\b"<<
"\\btriand\\b"<<
"\\btri0\\b"<<
"\\btri1\\b"<<
"\\bsupply0\\b"<<
"\\bsupply1\\b"<<
"\\btrireg\\b"<<
148 "\\bparameter\\b"<<
"\\bspecparam\\b"<<
"\\bevent\\b";
150 functionPattern <<
"\\bsetup\\b"<<
"\\bhold\\b"<<
"\\bsetuphold\\b"<<
"\\bskew\\b"<<
"\\brecovery\\b"<<
"\\bperiod\\b"<<
"\\bwidth\\b"<<
151 "\\bmonitor\\b"<<
"\\bdisplay\\b"<<
"\\bwrite\\b"<<
"\\bstrobe\\b"<<
"\\bfopen\\b"<<
"\\bfclose\\b"<<
"\\btime\\b"<<
152 "\\bstime\\b"<<
"\\brealtime\\b"<<
"\\btimeformat\\b"<<
"\\bprinttimescale\\b"<<
"\\brandom\\b"<<
"\\breadmemb\\b"<<
153 "\\breadmemh\\b"<<
"\\bfinish\\b"<<
"\\bstop\\b";
155 commentPattern <<
"//[^\n]*";
161 reservedWordPattern <<
"\\babstol\\b"<<
"\\baccess\\b"<<
"\\banalog\\b"<<
"\\bac_stim\\b"<<
"\\banalysis\\b"<<
162 "\\bbegin\\b"<<
"\\bbranch\\b"<<
"\\bbound_step\\b"<<
164 "\\bdiscipline\\b"<<
"\\bddt_nature\\b"<<
"\\bddt\\b"<<
"\\bdelay\\b"<<
"\\bdiscontinuity\\b"<<
"\\bdefault\\b"<<
165 "\\benddiscipline\\b"<<
"\\belse\\b"<<
"\\bend\\b"<<
"\\bendnature\\b"<<
"\\bexclude\\b"<<
"\\bendfunction\\b"<<
"\\bendmodule\\b"<<
"\\belectrical\\b"<<
"\\bendcase\\b"<<
166 "\\bfor\\b"<<
"\\bflow\\b"<<
"\\bfrom\\b"<<
"\\bfinal_step\\b"<<
"\\bflicker_noise\\b"<<
"\\bfunction\\b"<<
167 "\\bgenerate\\b"<<
"\\bground\\b"<<
168 "\\bif\\b"<<
"\\bidt_nature\\b"<<
"\\binf\\b"<<
"\\bidt\\b"<<
"\\binitial_step\\b"<<
"\\binput\\b"<<
"\\binout\\b"<<
169 "\\blaplace_nd\\b"<<
"\\blaplace_np\\b"<<
"\\blaplace_zd\\b"<<
"\\blaplace_zp\\b"<<
"\\blast_crossing\\b"<<
171 "\\bnature\\b"<<
"\\bnoise_table\\b"<<
172 "\\bpotential\\b"<<
"\\bparameter\\b"<<
174 "\\btimer\\b"<<
"\\btransition\\b"<<
176 "\\bwhite_noise\\b"<<
"\\bwhile\\b"<<
177 "\\bzi_nd\\b"<<
"\\bzi_np\\b"<<
"\\bzi_zd\\b"<<
"\\bzi_zp\\b";
179 unitPattern <<
"\\bT\\b"<<
"\\bG\\b"<<
"\\bM\\b"<<
"\\bK\\b"<<
"\\bm\\b"<<
"\\bu\\b"<<
"\\bn\\b"<<
"\\bp\\b"<<
"\\bf\\b"<<
"\\ba\\b";
181 datatypePattern <<
"\\binteger\\b"<<
"\\breal\\b";
183 directivePattern <<
"\\bdefine\\b"<<
"\\belse\\b"<<
"\\bundef\\b"<<
"\\bifdef\\b"<<
"\\bendif\\b"<<
"\\binclude\\b"<<
"\\bresetall\\b";
185 functionPattern <<
"\\brealtime\\b"<<
"\\btemperature\\b"<<
"\\bvt\\b"<<
"\\bdisplay\\b"<<
"\\bstrobe\\b";
187 commentPattern <<
"//[^\n]*";
192 reservedWordPattern <<
"\\bcase\\b"<<
"\\bcatch\\b"<<
193 "\\belse\\b"<<
"\\belseif\\b"<<
"\\bend\\b"<<
"\\bendfor\\b"<<
"\\bendfunction\\b"<<
"\\bendif\\b"<<
"\\bendswitch\\b"<<
"\\bend_try_catch\\b"<<
"\\bendwhile\\b"<<
"\\bend_unwind_protect\\b"
194 "\\bfor\\b" <<
"\\bfunction\\b" <<
199 "\\bunwind_protect\\b"<<
"\\bunwind_protect_cleanup\\b" <<
202 datatypePattern <<
"\\binf\\b"<<
"\\bnan\\b"<<
"\\bpi\\b";
204 functionPattern <<
"\\bplot\\b";
206 commentPattern <<
"//[^\n]*";
211 foreach (
const QString &pattern, reservedWordPattern) {
212 rule.
pattern = QRegExp(pattern);
217 foreach (
const QString &pattern, unitPattern) {
218 rule.
pattern = QRegExp(pattern);
223 foreach (
const QString &pattern, datatypePattern) {
224 rule.
pattern = QRegExp(pattern);
229 foreach (
const QString &pattern, directivePattern) {
230 rule.
pattern = QRegExp(pattern);
235 foreach (
const QString &pattern, functionPattern) {
236 rule.
pattern = QRegExp(pattern);
241 foreach (
const QString &pattern, commentPattern) {
242 rule.
pattern = QRegExp(pattern);
253 QRegExp expression(rule.
pattern);
254 int index = expression.indexIn(text);
256 int length = expression.matchedLength();
257 setFormat(index, length, rule.
format);
258 index = expression.indexIn(text, index + length);
Definition of the TextDoc class.
QTextCharFormat unitFormat
QTextCharFormat functionFormat
QVector< HighlightingRule > highlightingRules
QTextCharFormat commentFormat
The TextDoc class definition.
void highlightBlock(const QString &)
QTextCharFormat reservedWordFormat
QTextCharFormat directiveFormat
SyntaxHighlighter(TextDoc *)
virtual ~SyntaxHighlighter()
QTextCharFormat datatypeFormat