2 Inform syntax highlighting.
7 from pygments.lexer import RegexLexer
8 from pygments.token import (Text, Comment, Operator, Keyword, Name,
9 String, Number, Punctuation, Token)
11 objects = ["Class", "Nearby", "Object"]
13 directives = ["Abbreviate", "Array", "Attribute", "Btrace", "Class",
14 "Constant", "Default", "Dictionary", "End", "Endif", "Etrace",
15 "Extend", "Fake_action", "Global", "Ifdef", "Iffalse",
16 "Ifndef", "Ifnot", "Iftrue", "Ifv3", "Ifv5", "Import",
17 "Include", "Link", "Listsymbols", "Listdict", "Listverbs",
18 "Lowstring", "Ltrace", "Message", "Nearby", "Nobtrace",
19 "Noetrace", "Noltrace", "Notrace", "Object", "Property",
20 "Release", "Replace", "Serial", "Statusline", "Stub",
21 "Switches", "System_file", "Trace", "Verb", "Version",
24 defining = ["[", "array", "attribute", "class", "constant", "fake_action",
25 "global", "lowstring", "nearby", "object", "property"]
27 attributes = ["absent", "animate", "clothing", "concealed", "container",
28 "door", "edible", "enterable", "female", "general", "light",
29 "lockable", "locked", "male", "moved", "neuter", "on", "open",
30 "openable", "pluralname", "proper", "scenery", "scored",
31 "static", "supporter", "switchable", "talkable", "transparent",
32 "visited", "workflag", "worn"]
34 properties = ["n_to", "s_to", "e_to", "w_to", "ne_to", "se_to", "nw_to",
35 "sw_to", "u_to", "d_to", "in_to", "out_to", "add_to_scope",
36 "after", "article", "articles", "before", "cant_go", "capacity",
37 "daemon", "describe", "description", "door_dir", "door_to",
38 "each_turn", "found_in", "grammar", "initial",
39 "inside_description", "invent", "life", "list_together",
40 "name", "number", "orders", "parse_name", "plural",
41 "react_after", "react_before", "short_name", "short_name_indef",
42 "time_left", "time_out", "when_closed", "when_open", "when_on",
43 "when_off", "with_key"]
45 keywords = ["box", "break", "continue", "do", "else", "font off", "font on",
46 "for", "give", "has", "hasnt", "if", "in", "inversion", "jump",
47 "move", "new_line", "notin", "objectloop", "ofclass", "or",
48 "print", "print_ret", "provides", "quit", "read", "remove",
49 "restore", "return", "rfalse", "rtrue", "save", "spaces",
50 "string", "style bold", "style fixed", "style reverse",
51 "style roman", "style underline", "switch", "to", "until",
57 return "(" + "|".join(list) + r")\b"
59 class InformLexer(RegexLexer):
67 mimetypes = ['text/x-inform', 'application/x-inform']
73 (r'!.*$', Comment.Single),
77 (r'"[^"]*"', String.Double),
78 (r"'[^']*'", String.Single),
79 (r"\S+:", Name.Label),
80 (r"<<.+>>", Name.Label),
82 (wordlist(objects), Name.Class),
83 (wordlist(keywords), Token.Keyword.Reserved),
84 (wordlist(properties), Name.Builtin),
85 (wordlist(directives), Name.Entity),
86 (wordlist(attributes), Name.Attribute),
88 (r'[a-zA-Z_][a-zA-Z0-9_.]*', Name),
89 (r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
90 (r'\d+', Number.Integer),