1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
from highlighter.common import *
keywords = [
"assign", "backspace", "block ""data", "call", "close", "common",
"continue", "data", "dimension", "do", "else", "else ""if", "end",
"endfile", "endif", "entry", "equivalence", "external", "format",
"function", "goto", "if", "implicit", "inquire", "intrinsic", "open",
"parameter", "pause", "print", "program", "read", "return", "rewind",
"rewrite", "save", "stop", "subroutine", "then", "write"
"allocatable", "allocate", "case", "contains", "cycle", "deallocate",
"elsewhere", "exit", "include", "interface", "intent", "module",
"namelist", "nullify", "only", "operator", "optional", "pointer",
"private", "procedure", "public", "recursive", "result", "select",
"sequence", "target", "use", "while", "where"
]
hl_cont_line = simple(r"\\\n", tag=tag_type)
hl_strings = region_template(
matchall=False, tag=tag_string,
highlighter=(hl_cont_line, hl_inside_strings)
)
register_highlighter(
language="fortran 90",
spec=(
# Match comments lines
region(r"!", "\n", tag=tag_comment, highlighter=(hl_comment_notes,)),
# Match string literals
hl_strings(r"'", r"'|[^\\]$"),
hl_strings(r'"', r'"|[^\\]$'),
region(
r"'", r"'|[^\\]$", matchall=False, tag=tag_string,
highlighter=(hl_cont_line, hl_inside_strings)
),
words(keywords, tag=tag_keyword),
),
igncase=True
)
|