state fortran_string extends Highlight
{
/[\']/ {
language_print ($0);
debug ("Finishing fortran_string state.");
return;
}
}
state fortran_io extends Highlight
{
/\(/ {
language_print ($0);
parentheses_level++;
debug (concat("Parenthesis_level = ",string(parentheses_level)));
}
/\)/ {
language_print ($0);
parentheses_level--;
debug (concat("Parenthesis_level = ",string(parentheses_level)));
if (parentheses_level == 0) {
debug ("Finishing fortran_io state.");
return;
}
}
/\b(ACCESS|BLANK|DIRECT|E(ND|RR|XIST)|F(ILE|MT|ORM(|ATTED))|IOSTAT\
|N(AMED?|EXTREC|UMBER)|OPENED|REC(|L)|S(EQUENTIAL|TATUS)\
|UN(FORMATTED|IT))\b/i {
debug (concat("This is an io specifier: ",$0));
builtin_face (true);
language_print ($0);
builtin_face (false);
}
/[\']/ {
debug ("String in io statement found.");
string_face (true);
language_print ($0);
call (fortran_string);
string_face (false);
}
}
state fortran extends HighlightEntry
{
BEGIN {
parentheses_level = 0;
debug ("Starting fortran state.");
}
END {
debug ("Finishing fortran state.");
}
/^[cC\*]/ {
debug ("Comment line found.");
comment_face (true);
language_print ($0);
call (eat_one_line);
comment_face (false);
}
/[\']/ {
debug ("String constant found.");
string_face (true);
language_print ($0);
call (fortran_string);
string_face (false);
}
/\.(AND|EQV?|G(E|T)|L(E|T)|NE(QV)?|NOT|OR)\./i {
debug (concat("This is an rel/log operator: ",$0));
builtin_face (true);
language_print ($0);
builtin_face (false);
}
/\b(BACKSPACE|CLOSE|ENDFILE|INQUIRE|OPEN|PRINT|RE(AD|WIND)|WRITE)(\(?)/i {
debug (concat("This is an io statement: ",$1));
keyword_face (true);
language_print ($1);
keyword_face (false);
if (strcmp ($3, "") != 0) {
language_print ($3);
parentheses_level=1;
call (fortran_io);
}
}
/\b((CHARACTER|COMPLEX|INTEGER|LOGICAL|REAL)(\*([0-9]+|\())?\
|(DOUBLE *PRECISION))( *\(?[a-zA-Z0-9]+)/i {
debug (concat("This is a type statement: ",$2,$5));
type_face (true);
language_print ($2);
language_print ($5);
type_face (false);
language_print ($3);
next_word = $6;
if (regmatch (next_word, / *FUNCTION/i)) {
debug ("... for a function");
keyword_face (true);
language_print (next_word);
keyword_face (false);
} else {
language_print (next_word);
}
}
/\b(ASSIGN|BLOCK \*DATA|C(ALL|O(MMON|NTINUE))|D(ATA|IMENSION|O)\
|E(LSE(| \*IF)|N(D(| \*IF)|TRY)|QUIVALENCE|XTERNAL)|F(ORMAT|UNCTION)\
|GO \*TO|I(F|MPLICIT|N(CLUDE|TRINSIC))|P(A(RAMETER|USE)|ROGRAM)|RETURN\
|S(AVE|TOP|UBROUTINE)|THEN)\b/i {
debug (concat("Other keyword found: ",$0));
keyword_face (true);
language_print ($0);
keyword_face (false);
}
}