24 #include <qsyntaxhighlighter.h>
31 : QSyntaxHighlighter(textEdit)
52 int iString=-1, iWord=-1, iNumber=-1, iExpo=-1,
i=0, iComment=-1;
54 font.setPointSize((
int)Doc->
Scale);
55 setFormat(0, text.length(), font, QPen::black);
62 for(c = text.at(
i); !c.isNull(); c = text.at(++
i)) {
66 if (
i > 0 && c ==
')' && text.at (
i-1) ==
'*') {
74 else if(iString >= 0) {
85 if(c.isLetterOrNumber())
91 if(text.at(iWord-1) ==
'\'') {
92 markAttribute(text, iWord,
i-iWord);
95 markWord(text, iWord,
i-iWord);
100 else if(iNumber >= 0) {
113 if((c ==
'e') || (c ==
'E')) {
122 if((c ==
'-') || (c ==
'+')) {
136 else if(language ==
LANG_VHDL && c ==
'-') {
138 if(text.at(
i-1) ==
'-') {
148 if(text.at(
i-1) ==
'/') {
155 else if((language ==
LANG_OCTAVE) && (c ==
'%' || c ==
'#')) {
162 && c ==
'`' && text.at(
i+1).isLetter())
165 && c ==
'$' && text.at(
i+1).isLetter())
167 else if(c.isLetter())
169 else if(c.isNumber()) {
182 if(text.at(
i-2) ==
'\'')
185 else if(c ==
'"' || (c ==
'\'' && language ==
LANG_OCTAVE))
189 &&
i > 0 && c ==
'*' && text.at(
i-1) ==
'(') {
206 "architecture",
"array",
"assert",
"attribute", 0};
221 "return",
"rol",
"ror", 0};
223 "sra",
"srl",
"subtype", 0};
242 {
"fs",
"ps",
"ns",
"us",
"ms",
"sec",
"min",
"hr", 0};
245 "bit",
"bit_vector",
"boolean",
"std_logic",
"std_logic_vector",
246 "std_ulogic",
"std_ulogic_vector",
"signed",
"unsigned",
"integer",
247 "real",
"time",
"character",
"natural", 0};
256 "endfunction",
"endmodule",
"endprimitive",
"endspecify",
257 "endtable",
"endtask",
"event", 0};
268 "pulldown",
"pullup", 0};
270 "rnmos",
"rpmos",
"rtran",
"rtranif0",
"rtranif1", 0};
272 "strong0",
"strong1", 0};
289 {
"reset_all",
"timescale",
"define",
"include",
"ifdef",
"else",
"endif",
290 "celldefine",
"endcelldefine",
"default_nettype",
"unconnected_drive",
291 "nounconnected_drive",
"delay_mode_zero",
"delay_mode_unit",
292 "delay_mode_path",
"delay_mode_distributed",
"uselib", 0};
295 "reg",
"integer",
"time",
"real",
"realtime",
"wire",
"tri",
"wor",
296 "trior",
"wand",
"triand",
"tri0",
"tri1",
"supply0",
"supply1",
"trireg",
297 "parameter",
"specparam",
"event", 0};
300 {
"setup",
"hold",
"setuphold",
"skew",
"recovery",
"period",
"width",
301 "monitor",
"display",
"write",
"strobe",
"fopen",
"fclose",
"time",
302 "stime",
"realtime",
"timeformat",
"printtimescale",
"random",
"readmemb",
303 "readmemh",
"finish",
"stop", 0};
311 "discontinuity",
"default", 0 };
313 "endfunction",
"endmodule",
"electrical",
"endcase", 0};
318 "input",
"inout", 0};
342 {
"T",
"G",
"M",
"K",
"m",
"u",
"n",
"p",
"f",
"a", 0};
345 {
"define",
"else",
"undef",
"ifdef",
"endif",
"include",
"resetall", 0};
348 "integer",
"real", 0};
351 {
"realtime",
"temperature",
"vt",
"display",
"strobe", 0};
357 "endif",
"endswitch",
"end_try_catch",
"endwhile",
358 "end_unwind_protect", 0};
368 {0, 0, (
ppChar)&OCT_List_C,
372 0, 0, (
ppChar)&OCT_List_O,
375 0, (
ppChar)&OCT_List_W, 0,
379 "inf",
"nan",
"pi", 0};
385 void SyntaxHighlighter::markWord(
const QString& text,
int start,
int len)
390 newFont.setPointSize((
int)Doc->
Scale);
393 QString Word = text.mid(start, len);
405 int idx = (int)(Word.at(0).latin1() -
'a');
406 if(idx >= 0 && idx <= 25) {
417 List = OCT_WordList[idx];
420 List = VA_WordList[idx];;
426 for( ; *List != 0; List++)
428 newFont.setWeight(QFont::Bold);
429 setFormat(start, len, newFont);
450 for( ; *List != 0; List++)
469 for( ; *List != 0; List++)
471 newFont.setWeight(QFont::Bold);
477 if (Word.at(0) ==
'`' || Word.at(0) ==
'$') {
492 for( ; *List != 0; List++)
494 newFont.setWeight(QFont::Bold);
515 for( ; *List != 0; List++)
517 newFont.setWeight(QFont::Bold);
533 "leftof",
"length",
"low", 0};
545 0, 0, (
ppChar)&VHD_List_Attrib_L, 0, 0, 0,
550 void SyntaxHighlighter::markAttribute(
const QString& text,
int start,
int len)
552 QString Word = text.mid(start, len).lower();
553 int idx = (int)(Word.at(0).latin1() -
'a');
554 if(idx < 0 || idx > 22)
556 pChar *List = VHD_Attribute_List[idx];
559 for(; *List != 0; List++)