Back to index

moin  1.9.0~rc2
other.py
Go to the documentation of this file.
00001 # -*- coding: utf-8 -*-
00002 """
00003     pygments.lexers.other
00004     ~~~~~~~~~~~~~~~~~~~~~
00005 
00006     Lexers for other languages.
00007 
00008     :copyright: Copyright 2006-2009 by the Pygments team, see AUTHORS.
00009     :license: BSD, see LICENSE for details.
00010 """
00011 
00012 import re
00013 
00014 from pygments.lexer import Lexer, RegexLexer, include, bygroups, using, \
00015      this, do_insertions
00016 from pygments.token import Error, Punctuation, \
00017      Text, Comment, Operator, Keyword, Name, String, Number, Generic
00018 from pygments.util import shebang_matches
00019 from pygments.lexers.web import HtmlLexer
00020 
00021 
00022 __all__ = ['SqlLexer', 'MySqlLexer', 'SqliteConsoleLexer', 'BrainfuckLexer',
00023            'BashLexer', 'BatchLexer', 'BefungeLexer', 'RedcodeLexer',
00024            'MOOCodeLexer', 'SmalltalkLexer', 'TcshLexer', 'LogtalkLexer',
00025            'GnuplotLexer', 'PovrayLexer', 'AppleScriptLexer',
00026            'BashSessionLexer', 'ModelicaLexer', 'RebolLexer', 'ABAPLexer',
00027            'NewspeakLexer']
00028 
00029 line_re  = re.compile('.*?\n')
00030 
00031 
00032 class SqlLexer(RegexLexer):
00033     """
00034     Lexer for Structured Query Language. Currently, this lexer does
00035     not recognize any special syntax except ANSI SQL.
00036     """
00037 
00038     name = 'SQL'
00039     aliases = ['sql']
00040     filenames = ['*.sql']
00041     mimetypes = ['text/x-sql']
00042 
00043     flags = re.IGNORECASE
00044     tokens = {
00045         'root': [
00046             (r'\s+', Text),
00047             (r'--.*?\n', Comment.Single),
00048             (r'/\*', Comment.Multiline, 'multiline-comments'),
00049             (r'(ABORT|ABS|ABSOLUTE|ACCESS|ADA|ADD|ADMIN|AFTER|AGGREGATE|'
00050              r'ALIAS|ALL|ALLOCATE|ALTER|ANALYSE|ANALYZE|AND|ANY|ARE|AS|'
00051              r'ASC|ASENSITIVE|ASSERTION|ASSIGNMENT|ASYMMETRIC|AT|ATOMIC|'
00052              r'AUTHORIZATION|AVG|BACKWARD|BEFORE|BEGIN|BETWEEN|BITVAR|'
00053              r'BIT_LENGTH|BOTH|BREADTH|BY|C|CACHE|CALL|CALLED|CARDINALITY|'
00054              r'CASCADE|CASCADED|CASE|CAST|CATALOG|CATALOG_NAME|CHAIN|'
00055              r'CHARACTERISTICS|CHARACTER_LENGTH|CHARACTER_SET_CATALOG|'
00056              r'CHARACTER_SET_NAME|CHARACTER_SET_SCHEMA|CHAR_LENGTH|CHECK|'
00057              r'CHECKED|CHECKPOINT|CLASS|CLASS_ORIGIN|CLOB|CLOSE|CLUSTER|'
00058              r'COALSECE|COBOL|COLLATE|COLLATION|COLLATION_CATALOG|'
00059              r'COLLATION_NAME|COLLATION_SCHEMA|COLUMN|COLUMN_NAME|'
00060              r'COMMAND_FUNCTION|COMMAND_FUNCTION_CODE|COMMENT|COMMIT|'
00061              r'COMMITTED|COMPLETION|CONDITION_NUMBER|CONNECT|CONNECTION|'
00062              r'CONNECTION_NAME|CONSTRAINT|CONSTRAINTS|CONSTRAINT_CATALOG|'
00063              r'CONSTRAINT_NAME|CONSTRAINT_SCHEMA|CONSTRUCTOR|CONTAINS|'
00064              r'CONTINUE|CONVERSION|CONVERT|COPY|CORRESPONTING|COUNT|'
00065              r'CREATE|CREATEDB|CREATEUSER|CROSS|CUBE|CURRENT|CURRENT_DATE|'
00066              r'CURRENT_PATH|CURRENT_ROLE|CURRENT_TIME|CURRENT_TIMESTAMP|'
00067              r'CURRENT_USER|CURSOR|CURSOR_NAME|CYCLE|DATA|DATABASE|'
00068              r'DATETIME_INTERVAL_CODE|DATETIME_INTERVAL_PRECISION|DAY|'
00069              r'DEALLOCATE|DECLARE|DEFAULT|DEFAULTS|DEFERRABLE|DEFERRED|'
00070              r'DEFINED|DEFINER|DELETE|DELIMITER|DELIMITERS|DEREF|DESC|'
00071              r'DESCRIBE|DESCRIPTOR|DESTROY|DESTRUCTOR|DETERMINISTIC|'
00072              r'DIAGNOSTICS|DICTIONARY|DISCONNECT|DISPATCH|DISTINCT|DO|'
00073              r'DOMAIN|DROP|DYNAMIC|DYNAMIC_FUNCTION|DYNAMIC_FUNCTION_CODE|'
00074              r'EACH|ELSE|ENCODING|ENCRYPTED|END|END-EXEC|EQUALS|ESCAPE|EVERY|'
00075              r'EXCEPT|ESCEPTION|EXCLUDING|EXCLUSIVE|EXEC|EXECUTE|EXISTING|'
00076              r'EXISTS|EXPLAIN|EXTERNAL|EXTRACT|FALSE|FETCH|FINAL|FIRST|FOR|'
00077              r'FORCE|FOREIGN|FORTRAN|FORWARD|FOUND|FREE|FREEZE|FROM|FULL|'
00078              r'FUNCTION|G|GENERAL|GENERATED|GET|GLOBAL|GO|GOTO|GRANT|GRANTED|'
00079              r'GROUP|GROUPING|HANDLER|HAVING|HIERARCHY|HOLD|HOST|IDENTITY|'
00080              r'IGNORE|ILIKE|IMMEDIATE|IMMUTABLE|IMPLEMENTATION|IMPLICIT|IN|'
00081              r'INCLUDING|INCREMENT|INDEX|INDITCATOR|INFIX|INHERITS|INITIALIZE|'
00082              r'INITIALLY|INNER|INOUT|INPUT|INSENSITIVE|INSERT|INSTANTIABLE|'
00083              r'INSTEAD|INTERSECT|INTO|INVOKER|IS|ISNULL|ISOLATION|ITERATE|JOIN|'
00084              r'KEY|KEY_MEMBER|KEY_TYPE|LANCOMPILER|LANGUAGE|LARGE|LAST|'
00085              r'LATERAL|LEADING|LEFT|LENGTH|LESS|LEVEL|LIKE|LIMIT|LISTEN|LOAD|'
00086              r'LOCAL|LOCALTIME|LOCALTIMESTAMP|LOCATION|LOCATOR|LOCK|LOWER|'
00087              r'MAP|MATCH|MAX|MAXVALUE|MESSAGE_LENGTH|MESSAGE_OCTET_LENGTH|'
00088              r'MESSAGE_TEXT|METHOD|MIN|MINUTE|MINVALUE|MOD|MODE|MODIFIES|'
00089              r'MODIFY|MONTH|MORE|MOVE|MUMPS|NAMES|NATIONAL|NATURAL|NCHAR|'
00090              r'NCLOB|NEW|NEXT|NO|NOCREATEDB|NOCREATEUSER|NONE|NOT|NOTHING|'
00091              r'NOTIFY|NOTNULL|NULL|NULLABLE|NULLIF|OBJECT|OCTET_LENGTH|OF|OFF|'
00092              r'OFFSET|OIDS|OLD|ON|ONLY|OPEN|OPERATION|OPERATOR|OPTION|OPTIONS|'
00093              r'OR|ORDER|ORDINALITY|OUT|OUTER|OUTPUT|OVERLAPS|OVERLAY|OVERRIDING|'
00094              r'OWNER|PAD|PARAMETER|PARAMETERS|PARAMETER_MODE|PARAMATER_NAME|'
00095              r'PARAMATER_ORDINAL_POSITION|PARAMETER_SPECIFIC_CATALOG|'
00096              r'PARAMETER_SPECIFIC_NAME|PARAMATER_SPECIFIC_SCHEMA|PARTIAL|'
00097              r'PASCAL|PENDANT|PLACING|PLI|POSITION|POSTFIX|PRECISION|PREFIX|'
00098              r'PREORDER|PREPARE|PRESERVE|PRIMARY|PRIOR|PRIVILEGES|PROCEDURAL|'
00099              r'PROCEDURE|PUBLIC|READ|READS|RECHECK|RECURSIVE|REF|REFERENCES|'
00100              r'REFERENCING|REINDEX|RELATIVE|RENAME|REPEATABLE|REPLACE|RESET|'
00101              r'RESTART|RESTRICT|RESULT|RETURN|RETURNED_LENGTH|'
00102              r'RETURNED_OCTET_LENGTH|RETURNED_SQLSTATE|RETURNS|REVOKE|RIGHT|'
00103              r'ROLE|ROLLBACK|ROLLUP|ROUTINE|ROUTINE_CATALOG|ROUTINE_NAME|'
00104              r'ROUTINE_SCHEMA|ROW|ROWS|ROW_COUNT|RULE|SAVE_POINT|SCALE|SCHEMA|'
00105              r'SCHEMA_NAME|SCOPE|SCROLL|SEARCH|SECOND|SECURITY|SELECT|SELF|'
00106              r'SENSITIVE|SERIALIZABLE|SERVER_NAME|SESSION|SESSION_USER|SET|'
00107              r'SETOF|SETS|SHARE|SHOW|SIMILAR|SIMPLE|SIZE|SOME|SOURCE|SPACE|'
00108              r'SPECIFIC|SPECIFICTYPE|SPECIFIC_NAME|SQL|SQLCODE|SQLERROR|'
00109              r'SQLEXCEPTION|SQLSTATE|SQLWARNINIG|STABLE|START|STATE|STATEMENT|'
00110              r'STATIC|STATISTICS|STDIN|STDOUT|STORAGE|STRICT|STRUCTURE|STYPE|'
00111              r'SUBCLASS_ORIGIN|SUBLIST|SUBSTRING|SUM|SYMMETRIC|SYSID|SYSTEM|'
00112              r'SYSTEM_USER|TABLE|TABLE_NAME| TEMP|TEMPLATE|TEMPORARY|TERMINATE|'
00113              r'THAN|THEN|TIMESTAMP|TIMEZONE_HOUR|TIMEZONE_MINUTE|TO|TOAST|'
00114              r'TRAILING|TRANSATION|TRANSACTIONS_COMMITTED|'
00115              r'TRANSACTIONS_ROLLED_BACK|TRANSATION_ACTIVE|TRANSFORM|'
00116              r'TRANSFORMS|TRANSLATE|TRANSLATION|TREAT|TRIGGER|TRIGGER_CATALOG|'
00117              r'TRIGGER_NAME|TRIGGER_SCHEMA|TRIM|TRUE|TRUNCATE|TRUSTED|TYPE|'
00118              r'UNCOMMITTED|UNDER|UNENCRYPTED|UNION|UNIQUE|UNKNOWN|UNLISTEN|'
00119              r'UNNAMED|UNNEST|UNTIL|UPDATE|UPPER|USAGE|USER|'
00120              r'USER_DEFINED_TYPE_CATALOG|USER_DEFINED_TYPE_NAME|'
00121              r'USER_DEFINED_TYPE_SCHEMA|USING|VACUUM|VALID|VALIDATOR|VALUES|'
00122              r'VARIABLE|VERBOSE|VERSION|VIEW|VOLATILE|WHEN|WHENEVER|WHERE|'
00123              r'WITH|WITHOUT|WORK|WRITE|YEAR|ZONE)\b', Keyword),
00124             (r'(ARRAY|BIGINT|BINARY|BIT|BLOB|BOOLEAN|CHAR|CHARACTER|DATE|'
00125              r'DEC|DECIMAL|FLOAT|INT|INTEGER|INTERVAL|NUMBER|NUMERIC|REAL|'
00126              r'SERIAL|SMALLINT|VARCHAR|VARYING|INT8|SERIAL8|TEXT)\b',
00127              Name.Builtin),
00128             (r'[+*/<>=~!@#%^&|`?^-]', Operator),
00129             (r'[0-9]+', Number.Integer),
00130             # TODO: Backslash escapes?
00131             (r"'(''|[^'])*'", String.Single),
00132             (r'"(""|[^"])*"', String.Symbol), # not a real string literal in ANSI SQL
00133             (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
00134             (r'[;:()\[\],\.]', Punctuation)
00135         ],
00136         'multiline-comments': [
00137             (r'/\*', Comment.Multiline, 'multiline-comments'),
00138             (r'\*/', Comment.Multiline, '#pop'),
00139             (r'[^/\*]+', Comment.Multiline),
00140             (r'[/*]', Comment.Multiline)
00141         ]
00142     }
00143 
00144 
00145 class MySqlLexer(RegexLexer):
00146     """
00147     Special lexer for MySQL.
00148     """
00149 
00150     name = 'MySQL'
00151     aliases = ['mysql']
00152     mimetypes = ['text/x-mysql']
00153 
00154     flags = re.IGNORECASE
00155     tokens = {
00156         'root': [
00157             (r'\s+', Text),
00158             (r'(#|--\s+).*?\n', Comment.Single),
00159             (r'/\*', Comment.Multiline, 'multiline-comments'),
00160             (r'[0-9]+', Number.Integer),
00161             (r'[0-9]*\.[0-9]+(e[+-][0-9]+)', Number.Float),
00162             # TODO: add backslash escapes
00163             (r"'(''|[^'])*'", String.Single),
00164             (r'"(""|[^"])*"', String.Double),
00165             (r"`(``|[^`])*`", String.Symbol),
00166             (r'[+*/<>=~!@#%^&|`?^-]', Operator),
00167             (r'\b(tinyint|smallint|mediumint|int|integer|bigint|date|'
00168              r'datetime|time|bit|bool|tinytext|mediumtext|longtext|text|'
00169              r'tinyblob|mediumblob|longblob|blob|float|double|double\s+'
00170              r'precision|real|numeric|dec|decimal|timestamp|year|char|'
00171              r'varchar|varbinary|varcharacter|enum|set)(\b\s*)(\()?',
00172              bygroups(Keyword.Type, Text, Punctuation)),
00173             (r'\b(add|all|alter|analyze|and|as|asc|asensitive|before|between|'
00174              r'bigint|binary|blob|both|by|call|cascade|case|change|char|'
00175              r'character|check|collate|column|condition|constraint|continue|'
00176              r'convert|create|cross|current_date|current_time|'
00177              r'current_timestamp|current_user|cursor|database|databases|'
00178              r'day_hour|day_microsecond|day_minute|day_second|dec|decimal|'
00179              r'declare|default|delayed|delete|desc|describe|deterministic|'
00180              r'distinct|distinctrow|div|double|drop|dual|each|else|elseif|'
00181              r'enclosed|escaped|exists|exit|explain|fetch|float|float4|float8'
00182              r'|for|force|foreign|from|fulltext|grant|group|having|'
00183              r'high_priority|hour_microsecond|hour_minute|hour_second|if|'
00184              r'ignore|in|index|infile|inner|inout|insensitive|insert|int|'
00185              r'int1|int2|int3|int4|int8|integer|interval|into|is|iterate|'
00186              r'join|key|keys|kill|leading|leave|left|like|limit|lines|load|'
00187              r'localtime|localtimestamp|lock|long|loop|low_priority|match|'
00188              r'minute_microsecond|minute_second|mod|modifies|natural|'
00189              r'no_write_to_binlog|not|numeric|on|optimize|option|optionally|'
00190              r'or|order|out|outer|outfile|precision|primary|procedure|purge|'
00191              r'raid0|read|reads|real|references|regexp|release|rename|repeat|'
00192              r'replace|require|restrict|return|revoke|right|rlike|schema|'
00193              r'schemas|second_microsecond|select|sensitive|separator|set|'
00194              r'show|smallint|soname|spatial|specific|sql|sql_big_result|'
00195              r'sql_calc_found_rows|sql_small_result|sqlexception|sqlstate|'
00196              r'sqlwarning|ssl|starting|straight_join|table|terminated|then|'
00197              r'to|trailing|trigger|undo|union|unique|unlock|unsigned|update|'
00198              r'usage|use|using|utc_date|utc_time|utc_timestamp|values|'
00199              r'varying|when|where|while|with|write|x509|xor|year_month|'
00200              r'zerofill)\b', Keyword),
00201             # TODO: this list is not complete
00202             (r'\b(auto_increment|engine|charset|tables)\b', Keyword.Pseudo),
00203             (r'(true|false|null)', Name.Constant),
00204             (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(\()',
00205              bygroups(Name.Function, Text, Punctuation)),
00206             (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
00207             (r'@[A-Za-z0-9]*[._]*[A-Za-z0-9]*', Name.Variable),
00208             (r'[;:()\[\],\.]', Punctuation)
00209         ],
00210         'multiline-comments': [
00211             (r'/\*', Comment.Multiline, 'multiline-comments'),
00212             (r'\*/', Comment.Multiline, '#pop'),
00213             (r'[^/\*]+', Comment.Multiline),
00214             (r'[/*]', Comment.Multiline)
00215         ]
00216     }
00217 
00218 
00219 class SqliteConsoleLexer(Lexer):
00220     """
00221     Lexer for example sessions using sqlite3.
00222 
00223     *New in Pygments 0.11.*
00224     """
00225 
00226     name = 'sqlite3con'
00227     aliases = ['sqlite3']
00228     filenames = ['*.sqlite3-console']
00229     mimetypes = ['text/x-sqlite3-console']
00230 
00231     def get_tokens_unprocessed(self, data):
00232         sql = SqlLexer(**self.options)
00233 
00234         curcode = ''
00235         insertions = []
00236         for match in line_re.finditer(data):
00237             line = match.group()
00238             if line.startswith('sqlite> ') or line.startswith('   ...> '):
00239                 insertions.append((len(curcode),
00240                                    [(0, Generic.Prompt, line[:8])]))
00241                 curcode += line[8:]
00242             else:
00243                 if curcode:
00244                     for item in do_insertions(insertions,
00245                                               sql.get_tokens_unprocessed(curcode)):
00246                         yield item
00247                     curcode = ''
00248                     insertions = []
00249                 if line.startswith('SQL error: '):
00250                     yield (match.start(), Generic.Traceback, line)
00251                 else:
00252                     yield (match.start(), Generic.Output, line)
00253         if curcode:
00254             for item in do_insertions(insertions,
00255                                       sql.get_tokens_unprocessed(curcode)):
00256                 yield item
00257 
00258 
00259 class BrainfuckLexer(RegexLexer):
00260     """
00261     Lexer for the esoteric `BrainFuck <http://www.muppetlabs.com/~breadbox/bf/>`_
00262     language.
00263     """
00264 
00265     name = 'Brainfuck'
00266     aliases = ['brainfuck', 'bf']
00267     filenames = ['*.bf', '*.b']
00268     mimetypes = ['application/x-brainfuck']
00269 
00270     tokens = {
00271         'common': [
00272             # use different colors for different instruction types
00273             (r'[.,]+', Name.Tag),
00274             (r'[+-]+', Name.Builtin),
00275             (r'[<>]+', Name.Variable),
00276             (r'[^.,+\-<>\[\]]+', Comment),
00277         ],
00278         'root': [
00279             (r'\[', Keyword, 'loop'),
00280             (r'\]', Error),
00281             include('common'),
00282         ],
00283         'loop': [
00284             (r'\[', Keyword, '#push'),
00285             (r'\]', Keyword, '#pop'),
00286             include('common'),
00287         ]
00288     }
00289 
00290 
00291 class BefungeLexer(RegexLexer):
00292     """
00293     Lexer for the esoteric `Befunge <http://en.wikipedia.org/wiki/Befunge>`_
00294     language.
00295 
00296     *New in Pygments 0.7.*
00297     """
00298     name = 'Befunge'
00299     aliases = ['befunge']
00300     filenames = ['*.befunge']
00301     mimetypes = ['application/x-befunge']
00302 
00303     tokens = {
00304         'root': [
00305             (r'[0-9a-f]', Number),
00306             (r'[\+\*/%!`-]', Operator), # Traditional math
00307             (r'[<>^v?\[\]rxjk]', Name.Variable), # Move, imperatives
00308             (r'[:\\$.,n]', Name.Builtin), # Stack ops, imperatives
00309             (r'[|_mw]', Keyword),
00310             (r'[{}]', Name.Tag), # Befunge-98 stack ops
00311             (r'".*?"', String.Double), # Strings don't appear to allow escapes
00312             (r'\'.', String.Single), # Single character
00313             (r'[#;]', Comment), # Trampoline... depends on direction hit
00314             (r'[pg&~=@iotsy]', Keyword), # Misc
00315             (r'[()A-Z]', Comment), # Fingerprints
00316             (r'\s+', Text), # Whitespace doesn't matter
00317         ],
00318     }
00319 
00320 
00321 
00322 class BashLexer(RegexLexer):
00323     """
00324     Lexer for (ba)sh shell scripts.
00325 
00326     *New in Pygments 0.6.*
00327     """
00328 
00329     name = 'Bash'
00330     aliases = ['bash', 'sh']
00331     filenames = ['*.sh', '*.ebuild', '*.eclass']
00332     mimetypes = ['application/x-sh', 'application/x-shellscript']
00333 
00334     tokens = {
00335         'root': [
00336             include('basic'),
00337             (r'\$\(\(', Keyword, 'math'),
00338             (r'\$\(', Keyword, 'paren'),
00339             (r'\${#?', Keyword, 'curly'),
00340             (r'`', String.Backtick, 'backticks'),
00341             include('data'),
00342         ],
00343         'basic': [
00344             (r'\b(if|fi|else|while|do|done|for|then|return|function|case|'
00345              r'select|continue|until|esac|elif)\s*\b',
00346              Keyword),
00347             (r'\b(alias|bg|bind|break|builtin|caller|cd|command|compgen|'
00348              r'complete|declare|dirs|disown|echo|enable|eval|exec|exit|'
00349              r'export|false|fc|fg|getopts|hash|help|history|jobs|kill|let|'
00350              r'local|logout|popd|printf|pushd|pwd|read|readonly|set|shift|'
00351              r'shopt|source|suspend|test|time|times|trap|true|type|typeset|'
00352              r'ulimit|umask|unalias|unset|wait)\s*\b(?!\.)',
00353              Name.Builtin),
00354             (r'#.*\n', Comment),
00355             (r'\\[\w\W]', String.Escape),
00356             (r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Text, Operator)),
00357             (r'[\[\]{}()=]', Operator),
00358             (r'<<\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
00359             (r'&&|\|\|', Operator),
00360         ],
00361         'data': [
00362             (r'\$?"(\\\\|\\[0-7]+|\\.|[^"])*"', String.Double),
00363             (r"\$?'(\\\\|\\[0-7]+|\\.|[^'])*'", String.Single),
00364             (r';', Text),
00365             (r'\s+', Text),
00366             (r'[^=\s\n\[\]{}()$"\'`\\<]+', Text),
00367             (r'\d+(?= |\Z)', Number),
00368             (r'\$#?(\w+|.)', Name.Variable),
00369             (r'<', Text),
00370         ],
00371         'curly': [
00372             (r'}', Keyword, '#pop'),
00373             (r':-', Keyword),
00374             (r'[a-zA-Z0-9_]+', Name.Variable),
00375             (r'[^}:"\'`$]+', Punctuation),
00376             (r':', Punctuation),
00377             include('root'),
00378         ],
00379         'paren': [
00380             (r'\)', Keyword, '#pop'),
00381             include('root'),
00382         ],
00383         'math': [
00384             (r'\)\)', Keyword, '#pop'),
00385             (r'[-+*/%^|&]|\*\*|\|\|', Operator),
00386             (r'\d+', Number),
00387             include('root'),
00388         ],
00389         'backticks': [
00390             (r'`', String.Backtick, '#pop'),
00391             include('root'),
00392         ],
00393     }
00394 
00395     def analyse_text(text):
00396         return shebang_matches(text, r'(ba|z|)sh')
00397 
00398 
00399 class BashSessionLexer(Lexer):
00400     """
00401     Lexer for simplistic shell sessions.
00402 
00403     *New in Pygments 1.1.*
00404     """
00405 
00406     name = 'Bash Session'
00407     aliases = ['console']
00408     filenames = ['*.sh-session']
00409     mimetypes = ['application/x-shell-session']
00410 
00411     def get_tokens_unprocessed(self, text):
00412         bashlexer = BashLexer(**self.options)
00413 
00414         pos = 0
00415         curcode = ''
00416         insertions = []
00417 
00418         for match in line_re.finditer(text):
00419             line = match.group()
00420             m = re.match(r'^((?:|sh\S*?|\w+\S+[@:]\S+(?:\s+\S+)?|\[\S+[@:]'
00421                          r'[^\n]+\].+)[$#%])(.*\n?)', line)
00422             if m:
00423                 # To support output lexers (say diff output), the output
00424                 # needs to be broken by prompts whenever the output lexer
00425                 # changes.
00426                 if not insertions:
00427                     pos = match.start()
00428 
00429                 insertions.append((len(curcode),
00430                                    [(0, Generic.Prompt, m.group(1))]))
00431                 curcode += m.group(2)
00432             elif line.startswith('>'):
00433                 insertions.append((len(curcode),
00434                                    [(0, Generic.Prompt, line[:1])]))
00435                 curcode += line[1:]
00436             else:
00437                 if insertions:
00438                     toks = bashlexer.get_tokens_unprocessed(curcode)
00439                     for i, t, v in do_insertions(insertions, toks):
00440                         yield pos+i, t, v
00441                 yield match.start(), Generic.Output, line
00442                 insertions = []
00443                 curcode = ''
00444         if insertions:
00445             for i, t, v in do_insertions(insertions,
00446                                          bashlexer.get_tokens_unprocessed(curcode)):
00447                 yield pos+i, t, v
00448 
00449 
00450 class BatchLexer(RegexLexer):
00451     """
00452     Lexer for the DOS/Windows Batch file format.
00453 
00454     *New in Pygments 0.7.*
00455     """
00456     name = 'Batchfile'
00457     aliases = ['bat']
00458     filenames = ['*.bat', '*.cmd']
00459     mimetypes = ['application/x-dos-batch']
00460 
00461     flags = re.MULTILINE | re.IGNORECASE
00462 
00463     tokens = {
00464         'root': [
00465             # Lines can start with @ to prevent echo
00466             (r'^\s*@', Punctuation),
00467             (r'^(\s*)(rem\s.*)$', bygroups(Text, Comment)),
00468             (r'".*?"', String.Double),
00469             (r"'.*?'", String.Single),
00470             # If made more specific, make sure you still allow expansions
00471             # like %~$VAR:zlt
00472             (r'%%?[~$:\w]+%?', Name.Variable),
00473             (r'::.*', Comment), # Technically :: only works at BOL
00474             (r'(set)(\s+)(\w+)', bygroups(Keyword, Text, Name.Variable)),
00475             (r'(call)(\s+)(:\w+)', bygroups(Keyword, Text, Name.Label)),
00476             (r'(goto)(\s+)(\w+)', bygroups(Keyword, Text, Name.Label)),
00477             (r'\b(set|call|echo|on|off|endlocal|for|do|goto|if|pause|'
00478              r'setlocal|shift|errorlevel|exist|defined|cmdextversion|'
00479              r'errorlevel|else|cd|md|del|deltree|cls|choice)\b', Keyword),
00480             (r'\b(equ|neq|lss|leq|gtr|geq)\b', Operator),
00481             include('basic'),
00482             (r'.', Text),
00483         ],
00484         'echo': [
00485             # Escapes only valid within echo args?
00486             (r'\^\^|\^<|\^>|\^\|', String.Escape),
00487             (r'\n', Text, '#pop'),
00488             include('basic'),
00489             (r'[^\'"^]+', Text),
00490         ],
00491         'basic': [
00492             (r'".*?"', String.Double),
00493             (r"'.*?'", String.Single),
00494             (r'`.*?`', String.Backtick),
00495             (r'-?\d+', Number),
00496             (r',', Punctuation),
00497             (r'=', Operator),
00498             (r'/\S+', Name),
00499             (r':\w+', Name.Label),
00500             (r'\w:\w+', Text),
00501             (r'([<>|])(\s*)(\w+)', bygroups(Punctuation, Text, Name)),
00502         ],
00503     }
00504 
00505 
00506 class RedcodeLexer(RegexLexer):
00507     """
00508     A simple Redcode lexer based on ICWS'94.
00509     Contributed by Adam Blinkinsop <blinks@acm.org>.
00510 
00511     *New in Pygments 0.8.*
00512     """
00513     name = 'Redcode'
00514     aliases = ['redcode']
00515     filenames = ['*.cw']
00516 
00517     opcodes = ['DAT','MOV','ADD','SUB','MUL','DIV','MOD',
00518                'JMP','JMZ','JMN','DJN','CMP','SLT','SPL',
00519                'ORG','EQU','END']
00520     modifiers = ['A','B','AB','BA','F','X','I']
00521 
00522     tokens = {
00523         'root': [
00524             # Whitespace:
00525             (r'\s+', Text),
00526             (r';.*$', Comment.Single),
00527             # Lexemes:
00528             #  Identifiers
00529             (r'\b(%s)\b' % '|'.join(opcodes), Name.Function),
00530             (r'\b(%s)\b' % '|'.join(modifiers), Name.Decorator),
00531             (r'[A-Za-z_][A-Za-z_0-9]+', Name),
00532             #  Operators
00533             (r'[-+*/%]', Operator),
00534             (r'[#$@<>]', Operator), # mode
00535             (r'[.,]', Punctuation), # mode
00536             #  Numbers
00537             (r'[-+]?\d+', Number.Integer),
00538         ],
00539     }
00540 
00541 
00542 class MOOCodeLexer(RegexLexer):
00543     """
00544     For `MOOCode <http://www.moo.mud.org/>`_ (the MOO scripting
00545     language).
00546 
00547     *New in Pygments 0.9.*
00548     """
00549     name = 'MOOCode'
00550     filenames = ['*.moo']
00551     aliases = ['moocode']
00552     mimetypes = ['text/x-moocode']
00553 
00554     tokens = {
00555         'root' : [
00556             # Numbers
00557             (r'(0|[1-9][0-9_]*)', Number.Integer),
00558             # Strings
00559             (r'"(\\\\|\\"|[^"])*"', String),
00560             # exceptions
00561             (r'(E_PERM|E_DIV)', Name.Exception),
00562             # db-refs
00563             (r'((#[-0-9]+)|(\$[a-z_A-Z0-9]+))', Name.Entity),
00564             # Keywords
00565             (r'\b(if|else|elseif|endif|for|endfor|fork|endfork|while'
00566              r'|endwhile|break|continue|return|try'
00567              r'|except|endtry|finally|in)\b', Keyword),
00568             # builtins
00569             (r'(random|length)', Name.Builtin),
00570             # special variables
00571             (r'(player|caller|this|args)', Name.Variable.Instance),
00572             # skip whitespace
00573             (r'\s+', Text),
00574             (r'\n', Text),
00575             # other operators
00576             (r'([!;=,{}&\|:\.\[\]@\(\)<>\?]+)', Operator),
00577             # function call
00578             (r'([a-z_A-Z0-9]+)(\()', bygroups(Name.Function, Operator)),
00579             # variables
00580             (r'([a-zA-Z_0-9]+)', Text),
00581         ]
00582     }
00583 
00584 
00585 class SmalltalkLexer(RegexLexer):
00586     """
00587     For `Smalltalk <http://www.smalltalk.org/>`_ syntax.
00588     Contributed by Stefan Matthias Aust.
00589     Rewritten by Nils Winter.
00590 
00591     *New in Pygments 0.10.*
00592     """
00593     name = 'Smalltalk'
00594     filenames = ['*.st']
00595     aliases = ['smalltalk', 'squeak']
00596     mimetypes = ['text/x-smalltalk']
00597 
00598     tokens = {
00599         'root' : [
00600             (r'(<)(\w+:)(.*?)(>)', bygroups(Text, Keyword, Text, Text)),
00601             include('squeak fileout'),
00602             include('whitespaces'),
00603             include('method definition'),
00604             (r'(\|)([\w\s]*)(\|)', bygroups(Operator, Name.Variable, Operator)),
00605             include('objects'),
00606             (r'\^|\:=|\_', Operator),
00607             # temporaries
00608             (r'[\]({}.;!]', Text),
00609 
00610         ],
00611         'method definition' : [
00612             # Not perfect can't allow whitespaces at the beginning and the
00613             # without breaking everything
00614             (r'([a-zA-Z]+\w*:)(\s*)(\w+)',
00615              bygroups(Name.Function, Text, Name.Variable)),
00616             (r'^(\b[a-zA-Z]+\w*\b)(\s*)$', bygroups(Name.Function, Text)),
00617             (r'^([-+*/\\~<>=|&!?,@%]+)(\s*)(\w+)(\s*)$',
00618              bygroups(Name.Function, Text, Name.Variable, Text)),
00619         ],
00620         'blockvariables' : [
00621             include('whitespaces'),
00622             (r'(:)(\s*)([A-Za-z\w]+)',
00623              bygroups(Operator, Text, Name.Variable)),
00624             (r'\|', Operator, '#pop'),
00625             (r'', Text, '#pop'), # else pop
00626         ],
00627         'literals' : [
00628             (r'\'[^\']*\'', String, 'afterobject'),
00629             (r'\$.', String.Char, 'afterobject'),
00630             (r'#\(', String.Symbol, 'parenth'),
00631             (r'\)', Text, 'afterobject'),
00632             (r'(\d+r)?-?\d+(\.\d+)?(e-?\d+)?', Number, 'afterobject'),
00633         ],
00634         '_parenth_helper' : [
00635             include('whitespaces'),
00636             (r'[-+*/\\~<>=|&#!?,@%\w+:]+', String.Symbol),
00637             # literals
00638             (r'\'[^\']*\'', String),
00639             (r'\$.', String.Char),
00640             (r'(\d+r)?-?\d+(\.\d+)?(e-?\d+)?', Number),
00641             (r'#*\(', String.Symbol, 'inner_parenth'),
00642         ],
00643         'parenth' : [
00644             # This state is a bit tricky since
00645             # we can't just pop this state
00646             (r'\)', String.Symbol, ('root','afterobject')),
00647             include('_parenth_helper'),
00648         ],
00649         'inner_parenth': [
00650             (r'\)', String.Symbol, '#pop'),
00651             include('_parenth_helper'),
00652         ],
00653         'whitespaces' : [
00654             # skip whitespace and comments
00655             (r'\s+', Text),
00656             (r'"[^"]*"', Comment),
00657         ],
00658         'objects' : [
00659             (r'\[', Text, 'blockvariables'),
00660             (r'\]', Text, 'afterobject'),
00661             (r'\b(self|super|true|false|nil|thisContext)\b',
00662              Name.Builtin.Pseudo, 'afterobject'),
00663             (r'\b[A-Z]\w*(?!:)\b', Name.Class, 'afterobject'),
00664             (r'\b[a-z]\w*(?!:)\b', Name.Variable, 'afterobject'),
00665             (r'#("[^"]*"|[-+*/\\~<>=|&!?,@%]+|[\w:]+)',
00666              String.Symbol, 'afterobject'),
00667             include('literals'),
00668         ],
00669         'afterobject' : [
00670             (r'! !$', Keyword , '#pop'), # squeak chunk delimeter
00671             include('whitespaces'),
00672             (r'\b(ifTrue:|ifFalse:|whileTrue:|whileFalse:|timesRepeat:)',
00673              Name.Builtin, '#pop'),
00674             (r'\b(new\b(?!:))', Name.Builtin),
00675             (r'\:=|\_', Operator, '#pop'),
00676             (r'\b[a-zA-Z]+\w*:', Name.Function, '#pop'),
00677             (r'\b[a-zA-Z]+\w*', Name.Function),
00678             (r'\w+:?|[-+*/\\~<>=|&!?,@%]+', Name.Function, '#pop'),
00679             (r'\.', Punctuation, '#pop'),
00680             (r';', Punctuation),
00681             (r'[\])}]', Text),
00682             (r'[\[({]', Text, '#pop'),
00683         ],
00684         'squeak fileout' : [
00685             # Squeak fileout format (optional)
00686             (r'^"[^"]*"!', Keyword),
00687             (r"^'[^']*'!", Keyword),
00688             (r'^(!)(\w+)( commentStamp: )(.*?)( prior: .*?!\n)(.*?)(!)',
00689                 bygroups(Keyword, Name.Class, Keyword, String, Keyword, Text, Keyword)),
00690             (r'^(!)(\w+(?: class)?)( methodsFor: )(\'[^\']*\')(.*?!)',
00691                 bygroups(Keyword, Name.Class, Keyword, String, Keyword)),
00692             (r'^(\w+)( subclass: )(#\w+)'
00693              r'(\s+instanceVariableNames: )(.*?)'
00694              r'(\s+classVariableNames: )(.*?)'
00695              r'(\s+poolDictionaries: )(.*?)'
00696              r'(\s+category: )(.*?)(!)',
00697                 bygroups(Name.Class, Keyword, String.Symbol, Keyword, String, Keyword,
00698                          String, Keyword, String, Keyword, String, Keyword)),
00699             (r'^(\w+(?: class)?)(\s+instanceVariableNames: )(.*?)(!)',
00700                 bygroups(Name.Class, Keyword, String, Keyword)),
00701             (r'(!\n)(\].*)(! !)$', bygroups(Keyword, Text, Keyword)),
00702             (r'! !$', Keyword),
00703         ],
00704     }
00705 
00706 
00707 class TcshLexer(RegexLexer):
00708     """
00709     Lexer for tcsh scripts.
00710 
00711     *New in Pygments 0.10.*
00712     """
00713 
00714     name = 'Tcsh'
00715     aliases = ['tcsh', 'csh']
00716     filenames = ['*.tcsh', '*.csh']
00717     mimetypes = ['application/x-csh']
00718 
00719     tokens = {
00720         'root': [
00721             include('basic'),
00722             (r'\$\(', Keyword, 'paren'),
00723             (r'\${#?', Keyword, 'curly'),
00724             (r'`', String.Backtick, 'backticks'),
00725             include('data'),
00726         ],
00727         'basic': [
00728             (r'\b(if|endif|else|while|then|foreach|case|default|'
00729              r'continue|goto|breaksw|end|switch|endsw)\s*\b',
00730              Keyword),
00731             (r'\b(alias|alloc|bg|bindkey|break|builtins|bye|caller|cd|chdir|'
00732              r'complete|dirs|echo|echotc|eval|exec|exit|'
00733              r'fg|filetest|getxvers|glob|getspath|hashstat|history|hup|inlib|jobs|kill|'
00734              r'limit|log|login|logout|ls-F|migrate|newgrp|nice|nohup|notify|'
00735              r'onintr|popd|printenv|pushd|rehash|repeat|rootnode|popd|pushd|set|shift|'
00736              r'sched|setenv|setpath|settc|setty|setxvers|shift|source|stop|suspend|'
00737              r'source|suspend|telltc|time|'
00738              r'umask|unalias|uncomplete|unhash|universe|unlimit|unset|unsetenv|'
00739              r'ver|wait|warp|watchlog|where|which)\s*\b',
00740              Name.Builtin),
00741             (r'#.*\n', Comment),
00742             (r'\\[\w\W]', String.Escape),
00743             (r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Text, Operator)),
00744             (r'[\[\]{}()=]+', Operator),
00745             (r'<<\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
00746         ],
00747         'data': [
00748             (r'"(\\\\|\\[0-7]+|\\.|[^"])*"', String.Double),
00749             (r"'(\\\\|\\[0-7]+|\\.|[^'])*'", String.Single),
00750             (r'\s+', Text),
00751             (r'[^=\s\n\[\]{}()$"\'`\\]+', Text),
00752             (r'\d+(?= |\Z)', Number),
00753             (r'\$#?(\w+|.)', Name.Variable),
00754         ],
00755         'curly': [
00756             (r'}', Keyword, '#pop'),
00757             (r':-', Keyword),
00758             (r'[a-zA-Z0-9_]+', Name.Variable),
00759             (r'[^}:"\'`$]+', Punctuation),
00760             (r':', Punctuation),
00761             include('root'),
00762         ],
00763         'paren': [
00764             (r'\)', Keyword, '#pop'),
00765             include('root'),
00766         ],
00767         'backticks': [
00768             (r'`', String.Backtick, '#pop'),
00769             include('root'),
00770         ],
00771     }
00772 
00773 
00774 class LogtalkLexer(RegexLexer):
00775     """
00776     For `Logtalk <http://logtalk.org/>`_ source code.
00777 
00778     *New in Pygments 0.10.*
00779     """
00780 
00781     name = 'Logtalk'
00782     aliases = ['logtalk']
00783     filenames = ['*.lgt']
00784     mimetypes = ['text/x-logtalk']
00785 
00786     tokens = {
00787         'root': [
00788             # Directives
00789             (r'^\s*:-\s',Punctuation,'directive'),
00790             # Comments
00791             (r'%.*?\n', Comment),
00792             (r'/\*(.|\n)*?\*/',Comment),
00793             # Whitespace
00794             (r'\n', Text),
00795             (r'\s+', Text),
00796             # Numbers
00797             (r"0'.", Number),
00798             (r'0b[01]+', Number),
00799             (r'0o[0-7]+', Number),
00800             (r'0x[0-9a-fA-F]+', Number),
00801             (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
00802             # Variables
00803             (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
00804             # Event handlers
00805             (r'(after|before)(?=[(])', Keyword),
00806             # Execution-context methods
00807             (r'(parameter|this|se(lf|nder))(?=[(])', Keyword),
00808             # Reflection
00809             (r'(current_predicate|predicate_property)(?=[(])', Keyword),
00810             # DCGs and term expansion
00811             (r'(expand_term|(goal|term)_expansion|phrase)(?=[(])', Keyword),
00812             # Entity
00813             (r'(abolish|c(reate|urrent))_(object|protocol|category)(?=[(])',
00814              Keyword),
00815             (r'(object|protocol|category)_property(?=[(])', Keyword),
00816             # Entity relations
00817             (r'complements_object(?=[(])', Keyword),
00818             (r'extends_(object|protocol|category)(?=[(])', Keyword),
00819             (r'imp(lements_protocol|orts_category)(?=[(])', Keyword),
00820             (r'(instantiat|specializ)es_class(?=[(])', Keyword),
00821             # Events
00822             (r'(current_event|(abolish|define)_events)(?=[(])', Keyword),
00823             # Flags
00824             (r'(current|set)_logtalk_flag(?=[(])', Keyword),
00825             # Compiling, loading, and library paths
00826             (r'logtalk_(compile|l(ibrary_path|oad))(?=[(])', Keyword),
00827             # Database
00828             (r'(clause|retract(all)?)(?=[(])', Keyword),
00829             (r'a(bolish|ssert(a|z))(?=[(])', Keyword),
00830             # Control
00831             (r'(ca(ll|tch)|throw)(?=[(])', Keyword),
00832             (r'(fail|true)\b', Keyword),
00833             # All solutions
00834             (r'((bag|set)of|f(ind|or)all)(?=[(])', Keyword),
00835             # Multi-threading meta-predicates
00836             (r'threaded(_(call|once|ignore|exit|peek|wait|notify))?(?=[(])',
00837              Keyword),
00838             # Term unification
00839             (r'unify_with_occurs_check(?=[(])', Keyword),
00840             # Term creation and decomposition
00841             (r'(functor|arg|copy_term)(?=[(])', Keyword),
00842             # Evaluable functors
00843             (r'(rem|mod|abs|sign)(?=[(])', Keyword),
00844             (r'float(_(integer|fractional)_part)?(?=[(])', Keyword),
00845             (r'(floor|truncate|round|ceiling)(?=[(])', Keyword),
00846             # Other arithmetic functors
00847             (r'(cos|atan|exp|log|s(in|qrt))(?=[(])', Keyword),
00848             # Term testing
00849             (r'(var|atom(ic)?|integer|float|compound|n(onvar|umber))(?=[(])',
00850              Keyword),
00851             # Stream selection and control
00852             (r'(curren|se)t_(in|out)put(?=[(])', Keyword),
00853             (r'(open|close)(?=[(])', Keyword),
00854             (r'flush_output(?=[(])', Keyword),
00855             (r'(at_end_of_stream|flush_output)\b', Keyword),
00856             (r'(stream_property|at_end_of_stream|set_stream_position)(?=[(])',
00857              Keyword),
00858             # Character and byte input/output
00859             (r'(nl|(get|peek|put)_(byte|c(har|ode)))(?=[(])', Keyword),
00860             (r'\bnl\b', Keyword),
00861             # Term input/output
00862             (r'read(_term)?(?=[(])', Keyword),
00863             (r'write(q|_(canonical|term))?(?=[(])', Keyword),
00864             (r'(current_)?op(?=[(])', Keyword),
00865             (r'(current_)?char_conversion(?=[(])', Keyword),
00866             # Atomic term processing
00867             (r'atom_(length|c(hars|o(ncat|des)))(?=[(])', Keyword),
00868             (r'(char_code|sub_atom)(?=[(])', Keyword),
00869             (r'number_c(har|ode)s(?=[(])', Keyword),
00870             # Implementation defined hooks functions
00871             (r'(se|curren)t_prolog_flag(?=[(])', Keyword),
00872             (r'\bhalt\b', Keyword),
00873             (r'halt(?=[(])', Keyword),
00874             # Message sending operators
00875             (r'(::|:|\^\^)', Operator),
00876             # External call
00877             (r'[{}]', Keyword),
00878             # Logic and control
00879             (r'\bonce(?=[(])', Keyword),
00880             (r'\brepeat\b', Keyword),
00881             # Bitwise functors
00882             (r'(>>|<<|/\\|\\\\|\\)', Operator),
00883             # Arithemtic evaluation
00884             (r'\bis\b', Keyword),
00885             # Arithemtic comparison
00886             (r'(=:=|=\\=|<|=<|>=|>)', Operator),
00887             # Term creation and decomposition
00888             (r'=\.\.', Operator),
00889             # Term unification
00890             (r'(=|\\=)', Operator),
00891             # Term comparison
00892             (r'(==|\\==|@=<|@<|@>=|@>)', Operator),
00893             # Evaluable functors
00894             (r'(//|[-+*/])', Operator),
00895             (r'\b(mod|rem)\b', Operator),
00896             # Other arithemtic functors
00897             (r'\b\*\*\b', Operator),
00898             # DCG rules
00899             (r'-->', Operator),
00900             # Control constructs
00901             (r'([!;]|->)', Operator),
00902             # Logic and control
00903             (r'\\+', Operator),
00904             # Mode operators
00905             (r'[?@]', Operator),
00906             # Strings
00907             (r'"(\\\\|\\"|[^"])*"', String),
00908             # Ponctuation
00909             (r'[()\[\],.|]', Text),
00910             # Atoms
00911             (r"[a-z][a-zA-Z0-9_]*", Text),
00912             (r"[']", String, 'quoted_atom'),
00913         ],
00914 
00915         'quoted_atom': [
00916             (r"['][']", String),
00917             (r"[']", String, '#pop'),
00918             (r'\\([\\abfnrtv"\']|(x[a-fA-F0-9]+|[0-7]+)\\)', String.Escape),
00919             (r"[^\\'\n]+", String),
00920             (r'\\', String),
00921         ],
00922 
00923         'directive': [
00924             # Entity directives
00925             (r'(category|object|protocol)(?=[(])', Keyword, 'entityrelations'),
00926             (r'(end_(category|object|protocol))[.]',Keyword, 'root'),
00927             # Predicate scope directives
00928             (r'(public|protected|private)(?=[(])', Keyword, 'root'),
00929             # Other directives
00930             (r'e(ncoding|xport)(?=[(])', Keyword, 'root'),
00931             (r'in(fo|itialization)(?=[(])', Keyword, 'root'),
00932             (r'(dynamic|synchronized|threaded)[.]', Keyword, 'root'),
00933             (r'(alias|d(ynamic|iscontiguous)|m(eta_predicate|ode|ultifile)'
00934              r'|synchronized)(?=[(])', Keyword, 'root'),
00935             (r'op(?=[(])', Keyword, 'root'),
00936             (r'(calls|use(s|_module))(?=[(])', Keyword, 'root'),
00937             (r'[a-z][a-zA-Z0-9_]*(?=[(])', Text, 'root'),
00938             (r'[a-z][a-zA-Z0-9_]*[.]', Text, 'root'),
00939         ],
00940 
00941         'entityrelations': [
00942             (r'(extends|i(nstantiates|mp(lements|orts))|specializes)(?=[(])',
00943              Keyword),
00944             # Numbers
00945             (r"0'.", Number),
00946             (r'0b[01]+', Number),
00947             (r'0o[0-7]+', Number),
00948             (r'0x[0-9a-fA-F]+', Number),
00949             (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
00950             # Variables
00951             (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
00952             # Atoms
00953             (r"[a-z][a-zA-Z0-9_]*", Text),
00954             (r"[']", String, 'quoted_atom'),
00955             # Strings
00956             (r'"(\\\\|\\"|[^"])*"', String),
00957             # End of entity-opening directive
00958             (r'([)]\.)', Text, 'root'),
00959             # Scope operator
00960             (r'(::)', Operator),
00961             # Ponctuation
00962             (r'[()\[\],.|]', Text),
00963             # Comments
00964             (r'%.*?\n', Comment),
00965             (r'/\*(.|\n)*?\*/',Comment),
00966             # Whitespace
00967             (r'\n', Text),
00968             (r'\s+', Text),
00969         ]
00970     }
00971 
00972 
00973 def _shortened(word):
00974     dpos = word.find('$')
00975     return '|'.join([word[:dpos] + word[dpos+1:i] + r'\b'
00976                      for i in range(len(word), dpos, -1)])
00977 def _shortened_many(*words):
00978     return '|'.join(map(_shortened, words))
00979 
00980 class GnuplotLexer(RegexLexer):
00981     """
00982     For `Gnuplot <http://gnuplot.info/>`_ plotting scripts.
00983 
00984     *New in Pygments 0.11.*
00985     """
00986 
00987     name = 'Gnuplot'
00988     aliases = ['gnuplot']
00989     filenames = ['*.plot', '*.plt']
00990     mimetypes = ['text/x-gnuplot']
00991 
00992     tokens = {
00993         'root': [
00994             include('whitespace'),
00995             (_shortened('bi$nd'), Keyword, 'bind'),
00996             (_shortened_many('ex$it', 'q$uit'), Keyword, 'quit'),
00997             (_shortened('f$it'), Keyword, 'fit'),
00998             (r'(if)(\s*)(\()', bygroups(Keyword, Text, Punctuation), 'if'),
00999             (r'else\b', Keyword),
01000             (_shortened('pa$use'), Keyword, 'pause'),
01001             (_shortened_many('p$lot', 'rep$lot', 'sp$lot'), Keyword, 'plot'),
01002             (_shortened('sa$ve'), Keyword, 'save'),
01003             (_shortened('se$t'), Keyword, ('genericargs', 'optionarg')),
01004             (_shortened_many('sh$ow', 'uns$et'),
01005              Keyword, ('noargs', 'optionarg')),
01006             (_shortened_many('low$er', 'ra$ise', 'ca$ll', 'cd$', 'cl$ear',
01007                              'h$elp', '\\?$', 'hi$story', 'l$oad', 'pr$int',
01008                              'pwd$', 're$read', 'res$et', 'scr$eendump',
01009                              'she$ll', 'sy$stem', 'up$date'),
01010              Keyword, 'genericargs'),
01011             (_shortened_many('pwd$', 're$read', 'res$et', 'scr$eendump',
01012                              'she$ll', 'test$'),
01013              Keyword, 'noargs'),
01014             ('([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(=)',
01015              bygroups(Name.Variable, Text, Operator), 'genericargs'),
01016             ('([a-zA-Z_][a-zA-Z0-9_]*)(\s*\(.*?\)\s*)(=)',
01017              bygroups(Name.Function, Text, Operator), 'genericargs'),
01018             (r'@[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant), # macros
01019             (r';', Keyword),
01020         ],
01021         'comment': [
01022             (r'[^\\\n]', Comment),
01023             (r'\\\n', Comment),
01024             (r'\\', Comment),
01025             # don't add the newline to the Comment token
01026             ('', Comment, '#pop'),
01027         ],
01028         'whitespace': [
01029             ('#', Comment, 'comment'),
01030             (r'[ \t\v\f]+', Text),
01031         ],
01032         'noargs': [
01033             include('whitespace'),
01034             # semicolon and newline end the argument list
01035             (r';', Punctuation, '#pop'),
01036             (r'\n', Text, '#pop'),
01037         ],
01038         'dqstring': [
01039             (r'"', String, '#pop'),
01040             (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
01041             (r'[^\\"\n]+', String), # all other characters
01042             (r'\\\n', String), # line continuation
01043             (r'\\', String), # stray backslash
01044             (r'\n', String, '#pop'), # newline ends the string too
01045         ],
01046         'sqstring': [
01047             (r"''", String), # escaped single quote
01048             (r"'", String, '#pop'),
01049             (r"[^\\'\n]+", String), # all other characters
01050             (r'\\\n', String), # line continuation
01051             (r'\\', String), # normal backslash
01052             (r'\n', String, '#pop'), # newline ends the string too
01053         ],
01054         'genericargs': [
01055             include('noargs'),
01056             (r'"', String, 'dqstring'),
01057             (r"'", String, 'sqstring'),
01058             (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+', Number.Float),
01059             (r'(\d+\.\d*|\.\d+)', Number.Float),
01060             (r'-?\d+', Number.Integer),
01061             ('[,.~!%^&*+=|?:<>/-]', Operator),
01062             ('[{}()\[\]]', Punctuation),
01063             (r'(eq|ne)\b', Operator.Word),
01064             (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(\()',
01065              bygroups(Name.Function, Text, Punctuation)),
01066             (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
01067             (r'@[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant), # macros
01068             (r'\\\n', Text),
01069         ],
01070         'optionarg': [
01071             include('whitespace'),
01072             (_shortened_many(
01073                 "a$ll","an$gles","ar$row","au$toscale","b$ars","bor$der",
01074                 "box$width","cl$abel","c$lip","cn$trparam","co$ntour","da$ta",
01075                 "data$file","dg$rid3d","du$mmy","enc$oding","dec$imalsign",
01076                 "fit$","font$path","fo$rmat","fu$nction","fu$nctions","g$rid",
01077                 "hid$den3d","his$torysize","is$osamples","k$ey","keyt$itle",
01078                 "la$bel","li$nestyle","ls$","loa$dpath","loc$ale","log$scale",
01079                 "mac$ros","map$ping","map$ping3d","mar$gin","lmar$gin",
01080                 "rmar$gin","tmar$gin","bmar$gin","mo$use","multi$plot",
01081                 "mxt$ics","nomxt$ics","mx2t$ics","nomx2t$ics","myt$ics",
01082                 "nomyt$ics","my2t$ics","nomy2t$ics","mzt$ics","nomzt$ics",
01083                 "mcbt$ics","nomcbt$ics","of$fsets","or$igin","o$utput",
01084                 "pa$rametric","pm$3d","pal$ette","colorb$ox","p$lot",
01085                 "poi$ntsize","pol$ar","pr$int","obj$ect","sa$mples","si$ze",
01086                 "st$yle","su$rface","table$","t$erminal","termo$ptions","ti$cs",
01087                 "ticsc$ale","ticsl$evel","timef$mt","tim$estamp","tit$le",
01088                 "v$ariables","ve$rsion","vi$ew","xyp$lane","xda$ta","x2da$ta",
01089                 "yda$ta","y2da$ta","zda$ta","cbda$ta","xl$abel","x2l$abel",
01090                 "yl$abel","y2l$abel","zl$abel","cbl$abel","xti$cs","noxti$cs",
01091                 "x2ti$cs","nox2ti$cs","yti$cs","noyti$cs","y2ti$cs","noy2ti$cs",
01092                 "zti$cs","nozti$cs","cbti$cs","nocbti$cs","xdti$cs","noxdti$cs",
01093                 "x2dti$cs","nox2dti$cs","ydti$cs","noydti$cs","y2dti$cs",
01094                 "noy2dti$cs","zdti$cs","nozdti$cs","cbdti$cs","nocbdti$cs",
01095                 "xmti$cs","noxmti$cs","x2mti$cs","nox2mti$cs","ymti$cs",
01096                 "noymti$cs","y2mti$cs","noy2mti$cs","zmti$cs","nozmti$cs",
01097                 "cbmti$cs","nocbmti$cs","xr$ange","x2r$ange","yr$ange",
01098                 "y2r$ange","zr$ange","cbr$ange","rr$ange","tr$ange","ur$ange",
01099                 "vr$ange","xzeroa$xis","x2zeroa$xis","yzeroa$xis","y2zeroa$xis",
01100                 "zzeroa$xis","zeroa$xis","z$ero"), Name.Builtin, '#pop'),
01101         ],
01102         'bind': [
01103             ('!', Keyword, '#pop'),
01104             (_shortened('all$windows'), Name.Builtin),
01105             include('genericargs'),
01106         ],
01107         'quit': [
01108             (r'gnuplot\b', Keyword),
01109             include('noargs'),
01110         ],
01111         'fit': [
01112             (r'via\b', Name.Builtin),
01113             include('plot'),
01114         ],
01115         'if': [
01116             (r'\)', Punctuation, '#pop'),
01117             include('genericargs'),
01118         ],
01119         'pause': [
01120             (r'(mouse|any|button1|button2|button3)\b', Name.Builtin),
01121             (_shortened('key$press'), Name.Builtin),
01122             include('genericargs'),
01123         ],
01124         'plot': [
01125             (_shortened_many('ax$es', 'axi$s', 'bin$ary', 'ev$ery', 'i$ndex',
01126                              'mat$rix', 's$mooth', 'thru$', 't$itle',
01127                              'not$itle', 'u$sing', 'w$ith'),
01128              Name.Builtin),
01129             include('genericargs'),
01130         ],
01131         'save': [
01132             (_shortened_many('f$unctions', 's$et', 't$erminal', 'v$ariables'),
01133              Name.Builtin),
01134             include('genericargs'),
01135         ],
01136     }
01137 
01138 
01139 class PovrayLexer(RegexLexer):
01140     """
01141     For `Persistence of Vision Raytracer <http://www.povray.org/>`_ files.
01142 
01143     *New in Pygments 0.11.*
01144     """
01145     name = 'POVRay'
01146     aliases = ['pov']
01147     filenames = ['*.pov', '*.inc']
01148     mimetypes = ['text/x-povray']
01149 
01150     tokens = {
01151         'root': [
01152             (r'/\*[\w\W]*?\*/', Comment.Multiline),
01153             (r'//.*\n', Comment.Single),
01154             (r'"(?:\\.|[^"])+"', String.Double),
01155             (r'#(debug|default|else|end|error|fclose|fopen|if|ifdef|ifndef|'
01156              r'include|range|read|render|statistics|switch|undef|version|'
01157              r'warning|while|write|define|macro|local|declare)',
01158              Comment.Preproc),
01159             (r'\b(aa_level|aa_threshold|abs|acos|acosh|adaptive|adc_bailout|'
01160              r'agate|agate_turb|all|alpha|ambient|ambient_light|angle|'
01161              r'aperture|arc_angle|area_light|asc|asin|asinh|assumed_gamma|'
01162              r'atan|atan2|atanh|atmosphere|atmospheric_attenuation|'
01163              r'attenuating|average|background|black_hole|blue|blur_samples|'
01164              r'bounded_by|box_mapping|bozo|break|brick|brick_size|'
01165              r'brightness|brilliance|bumps|bumpy1|bumpy2|bumpy3|bump_map|'
01166              r'bump_size|case|caustics|ceil|checker|chr|clipped_by|clock|'
01167              r'color|color_map|colour|colour_map|component|composite|concat|'
01168              r'confidence|conic_sweep|constant|control0|control1|cos|cosh|'
01169              r'count|crackle|crand|cube|cubic_spline|cylindrical_mapping|'
01170              r'debug|declare|default|degrees|dents|diffuse|direction|'
01171              r'distance|distance_maximum|div|dust|dust_type|eccentricity|'
01172              r'else|emitting|end|error|error_bound|exp|exponent|'
01173              r'fade_distance|fade_power|falloff|falloff_angle|false|'
01174              r'file_exists|filter|finish|fisheye|flatness|flip|floor|'
01175              r'focal_point|fog|fog_alt|fog_offset|fog_type|frequency|gif|'
01176              r'global_settings|glowing|gradient|granite|gray_threshold|'
01177              r'green|halo|hexagon|hf_gray_16|hierarchy|hollow|hypercomplex|'
01178              r'if|ifdef|iff|image_map|incidence|include|int|interpolate|'
01179              r'inverse|ior|irid|irid_wavelength|jitter|lambda|leopard|'
01180              r'linear|linear_spline|linear_sweep|location|log|looks_like|'
01181              r'look_at|low_error_factor|mandel|map_type|marble|material_map|'
01182              r'matrix|max|max_intersections|max_iteration|max_trace_level|'
01183              r'max_value|metallic|min|minimum_reuse|mod|mortar|'
01184              r'nearest_count|no|normal|normal_map|no_shadow|number_of_waves|'
01185              r'octaves|off|offset|omega|omnimax|on|once|onion|open|'
01186              r'orthographic|panoramic|pattern1|pattern2|pattern3|'
01187              r'perspective|pgm|phase|phong|phong_size|pi|pigment|'
01188              r'pigment_map|planar_mapping|png|point_at|pot|pow|ppm|'
01189              r'precision|pwr|quadratic_spline|quaternion|quick_color|'
01190              r'quick_colour|quilted|radial|radians|radiosity|radius|rainbow|'
01191              r'ramp_wave|rand|range|reciprocal|recursion_limit|red|'
01192              r'reflection|refraction|render|repeat|rgb|rgbf|rgbft|rgbt|'
01193              r'right|ripples|rotate|roughness|samples|scale|scallop_wave|'
01194              r'scattering|seed|shadowless|sin|sine_wave|sinh|sky|sky_sphere|'
01195              r'slice|slope_map|smooth|specular|spherical_mapping|spiral|'
01196              r'spiral1|spiral2|spotlight|spotted|sqr|sqrt|statistics|str|'
01197              r'strcmp|strength|strlen|strlwr|strupr|sturm|substr|switch|sys|'
01198              r't|tan|tanh|test_camera_1|test_camera_2|test_camera_3|'
01199              r'test_camera_4|texture|texture_map|tga|thickness|threshold|'
01200              r'tightness|tile2|tiles|track|transform|translate|transmit|'
01201              r'triangle_wave|true|ttf|turbulence|turb_depth|type|'
01202              r'ultra_wide_angle|up|use_color|use_colour|use_index|u_steps|'
01203              r'val|variance|vaxis_rotate|vcross|vdot|version|vlength|'
01204              r'vnormalize|volume_object|volume_rendered|vol_with_light|'
01205              r'vrotate|v_steps|warning|warp|water_level|waves|while|width|'
01206              r'wood|wrinkles|yes)\b', Keyword),
01207             (r'bicubic_patch|blob|box|camera|cone|cubic|cylinder|difference|'
01208              r'disc|height_field|intersection|julia_fractal|lathe|'
01209              r'light_source|merge|mesh|object|plane|poly|polygon|prism|'
01210              r'quadric|quartic|smooth_triangle|sor|sphere|superellipsoid|'
01211              r'text|torus|triangle|union', Name.Builtin),
01212             # TODO: <=, etc
01213             (r'[\[\](){}<>;,]', Punctuation),
01214             (r'[-+*/=]', Operator),
01215             (r'\b(x|y|z|u|v)\b', Name.Builtin.Pseudo),
01216             (r'[a-zA-Z_][a-zA-Z_0-9]*', Name),
01217             (r'[0-9]+\.[0-9]*', Number.Float),
01218             (r'\.[0-9]+', Number.Float),
01219             (r'[0-9]+', Number.Integer),
01220             (r'\s+', Text),
01221         ]
01222     }
01223 
01224 
01225 class AppleScriptLexer(RegexLexer):
01226     """
01227     For `AppleScript source code
01228     <http://developer.apple.com/documentation/AppleScript/
01229     Conceptual/AppleScriptLangGuide>`_,
01230     including `AppleScript Studio
01231     <http://developer.apple.com/documentation/AppleScript/
01232     Reference/StudioReference>`_.
01233     Contributed by Andreas Amann <aamann@mac.com>.
01234     """
01235 
01236     name = 'AppleScript'
01237     aliases = ['applescript']
01238     filenames = ['*.applescript']
01239 
01240     flags = re.MULTILINE | re.DOTALL
01241 
01242     Identifiers = r'[a-zA-Z]\w*'
01243     Literals = ['AppleScript', 'current application', 'false', 'linefeed',
01244                 'missing value', 'pi','quote', 'result', 'return', 'space',
01245                 'tab', 'text item delimiters', 'true', 'version']
01246     Classes = ['alias ', 'application ', 'boolean ', 'class ', 'constant ',
01247                'date ', 'file ', 'integer ', 'list ', 'number ', 'POSIX file ',
01248                'real ', 'record ', 'reference ', 'RGB color ', 'script ',
01249                'text ', 'unit types', '(Unicode )?text', 'string']
01250     BuiltIn = ['attachment', 'attribute run', 'character', 'day', 'month',
01251                'paragraph', 'word', 'year']
01252     HandlerParams = ['about', 'above', 'against', 'apart from', 'around',
01253                      'aside from', 'at', 'below', 'beneath', 'beside',
01254                      'between', 'for', 'given', 'instead of', 'on', 'onto',
01255                      'out of', 'over', 'since']
01256     Commands = ['ASCII (character|number)', 'activate', 'beep', 'choose URL',
01257                 'choose application', 'choose color', 'choose file( name)?',
01258                 'choose folder', 'choose from list',
01259                 'choose remote application', 'clipboard info',
01260                 'close( access)?', 'copy', 'count', 'current date', 'delay',
01261                 'delete', 'display (alert|dialog)', 'do shell script',
01262                 'duplicate', 'exists', 'get eof', 'get volume settings',
01263                 'info for', 'launch', 'list (disks|folder)', 'load script',
01264                 'log', 'make', 'mount volume', 'new', 'offset',
01265                 'open( (for access|location))?', 'path to', 'print', 'quit',
01266                 'random number', 'read', 'round', 'run( script)?',
01267                 'say', 'scripting components',
01268                 'set (eof|the clipboard to|volume)', 'store script',
01269                 'summarize', 'system attribute', 'system info',
01270                 'the clipboard', 'time to GMT', 'write', 'quoted form']
01271     References = ['(in )?back of', '(in )?front of', '[0-9]+(st|nd|rd|th)',
01272                   'first', 'second', 'third', 'fourth', 'fifth', 'sixth',
01273                   'seventh', 'eighth', 'ninth', 'tenth', 'after', 'back',
01274                   'before', 'behind', 'every', 'front', 'index', 'last',
01275                   'middle', 'some', 'that', 'through', 'thru', 'where', 'whose']
01276     Operators = ["and", "or", "is equal", "equals", "(is )?equal to", "is not",
01277                  "isn't", "isn't equal( to)?", "is not equal( to)?",
01278                  "doesn't equal", "does not equal", "(is )?greater than",
01279                  "comes after", "is not less than or equal( to)?",
01280                  "isn't less than or equal( to)?", "(is )?less than",
01281                  "comes before", "is not greater than or equal( to)?",
01282                  "isn't greater than or equal( to)?",
01283                  "(is  )?greater than or equal( to)?", "is not less than",
01284                  "isn't less than", "does not come before",
01285                  "doesn't come before", "(is )?less than or equal( to)?",
01286                  "is not greater than", "isn't greater than",
01287                  "does not come after", "doesn't come after", "starts? with",
01288                  "begins? with", "ends? with", "contains?", "does not contain",
01289                  "doesn't contain", "is in", "is contained by", "is not in",
01290                  "is not contained by", "isn't contained by", "div", "mod",
01291                  "not", "(a  )?(ref( to)?|reference to)", "is", "does"]
01292     Control = ['considering', 'else', 'error', 'exit', 'from', 'if',
01293                'ignoring', 'in', 'repeat', 'tell', 'then', 'times', 'to',
01294                'try', 'until', 'using terms from', 'while', 'whith',
01295                'with timeout( of)?', 'with transaction', 'by', 'continue',
01296                'end', 'its?', 'me', 'my', 'return', 'of' , 'as']
01297     Declarations = ['global', 'local', 'prop(erty)?', 'set', 'get']
01298     Reserved = ['but', 'put', 'returning', 'the']
01299     StudioClasses = ['action cell', 'alert reply', 'application', 'box',
01300                      'browser( cell)?', 'bundle', 'button( cell)?', 'cell',
01301                      'clip view', 'color well', 'color-panel',
01302                      'combo box( item)?', 'control',
01303                      'data( (cell|column|item|row|source))?', 'default entry',
01304                      'dialog reply', 'document', 'drag info', 'drawer',
01305                      'event', 'font(-panel)?', 'formatter',
01306                      'image( (cell|view))?', 'matrix', 'menu( item)?', 'item',
01307                      'movie( view)?', 'open-panel', 'outline view', 'panel',
01308                      'pasteboard', 'plugin', 'popup button',
01309                      'progress indicator', 'responder', 'save-panel',
01310                      'scroll view', 'secure text field( cell)?', 'slider',
01311                      'sound', 'split view', 'stepper', 'tab view( item)?',
01312                      'table( (column|header cell|header view|view))',
01313                      'text( (field( cell)?|view))?', 'toolbar( item)?',
01314                      'user-defaults', 'view', 'window']
01315     StudioEvents = ['accept outline drop', 'accept table drop', 'action',
01316                     'activated', 'alert ended', 'awake from nib', 'became key',
01317                     'became main', 'begin editing', 'bounds changed',
01318                     'cell value', 'cell value changed', 'change cell value',
01319                     'change item value', 'changed', 'child of item',
01320                     'choose menu item', 'clicked', 'clicked toolbar item',
01321                     'closed', 'column clicked', 'column moved',
01322                     'column resized', 'conclude drop', 'data representation',
01323                     'deminiaturized', 'dialog ended', 'document nib name',
01324                     'double clicked', 'drag( (entered|exited|updated))?',
01325                     'drop', 'end editing', 'exposed', 'idle', 'item expandable',
01326                     'item value', 'item value changed', 'items changed',
01327                     'keyboard down', 'keyboard up', 'launched',
01328                     'load data representation', 'miniaturized', 'mouse down',
01329                     'mouse dragged', 'mouse entered', 'mouse exited',
01330                     'mouse moved', 'mouse up', 'moved',
01331                     'number of browser rows', 'number of items',
01332                     'number of rows', 'open untitled', 'opened', 'panel ended',
01333                     'parameters updated', 'plugin loaded', 'prepare drop',
01334                     'prepare outline drag', 'prepare outline drop',
01335                     'prepare table drag', 'prepare table drop',
01336                     'read from file', 'resigned active', 'resigned key',
01337                     'resigned main', 'resized( sub views)?',
01338                     'right mouse down', 'right mouse dragged',
01339                     'right mouse up', 'rows changed', 'scroll wheel',
01340                     'selected tab view item', 'selection changed',
01341                     'selection changing', 'should begin editing',
01342                     'should close', 'should collapse item',
01343                     'should end editing', 'should expand item',
01344                     'should open( untitled)?',
01345                     'should quit( after last window closed)?',
01346                     'should select column', 'should select item',
01347                     'should select row', 'should select tab view item',
01348                     'should selection change', 'should zoom', 'shown',
01349                     'update menu item', 'update parameters',
01350                     'update toolbar item', 'was hidden', 'was miniaturized',
01351                     'will become active', 'will close', 'will dismiss',
01352                     'will display browser cell', 'will display cell',
01353                     'will display item cell', 'will display outline cell',
01354                     'will finish launching', 'will hide', 'will miniaturize',
01355                     'will move', 'will open', 'will pop up', 'will quit',
01356                     'will resign active', 'will resize( sub views)?',
01357                     'will select tab view item', 'will show', 'will zoom',
01358                     'write to file', 'zoomed']
01359     StudioCommands = ['animate', 'append', 'call method', 'center',
01360                       'close drawer', 'close panel', 'display',
01361                       'display alert', 'display dialog', 'display panel', 'go',
01362                       'hide', 'highlight', 'increment', 'item for',
01363                       'load image', 'load movie', 'load nib', 'load panel',
01364                       'load sound', 'localized string', 'lock focus', 'log',
01365                       'open drawer', 'path for', 'pause', 'perform action',
01366                       'play', 'register', 'resume', 'scroll', 'select( all)?',
01367                       'show', 'size to fit', 'start', 'step back',
01368                       'step forward', 'stop', 'synchronize', 'unlock focus',
01369                       'update']
01370     StudioProperties = ['accepts arrow key', 'action method', 'active',
01371                         'alignment', 'allowed identifiers',
01372                         'allows branch selection', 'allows column reordering',
01373                         'allows column resizing', 'allows column selection',
01374                         'allows customization',
01375                         'allows editing text attributes',
01376                         'allows empty selection', 'allows mixed state',
01377                         'allows multiple selection', 'allows reordering',
01378                         'allows undo', 'alpha( value)?', 'alternate image',
01379                         'alternate increment value', 'alternate title',
01380                         'animation delay', 'associated file name',
01381                         'associated object', 'auto completes', 'auto display',
01382                         'auto enables items', 'auto repeat',
01383                         'auto resizes( outline column)?',
01384                         'auto save expanded items', 'auto save name',
01385                         'auto save table columns', 'auto saves configuration',
01386                         'auto scroll', 'auto sizes all columns to fit',
01387                         'auto sizes cells', 'background color', 'bezel state',
01388                         'bezel style', 'bezeled', 'border rect', 'border type',
01389                         'bordered', 'bounds( rotation)?', 'box type',
01390                         'button returned', 'button type',
01391                         'can choose directories', 'can choose files',
01392                         'can draw', 'can hide',
01393                         'cell( (background color|size|type))?', 'characters',
01394                         'class', 'click count', 'clicked( data)? column',
01395                         'clicked data item', 'clicked( data)? row',
01396                         'closeable', 'collating', 'color( (mode|panel))',
01397                         'command key down', 'configuration',
01398                         'content(s| (size|view( margins)?))?', 'context',
01399                         'continuous', 'control key down', 'control size',
01400                         'control tint', 'control view',
01401                         'controller visible', 'coordinate system',
01402                         'copies( on scroll)?', 'corner view', 'current cell',
01403                         'current column', 'current( field)?  editor',
01404                         'current( menu)? item', 'current row',
01405                         'current tab view item', 'data source',
01406                         'default identifiers', 'delta (x|y|z)',
01407                         'destination window', 'directory', 'display mode',
01408                         'displayed cell', 'document( (edited|rect|view))?',
01409                         'double value', 'dragged column', 'dragged distance',
01410                         'dragged items', 'draws( cell)? background',
01411                         'draws grid', 'dynamically scrolls', 'echos bullets',
01412                         'edge', 'editable', 'edited( data)? column',
01413                         'edited data item', 'edited( data)? row', 'enabled',
01414                         'enclosing scroll view', 'ending page',
01415                         'error handling', 'event number', 'event type',
01416                         'excluded from windows menu', 'executable path',
01417                         'expanded', 'fax number', 'field editor', 'file kind',
01418                         'file name', 'file type', 'first responder',
01419                         'first visible column', 'flipped', 'floating',
01420                         'font( panel)?', 'formatter', 'frameworks path',
01421                         'frontmost', 'gave up', 'grid color', 'has data items',
01422                         'has horizontal ruler', 'has horizontal scroller',
01423                         'has parent data item', 'has resize indicator',
01424                         'has shadow', 'has sub menu', 'has vertical ruler',
01425                         'has vertical scroller', 'header cell', 'header view',
01426                         'hidden', 'hides when deactivated', 'highlights by',
01427                         'horizontal line scroll', 'horizontal page scroll',
01428                         'horizontal ruler view', 'horizontally resizable',
01429                         'icon image', 'id', 'identifier',
01430                         'ignores multiple clicks',
01431                         'image( (alignment|dims when disabled|frame style|'
01432                             'scaling))?',
01433                         'imports graphics', 'increment value',
01434                         'indentation per level', 'indeterminate', 'index',
01435                         'integer value', 'intercell spacing', 'item height',
01436                         'key( (code|equivalent( modifier)?|window))?',
01437                         'knob thickness', 'label', 'last( visible)? column',
01438                         'leading offset', 'leaf', 'level', 'line scroll',
01439                         'loaded', 'localized sort', 'location', 'loop mode',
01440                         'main( (bunde|menu|window))?', 'marker follows cell',
01441                         'matrix mode', 'maximum( content)? size',
01442                         'maximum visible columns',
01443                         'menu( form representation)?', 'miniaturizable',
01444                         'miniaturized', 'minimized image', 'minimized title',
01445                         'minimum column width', 'minimum( content)? size',
01446                         'modal', 'modified', 'mouse down state',
01447                         'movie( (controller|file|rect))?', 'muted', 'name',
01448                         'needs display', 'next state', 'next text',
01449                         'number of tick marks', 'only tick mark values',
01450                         'opaque', 'open panel', 'option key down',
01451                         'outline table column', 'page scroll', 'pages across',
01452                         'pages down', 'palette label', 'pane splitter',
01453                         'parent data item', 'parent window', 'pasteboard',
01454                         'path( (names|separator))?', 'playing',
01455                         'plays every frame', 'plays selection only', 'position',
01456                         'preferred edge', 'preferred type', 'pressure',
01457                         'previous text', 'prompt', 'properties',
01458                         'prototype cell', 'pulls down', 'rate',
01459                         'released when closed', 'repeated',
01460                         'requested print time', 'required file type',
01461                         'resizable', 'resized column', 'resource path',
01462                         'returns records', 'reuses columns', 'rich text',
01463                         'roll over', 'row height', 'rulers visible',
01464                         'save panel', 'scripts path', 'scrollable',
01465                         'selectable( identifiers)?', 'selected cell',
01466                         'selected( data)? columns?', 'selected data items?',
01467                         'selected( data)? rows?', 'selected item identifier',
01468                         'selection by rect', 'send action on arrow key',
01469                         'sends action when done editing', 'separates columns',
01470                         'separator item', 'sequence number', 'services menu',
01471                         'shared frameworks path', 'shared support path',
01472                         'sheet', 'shift key down', 'shows alpha',
01473                         'shows state by', 'size( mode)?',
01474                         'smart insert delete enabled', 'sort case sensitivity',
01475                         'sort column', 'sort order', 'sort type',
01476                         'sorted( data rows)?', 'sound', 'source( mask)?',
01477                         'spell checking enabled', 'starting page', 'state',
01478                         'string value', 'sub menu', 'super menu', 'super view',
01479                         'tab key traverses cells', 'tab state', 'tab type',
01480                         'tab view', 'table view', 'tag', 'target( printer)?',
01481                         'text color', 'text container insert',
01482                         'text container origin', 'text returned',
01483                         'tick mark position', 'time stamp',
01484                         'title(d| (cell|font|height|position|rect))?',
01485                         'tool tip', 'toolbar', 'trailing offset', 'transparent',
01486                         'treat packages as directories', 'truncated labels',
01487                         'types', 'unmodified characters', 'update views',
01488                         'use sort indicator', 'user defaults',
01489                         'uses data source', 'uses ruler',
01490                         'uses threaded animation',
01491                         'uses title from previous column', 'value wraps',
01492                         'version',
01493                         'vertical( (line scroll|page scroll|ruler view))?',
01494                         'vertically resizable', 'view',
01495                         'visible( document rect)?', 'volume', 'width', 'window',
01496                         'windows menu', 'wraps', 'zoomable', 'zoomed']
01497 
01498     tokens = {
01499         'root': [
01500             (r'\s+', Text),
01501             (ur'¬\n', String.Escape),
01502             (r"'s\s+", Text), # This is a possessive, consider moving
01503             (r'(--|#).*?$', Comment),
01504             (r'\(\*', Comment.Multiline, 'comment'),
01505             (r'[\(\){}!,.:]', Punctuation),
01506             (ur'(«)([^»]+)(»)',
01507              bygroups(Text, Name.Builtin, Text)),
01508             (r'\b((?:considering|ignoring)\s*)'
01509              r'(application responses|case|diacriticals|hyphens|'
01510              r'numeric strings|punctuation|white space)',
01511              bygroups(Keyword, Name.Builtin)),
01512             (ur'(-|\*|\+|&|≠|>=?|<=?|=|≥|≤|/|÷|\^)', Operator),
01513             (r"\b(%s)\b" % '|'.join(Operators), Operator.Word),
01514             (r'^(\s*(?:on|end)\s+)'
01515              r'(%s)' % '|'.join(StudioEvents),
01516              bygroups(Keyword, Name.Function)),
01517             (r'^(\s*)(in|on|script|to)(\s+)', bygroups(Text, Keyword, Text)),
01518             (r'\b(as )(%s)\b' % '|'.join(Classes),
01519              bygroups(Keyword, Name.Class)),
01520             (r'\b(%s)\b' % '|'.join(Literals), Name.Constant),
01521             (r'\b(%s)\b' % '|'.join(Commands), Name.Builtin),
01522             (r'\b(%s)\b' % '|'.join(Control), Keyword),
01523             (r'\b(%s)\b' % '|'.join(Declarations), Keyword),
01524             (r'\b(%s)\b' % '|'.join(Reserved), Name.Builtin),
01525             (r'\b(%s)s?\b' % '|'.join(BuiltIn), Name.Builtin),
01526             (r'\b(%s)\b' % '|'.join(HandlerParams), Name.Builtin),
01527             (r'\b(%s)\b' % '|'.join(StudioProperties), Name.Attribute),
01528             (r'\b(%s)s?\b' % '|'.join(StudioClasses), Name.Builtin),
01529             (r'\b(%s)\b' % '|'.join(StudioCommands), Name.Builtin),
01530             (r'\b(%s)\b' % '|'.join(References), Name.Builtin),
01531             (r'"(\\\\|\\"|[^"])*"', String.Double),
01532             (r'\b(%s)\b' % Identifiers, Name.Variable),
01533             (r'[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?', Number.Float),
01534             (r'[-+]?\d+', Number.Integer),
01535         ],
01536         'comment': [
01537             ('\(\*', Comment.Multiline, '#push'),
01538             ('\*\)', Comment.Multiline, '#pop'),
01539             ('[^*(]+', Comment.Multiline),
01540             ('[*(]', Comment.Multiline),
01541         ],
01542     }
01543 
01544 
01545 class ModelicaLexer(RegexLexer):
01546     """
01547     For `Modelica <http://www.modelica.org/>`_ source code.
01548 
01549     *New in Pygments 1.1.*
01550     """
01551     name = 'Modelica'
01552     aliases = ['modelica']
01553     filenames = ['*.mo']
01554     mimetypes = ['text/x-modelica']
01555 
01556     flags = re.IGNORECASE | re.DOTALL
01557 
01558     tokens = {
01559         'whitespace': [
01560             (r'\n', Text),
01561             (r'\s+', Text),
01562             (r'\\\n', Text), # line continuation
01563             (r'//(\n|(.|\n)*?[^\\]\n)', Comment),
01564             (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment),
01565         ],
01566         'statements': [
01567             (r'"', String, 'string'),
01568             (r'(\d+\.\d*|\.\d+|\d+|\d.)[eE][+-]?\d+[lL]?', Number.Float),
01569             (r'(\d+\.\d*|\.\d+)', Number.Float),
01570             (r'\d+[Ll]?', Number.Integer),
01571             (r'[~!%^&*+=|?:<>/-]', Operator),
01572             (r'[()\[\]{},.;]', Punctuation),
01573             (r'(true|false|NULL|Real|Integer|Boolean)\b', Name.Builtin),
01574             (r"([a-zA-Z_][\w]*|'[a-zA-Z_\+\-\*\/\^][\w]*')"
01575              r"(\.([a-zA-Z_][\w]*|'[a-zA-Z_\+\-\*\/\^][\w]*'))+", Name.Class),
01576             (r"('[\w\+\-\*\/\^]+'|\w+)", Name)        ],
01577         'root': [
01578             include('whitespace'),
01579             include('keywords'),
01580             include('functions'),
01581             include('operators'),
01582             include('classes'),
01583             (r'("<html>|<html>)', Name.Tag, 'html-content'),
01584             include('statements')
01585         ],
01586         'keywords': [
01587             (r'(algorithm|annotation|break|connect|constant|constrainedby|'
01588             r'discrete|each|else|elseif|elsewhen|encapsulated|enumeration|'
01589             r'end|equation|exit|expandable|extends|'
01590             r'external|false|final|flow|for|if|import|in|inner|input|'
01591             r'loop|nondiscrete|outer|output|parameter|partial|'
01592             r'protected|public|redeclare|replaceable|stream|time|then|true|'
01593             r'when|while|within)\b', Keyword)
01594         ],
01595         'functions': [
01596             (r'(abs|acos|acosh|asin|asinh|atan|atan2|atan3|ceil|cos|cosh|'
01597              r'cross|div|exp|floor|log|log10|mod|rem|sign|sin|sinh|size|'
01598              r'sqrt|tan|tanh|zeros)\b', Name.Function)
01599         ],
01600         'operators': [
01601             (r'(and|assert|cardinality|change|delay|der|edge|initial|'
01602              r'noEvent|not|or|pre|reinit|return|sample|smooth|'
01603              r'terminal|terminate)\b', Name.Builtin)
01604         ],
01605         'classes': [
01606             (r'(block|class|connector|function|model|package|'
01607              r'record|type)\b', Name.Class)
01608         ],
01609         'string': [
01610             (r'"', String, '#pop'),
01611             (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})',
01612              String.Escape),
01613             (r'[^\\"\n]+', String), # all other characters
01614             (r'\\\n', String), # line continuation
01615             (r'\\', String) # stray backslash
01616         ],
01617         'html-content': [
01618             (r'<\s*/\s*html\s*>', Name.Tag, '#pop'),
01619             (r'.+?(?=<\s*/\s*html\s*>)', using(HtmlLexer)),
01620         ]
01621     }
01622 
01623 
01624 class RebolLexer(RegexLexer):
01625     """
01626     A `REBOL <http://www.rebol.com/>`_ lexer.
01627 
01628     *New in Pygments 1.1.*
01629     """
01630     name = 'REBOL'
01631     aliases = ['rebol']
01632     filenames = ['*.r', '*.r3']
01633     mimetypes = ['text/x-rebol']
01634 
01635     flags = re.IGNORECASE | re.MULTILINE
01636 
01637     re.IGNORECASE
01638 
01639     escape_re = r'(?:\^\([0-9a-fA-F]{1,4}\)*)'
01640 
01641     def word_callback(lexer, match):
01642         word = match.group()
01643 
01644         if re.match(".*:$", word):
01645             yield match.start(), Generic.Subheading, word
01646         elif re.match(
01647             r'(native|alias|all|any|as-string|as-binary|bind|bound\?|case|'
01648             r'catch|checksum|comment|debase|dehex|exclude|difference|disarm|'
01649             r'either|else|enbase|foreach|remove-each|form|free|get|get-env|if|'
01650             r'in|intersect|loop|minimum-of|maximum-of|mold|new-line|'
01651             r'new-line\?|not|now|prin|print|reduce|compose|construct|repeat|'
01652             r'reverse|save|script\?|set|shift|switch|throw|to-hex|trace|try|'
01653             r'type\?|union|unique|unless|unprotect|unset|until|use|value\?|'
01654             r'while|compress|decompress|secure|open|close|read|read-io|'
01655             r'write-io|write|update|query|wait|input\?|exp|log-10|log-2|'
01656             r'log-e|square-root|cosine|sine|tangent|arccosine|arcsine|'
01657             r'arctangent|protect|lowercase|uppercase|entab|detab|connected\?|'
01658             r'browse|launch|stats|get-modes|set-modes|to-local-file|'
01659             r'to-rebol-file|encloak|decloak|create-link|do-browser|bind\?|'
01660             r'hide|draw|show|size-text|textinfo|offset-to-caret|'
01661             r'caret-to-offset|local-request-file|rgb-to-hsv|hsv-to-rgb|'
01662             r'crypt-strength\?|dh-make-key|dh-generate-key|dh-compute-key|'
01663             r'dsa-make-key|dsa-generate-key|dsa-make-signature|'
01664             r'dsa-verify-signature|rsa-make-key|rsa-generate-key|'
01665             r'rsa-encrypt)$', word):
01666             yield match.start(), Name.Builtin, word
01667         elif re.match(
01668             r'(add|subtract|multiply|divide|remainder|power|and~|or~|xor~|'
01669             r'minimum|maximum|negate|complement|absolute|random|head|tail|'
01670             r'next|back|skip|at|pick|first|second|third|fourth|fifth|sixth|'
01671             r'seventh|eighth|ninth|tenth|last|path|find|select|make|to|copy\*|'
01672             r'insert|remove|change|poke|clear|trim|sort|min|max|abs|cp|'
01673             r'copy)$', word):
01674             yield match.start(), Name.Function, word
01675         elif re.match(
01676             r'(error|source|input|license|help|install|echo|Usage|with|func|'
01677             r'throw-on-error|function|does|has|context|probe|\?\?|as-pair|'
01678             r'mod|modulo|round|repend|about|set-net|append|join|rejoin|reform|'
01679             r'remold|charset|array|replace|move|extract|forskip|forall|alter|'
01680             r'first+|also|take|for|forever|dispatch|attempt|what-dir|'
01681             r'change-dir|clean-path|list-dir|dirize|rename|split-path|delete|'
01682             r'make-dir|delete-dir|in-dir|confirm|dump-obj|upgrade|what|'
01683             r'build-tag|process-source|build-markup|decode-cgi|read-cgi|'
01684             r'write-user|save-user|set-user-name|protect-system|parse-xml|'
01685             r'cvs-date|cvs-version|do-boot|get-net-info|desktop|layout|'
01686             r'scroll-para|get-face|alert|set-face|uninstall|unfocus|'
01687             r'request-dir|center-face|do-events|net-error|decode-url|'
01688             r'parse-header|parse-header-date|parse-email-addrs|import-email|'
01689             r'send|build-attach-body|resend|show-popup|hide-popup|open-events|'
01690             r'find-key-face|do-face|viewtop|confine|find-window|'
01691             r'insert-event-func|remove-event-func|inform|dump-pane|dump-face|'
01692             r'flag-face|deflag-face|clear-fields|read-net|vbug|path-thru|'
01693             r'read-thru|load-thru|do-thru|launch-thru|load-image|'
01694             r'request-download|do-face-alt|set-font|set-para|get-style|'
01695             r'set-style|make-face|stylize|choose|hilight-text|hilight-all|'
01696             r'unlight-text|focus|scroll-drag|clear-face|reset-face|scroll-face|'
01697             r'resize-face|load-stock|load-stock-block|notify|request|flash|'
01698             r'request-color|request-pass|request-text|request-list|'
01699             r'request-date|request-file|dbug|editor|link-relative-path|'
01700             r'emailer|parse-error)$', word):
01701             yield match.start(), Keyword.Namespace, word
01702         elif re.match(
01703             r'(halt|quit|do|load|q|recycle|call|run|ask|parse|view|unview|'
01704             r'return|exit|break)$', word):
01705             yield match.start(), Name.Exception, word
01706         elif re.match('REBOL$', word):
01707             yield match.start(), Generic.Heading, word
01708         elif re.match("to-.*", word):
01709             yield match.start(), Keyword, word
01710         elif re.match('(\+|-|\*|/|//|\*\*|and|or|xor|=\?|=|==|<>|<|>|<=|>=)$',
01711                       word):
01712             yield match.start(), Operator, word
01713         elif re.match(".*\?$", word):
01714             yield match.start(), Keyword, word
01715         elif re.match(".*\!$", word):
01716             yield match.start(), Keyword.Type, word
01717         elif re.match("'.*", word):
01718             yield match.start(), Name.Variable.Instance, word # lit-word
01719         elif re.match("#.*", word):
01720             yield match.start(), Name.Label, word # issue
01721         elif re.match("%.*", word):
01722             yield match.start(), Name.Decorator, word # file
01723         else:
01724             yield match.start(), Name.Variable, word
01725 
01726     tokens = {
01727         'root': [
01728             (r'\s+', Text),
01729             (r'#"', String.Char, 'char'),
01730             (r'#{[0-9a-fA-F]*}', Number.Hex),
01731             (r'2#{', Number.Hex, 'bin2'),
01732             (r'64#{[0-9a-zA-Z+/=\s]*}', Number.Hex),
01733             (r'"', String, 'string'),
01734             (r'{', String, 'string2'),
01735             (r';#+.*\n', Comment.Special),
01736             (r';\*+.*\n', Comment.Preproc),
01737             (r';.*\n', Comment),
01738             (r'%"', Name.Decorator, 'stringFile'),
01739             (r'%[^(\^{^")\s\[\]]+', Name.Decorator),
01740             (r'<[a-zA-Z0-9:._-]*>', Name.Tag),
01741             (r'<[^(<>\s")]+', Name.Tag, 'tag'),
01742             (r'[+-]?([a-zA-Z]{1,3})?\$\d+(\.\d+)?', Number.Float), # money
01743             (r'[+-]?\d+\:\d+(\:\d+)?(\.\d+)?', String.Other), # time
01744             (r'\d+\-[0-9a-zA-Z]+\-\d+(\/\d+\:\d+(\:\d+)?'
01745              r'([\.\d+]?([+-]?\d+:\d+)?)?)?', String.Other), # date
01746             (r'\d+(\.\d+)+\.\d+', Keyword.Constant), # tuple
01747             (r'\d+[xX]\d+', Keyword.Constant), # pair
01748             (r'[+-]?\d+(\'\d+)?([\.,]\d*)?[eE][+-]?\d+', Number.Float),
01749             (r'[+-]?\d+(\'\d+)?[\.,]\d*', Number.Float),
01750             (r'[+-]?\d+(\'\d+)?', Number),
01751             (r'[\[\]\(\)]', Generic.Strong),
01752             (r'[a-zA-Z]+[^(\^{"\s:)]*://[^(\^{"\s)]*', Name.Decorator), # url
01753             (r'mailto:[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # url
01754             (r'[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # email
01755             (r'comment\s', Comment, 'comment'),
01756             (r'/[^(\^{^")\s/[\]]*', Name.Attribute),
01757             (r'([^(\^{^")\s/[\]]+)(?=[:({"\s/\[\]])', word_callback),
01758             (r'([^(\^{^")\s]+)', Text),
01759         ],
01760         'string': [
01761             (r'[^(\^")]+', String),
01762             (escape_re, String.Escape),
01763             (r'[\(|\)]+', String),
01764             (r'\^.', String.Escape),
01765             (r'"', String, '#pop'),
01766         ],
01767         'string2': [
01768             (r'[^(\^{^})]+', String),
01769             (escape_re, String.Escape),
01770             (r'[\(|\)]+', String),
01771             (r'\^.', String.Escape),
01772             (r'{', String, '#push'),
01773             (r'}', String, '#pop'),
01774         ],
01775         'stringFile': [
01776             (r'[^(\^")]+', Name.Decorator),
01777             (escape_re, Name.Decorator),
01778             (r'\^.', Name.Decorator),
01779             (r'"', Name.Decorator, '#pop'),
01780         ],
01781         'char': [
01782             (escape_re + '"', String.Char, '#pop'),
01783             (r'\^."', String.Char, '#pop'),
01784             (r'."', String.Char, '#pop'),
01785         ],
01786         'tag': [
01787             (escape_re, Name.Tag),
01788             (r'"', Name.Tag, 'tagString'),
01789             (r'[^(<>\r\n")]+', Name.Tag),
01790             (r'>', Name.Tag, '#pop'),
01791         ],
01792         'tagString': [
01793             (r'[^(\^")]+', Name.Tag),
01794             (escape_re, Name.Tag),
01795             (r'[\(|\)]+', Name.Tag),
01796             (r'\^.', Name.Tag),
01797             (r'"', Name.Tag, '#pop'),
01798         ],
01799         'tuple': [
01800             (r'(\d+\.)+', Keyword.Constant),
01801             (r'\d+', Keyword.Constant, '#pop'),
01802         ],
01803         'bin2': [
01804             (r'\s+', Number.Hex),
01805             (r'([0-1]\s*){8}', Number.Hex),
01806             (r'}', Number.Hex, '#pop'),
01807         ],
01808         'comment': [
01809             (r'"', Comment, 'commentString1'),
01810             (r'{', Comment, 'commentString2'),
01811             (r'\[', Comment, 'commentBlock'),
01812             (r'[^(\s{\"\[]+', Comment, '#pop'),
01813         ],
01814         'commentString1': [
01815             (r'[^(\^")]+', Comment),
01816             (escape_re, Comment),
01817             (r'[\(|\)]+', Comment),
01818             (r'\^.', Comment),
01819             (r'"', Comment, '#pop'),
01820         ],
01821         'commentString2': [
01822             (r'[^(\^{^})]+', Comment),
01823             (escape_re, Comment),
01824             (r'[\(|\)]+', Comment),
01825             (r'\^.', Comment),
01826             (r'{', Comment, '#push'),
01827             (r'}', Comment, '#pop'),
01828         ],
01829         'commentBlock': [
01830             (r'\[',Comment, '#push'),
01831             (r'\]',Comment, '#pop'),
01832             (r'[^(\[\])]*', Comment),
01833         ],
01834     }
01835 
01836 
01837 class ABAPLexer(RegexLexer):
01838     """
01839     Lexer for ABAP, SAP's integrated language.
01840 
01841     *New in Pygments 1.1.*
01842     """
01843     name = 'ABAP'
01844     aliases = ['abap']
01845     filenames = ['*.abap']
01846     mimetypes = ['text/x-abap']
01847 
01848     flags = re.IGNORECASE | re.MULTILINE
01849 
01850     tokens = {
01851         'common': [
01852             (r'\s+', Text),
01853             (r'^\*.*$', Comment.Single),
01854             (r'\".*?\n', Comment.Single),
01855             ],
01856         'variable-names': [
01857             (r'<[\S_]+>', Name.Variable),
01858             (r'[\w][\w_~]*(?:(\[\])|->\*)?', Name.Variable),
01859             ],
01860         'root': [
01861             include('common'),
01862             #function calls
01863             (r'(CALL\s+(?:BADI|CUSTOMER-FUNCTION|FUNCTION))(\s+)(\'?\S+\'?)',
01864                 bygroups(Keyword, Text, Name.Function)),
01865             (r'(CALL\s+(?:DIALOG|SCREEN|SUBSCREEN|SELECTION-SCREEN|'
01866              r'TRANSACTION|TRANSFORMATION))\b',
01867                 Keyword),
01868             (r'(FORM|PERFORM)(\s+)([\w_]+)',
01869                 bygroups(Keyword, Text, Name.Function)),
01870             (r'(PERFORM)(\s+)(\()([\w_]+)(\))',
01871                 bygroups(Keyword, Text, Punctuation, Name.Variable, Punctuation )),
01872             (r'(MODULE)(\s+)(\S+)(\s+)(INPUT|OUTPUT)',
01873                 bygroups(Keyword, Text, Name.Function, Text, Keyword)),
01874 
01875             # method implementation
01876             (r'(METHOD)(\s+)([\w_~]+)',
01877                 bygroups(Keyword, Text, Name.Function)),
01878             # method calls
01879             (r'(\s+)([\w_\-]+)([=\-]>)([\w_\-~]+)',
01880                 bygroups(Text, Name.Variable, Operator, Name.Function)),
01881             # call methodnames returning style
01882             (r'(?<=(=|-)>)([\w_\-~]+)(?=\()', Name.Function),
01883 
01884             # keywords with dashes in them.
01885             # these need to be first, because for instance the -ID part
01886             # of MESSAGE-ID wouldn't get highlighted if MESSAGE was
01887             # first in the list of keywords.
01888             (r'(ADD-CORRESPONDING|AUTHORITY-CHECK|'
01889              r'CLASS-DATA|CLASS-EVENTS|CLASS-METHODS|CLASS-POOL|'
01890              r'DELETE-ADJACENT|DIVIDE-CORRESPONDING|'
01891              r'EDITOR-CALL|ENHANCEMENT-POINT|ENHANCEMENT-SECTION|EXIT-COMMAND|'
01892              r'FIELD-GROUPS|FIELD-SYMBOLS|FUNCTION-POOL|'
01893              r'INTERFACE-POOL|INVERTED-DATE|'
01894              r'LOAD-OF-PROGRAM|LOG-POINT|'
01895              r'MESSAGE-ID|MOVE-CORRESPONDING|MULTIPLY-CORRESPONDING|'
01896              r'NEW-LINE|NEW-PAGE|NEW-SECTION|NO-EXTENSION|'
01897              r'OUTPUT-LENGTH|PRINT-CONTROL|'
01898              r'SELECT-OPTIONS|START-OF-SELECTION|SUBTRACT-CORRESPONDING|'
01899              r'SYNTAX-CHECK|SYSTEM-EXCEPTIONS|'
01900              r'TYPE-POOL|TYPE-POOLS'
01901              r')\b', Keyword),
01902 
01903              # keyword kombinations
01904             (r'CREATE\s+(PUBLIC|PRIVATE|DATA|OBJECT)|'
01905              r'((PUBLIC|PRIVATE|PROTECTED)\s+SECTION|'
01906              r'(TYPE|LIKE)(\s+(LINE\s+OF|REF\s+TO|'
01907              r'(SORTED|STANDARD|HASHED)\s+TABLE\s+OF))?|'
01908              r'FROM\s+(DATABASE|MEMORY)|CALL\s+METHOD|'
01909              r'(GROUP|ORDER) BY|HAVING|SEPARATED BY|'
01910              r'GET\s+(BADI|BIT|CURSOR|DATASET|LOCALE|PARAMETER|'
01911                       r'PF-STATUS|(PROPERTY|REFERENCE)\s+OF|'
01912                       r'RUN\s+TIME|TIME\s+(STAMP)?)?|'
01913              r'SET\s+(BIT|BLANK\s+LINES|COUNTRY|CURSOR|DATASET|EXTENDED\s+CHECK|'
01914                       r'HANDLER|HOLD\s+DATA|LANGUAGE|LEFT\s+SCROLL-BOUNDARY|'
01915                       r'LOCALE|MARGIN|PARAMETER|PF-STATUS|PROPERTY\s+OF|'
01916                       r'RUN\s+TIME\s+(ANALYZER|CLOCK\s+RESOLUTION)|SCREEN|'
01917                       r'TITLEBAR|UPADTE\s+TASK\s+LOCAL|USER-COMMAND)|'
01918              r'CONVERT\s+((INVERTED-)?DATE|TIME|TIME\s+STAMP|TEXT)|'
01919              r'(CLOSE|OPEN)\s+(DATASET|CURSOR)|'
01920              r'(TO|FROM)\s+(DATA BUFFER|INTERNAL TABLE|MEMORY ID|'
01921                             r'DATABASE|SHARED\s+(MEMORY|BUFFER))|'
01922              r'DESCRIBE\s+(DISTANCE\s+BETWEEN|FIELD|LIST|TABLE)|'
01923              r'FREE\s(MEMORY|OBJECT)?|'
01924              r'PROCESS\s+(BEFORE\s+OUTPUT|AFTER\s+INPUT|'
01925                           r'ON\s+(VALUE-REQUEST|HELP-REQUEST))|'
01926              r'AT\s+(LINE-SELECTION|USER-COMMAND|END\s+OF|NEW)|'
01927              r'AT\s+SELECTION-SCREEN(\s+(ON(\s+(BLOCK|(HELP|VALUE)-REQUEST\s+FOR|'
01928                                      r'END\s+OF|RADIOBUTTON\s+GROUP))?|OUTPUT))?|'
01929              r'SELECTION-SCREEN:?\s+((BEGIN|END)\s+OF\s+((TABBED\s+)?BLOCK|LINE|'
01930                                      r'SCREEN)|COMMENT|FUNCTION\s+KEY|'
01931                                      r'INCLUDE\s+BLOCKS|POSITION|PUSHBUTTON|'
01932                                      r'SKIP|ULINE)|'
01933              r'LEAVE\s+(LIST-PROCESSING|PROGRAM|SCREEN|'
01934                         r'TO LIST-PROCESSING|TO TRANSACTION)'
01935              r'(ENDING|STARTING)\s+AT|'
01936              r'FORMAT\s+(COLOR|INTENSIFIED|INVERSE|HOTSPOT|INPUT|FRAMES|RESET)|'
01937              r'AS\s+(CHECKBOX|SUBSCREEN|WINDOW)|'
01938              r'WITH\s+(((NON-)?UNIQUE)?\s+KEY|FRAME)|'
01939              r'(BEGIN|END)\s+OF|'
01940              r'DELETE(\s+ADJACENT\s+DUPLICATES\sFROM)?|'
01941              r'COMPARING(\s+ALL\s+FIELDS)?|'
01942              r'INSERT(\s+INITIAL\s+LINE\s+INTO|\s+LINES\s+OF)?|'
01943              r'IN\s+((BYTE|CHARACTER)\s+MODE|PROGRAM)|'
01944              r'END-OF-(DEFINITION|PAGE|SELECTION)|'
01945              r'WITH\s+FRAME(\s+TITLE)|'
01946 
01947              # simple kombinations
01948              r'AND\s+(MARK|RETURN)|CLIENT\s+SPECIFIED|CORRESPONDING\s+FIELDS\s+OF|'
01949              r'IF\s+FOUND|FOR\s+EVENT|INHERITING\s+FROM|LEAVE\s+TO\s+SCREEN|'
01950              r'LOOP\s+AT\s+(SCREEN)?|LOWER\s+CASE|MATCHCODE\s+OBJECT|MODIF\s+ID|'
01951              r'MODIFY\s+SCREEN|NESTING\s+LEVEL|NO\s+INTERVALS|OF\s+STRUCTURE|'
01952              r'RADIOBUTTON\s+GROUP|RANGE\s+OF|REF\s+TO|SUPPRESS DIALOG|'
01953              r'TABLE\s+OF|UPPER\s+CASE|TRANSPORTING\s+NO\s+FIELDS|'
01954              r'VALUE\s+CHECK|VISIBLE\s+LENGTH|HEADER\s+LINE)\b', Keyword),
01955 
01956             # single word keywords.
01957             (r'(^|(?<=(\s|\.)))(ABBREVIATED|ADD|ALIASES|APPEND|ASSERT|'
01958              r'ASSIGN(ING)?|AT(\s+FIRST)?|'
01959              r'BACK|BLOCK|BREAK-POINT|'
01960              r'CASE|CATCH|CHANGING|CHECK|CLASS|CLEAR|COLLECT|COLOR|COMMIT|'
01961              r'CREATE|COMMUNICATION|COMPONENTS?|COMPUTE|CONCATENATE|CONDENSE|'
01962              r'CONSTANTS|CONTEXTS|CONTINUE|CONTROLS|'
01963              r'DATA|DECIMALS|DEFAULT|DEFINE|DEFINITION|DEFERRED|DEMAND|'
01964              r'DETAIL|DIRECTORY|DIVIDE|DO|'
01965              r'ELSE(IF)?|ENDAT|ENDCASE|ENDCLASS|ENDDO|ENDFORM|ENDFUNCTION|'
01966              r'ENDIF|ENDLOOP|ENDMETHOD|ENDMODULE|ENDSELECT|ENDTRY|'
01967              r'ENHANCEMENT|EVENTS|EXCEPTIONS|EXIT|EXPORT|EXPORTING|EXTRACT|'
01968              r'FETCH|FIELDS?|FIND|FOR|FORM|FORMAT|FREE|FROM|'
01969              r'HIDE|'
01970              r'ID|IF|IMPORT|IMPLEMENTATION|IMPORTING|IN|INCLUDE|INCLUDING|'
01971              r'INDEX|INFOTYPES|INITIALIZATION|INTERFACE|INTERFACES|INTO|'
01972              r'LENGTH|LINES|LOAD|LOCAL|'
01973              r'JOIN|'
01974              r'KEY|'
01975              r'MAXIMUM|MESSAGE|METHOD[S]?|MINIMUM|MODULE|MODIFY|MOVE|MULTIPLY|'
01976              r'NODES|'
01977              r'OBLIGATORY|OF|OFF|ON|OVERLAY|'
01978              r'PACK|PARAMETERS|PERCENTAGE|POSITION|PROGRAM|PROVIDE|PUBLIC|PUT|'
01979              r'RAISE|RAISING|RANGES|READ|RECEIVE|REFRESH|REJECT|REPORT|RESERVE|'
01980              r'RESUME|RETRY|RETURN|RETURNING|RIGHT|ROLLBACK|'
01981              r'SCROLL|SEARCH|SELECT|SHIFT|SINGLE|SKIP|SORT|SPLIT|STATICS|STOP|'
01982              r'SUBMIT|SUBTRACT|SUM|SUMMARY|SUMMING|SUPPLY|'
01983              r'TABLE|TABLES|TIMES|TITLE|TO|TOP-OF-PAGE|TRANSFER|TRANSLATE|TRY|TYPES|'
01984              r'ULINE|UNDER|UNPACK|UPDATE|USING|'
01985              r'VALUE|VALUES|VIA|'
01986              r'WAIT|WHEN|WHERE|WHILE|WITH|WINDOW|WRITE)\b', Keyword),
01987 
01988              # builtins
01989             (r'(abs|acos|asin|atan|'
01990              r'boolc|boolx|bit_set|'
01991              r'char_off|charlen|ceil|cmax|cmin|condense|contains|'
01992              r'contains_any_of|contains_any_not_of|concat_lines_of|cos|cosh|'
01993              r'count|count_any_of|count_any_not_of|'
01994              r'dbmaxlen|distance|'
01995              r'escape|exp|'
01996              r'find|find_end|find_any_of|find_any_not_of|floor|frac|from_mixed|'
01997              r'insert|'
01998              r'lines|log|log10|'
01999              r'match|matches|'
02000              r'nmax|nmin|numofchar|'
02001              r'repeat|replace|rescale|reverse|round|'
02002              r'segment|shift_left|shift_right|sign|sin|sinh|sqrt|strlen|'
02003              r'substring|substring_after|substring_from|substring_before|substring_to|'
02004              r'tan|tanh|to_upper|to_lower|to_mixed|translate|trunc|'
02005              r'xstrlen)(\()\b', bygroups(Name.Builtin, Punctuation)),
02006 
02007             (r'&[0-9]', Name),
02008             (r'[0-9]+', Number.Integer),
02009 
02010             # operators which look like variable names before
02011             # parsing variable names.
02012             (r'(?<=(\s|.))(AND|EQ|NE|GT|LT|GE|LE|CO|CN|CA|NA|CS|NOT|NS|CP|NP|'
02013              r'BYTE-CO|BYTE-CN|BYTE-CA|BYTE-NA|BYTE-CS|BYTE-NS|'
02014              r'IS\s+(NOT\s+)?(INITIAL|ASSIGNED|REQUESTED|BOUND))\b', Operator),
02015 
02016             include('variable-names'),
02017 
02018             # standard oparators after variable names,
02019             # because < and > are part of field symbols.
02020             (r'[?*<>=\-+]', Operator),
02021             (r"'(''|[^'])*'", String.Single),
02022             (r'[/;:()\[\],\.]', Punctuation)
02023         ],
02024     }
02025 
02026 
02027 class NewspeakLexer(RegexLexer):
02028     """
02029     For `Newspeak <http://newspeaklanguage.org/>` syntax.
02030     """
02031     name = 'Newspeak'
02032     filenames = ['*.ns2']
02033     aliases = ['newspeak', ]
02034     mimetypes = ['text/x-newspeak']
02035 
02036     tokens = {
02037        'root' : [
02038            (r'\b(Newsqueak2)\b',Keyword.Declaration),
02039            (r"'[^']*'",String),
02040            (r'\b(class)(\s+)([a-zA-Z0-9_]+)(\s*)',
02041             bygroups(Keyword.Declaration,Text,Name.Class,Text)),
02042            (r'\b(mixin|self|super|private|public|protected|nil|true|false)\b',
02043             Keyword),
02044            (r'([a-zA-Z0-9_]+\:)(\s*)([a-zA-Z_]\w+)',
02045             bygroups(Name.Function,Text,Name.Variable)),
02046            (r'([a-zA-Z0-9_]+)(\s*)(=)',
02047             bygroups(Name.Attribute,Text,Operator)),
02048            (r'<[a-zA-Z0-9_]+>', Comment.Special),
02049            include('expressionstat'),
02050            include('whitespace')
02051         ],
02052 
02053        'expressionstat': [
02054           (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
02055           (r'\d+', Number.Integer),
02056           (r':\w+',Name.Variable),
02057           (r'(\w+)(::)', bygroups(Name.Variable, Operator)),
02058           (r'\w+:', Name.Function),
02059           (r'\w+', Name.Variable),
02060           (r'\(|\)', Punctuation),
02061           (r'\[|\]', Punctuation),
02062           (r'\{|\}', Punctuation),
02063 
02064           (r'(\^|\+|\/|~|\*|<|>|=|@|%|\||&|\?|!|,|-|:)', Operator),
02065           (r'\.|;', Punctuation),
02066           include('whitespace'),
02067           include('literals'),
02068        ],
02069        'literals': [
02070          (r'\$.', String),
02071          (r"'[^']*'", String),
02072          (r"#'[^']*'", String.Symbol),
02073          (r"#\w+:?", String.Symbol),
02074          (r"#(\+|\/|~|\*|<|>|=|@|%|\||&|\?|!|,|-)+", String.Symbol)
02075 
02076        ],
02077        'whitespace' : [
02078          (r'\s+', Text),
02079          (r'"[^"]*"', Comment)
02080        ]
02081     }
02082