# -*- coding: utf-8 -*- """ pygments.lexers.pascal ~~~~~~~~~~~~~~~~~~~~~~ Lexers for Pascal family languages. :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ import re from pygments.lexer import Lexer, RegexLexer, include, bygroups, words, \ using, this, default from pygments.util import get_bool_opt, get_list_opt from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Error from pygments.scanner import Scanner # compatibility import from pygments.lexers.modula2 import Modula2Lexer __all__ = ['DelphiLexer', 'AdaLexer'] class DelphiLexer(Lexer): """ For `Delphi <http://www.borland.com/delphi/>`_ (Borland Object Pascal), Turbo Pascal and Free Pascal source code. Additional options accepted: `turbopascal` Highlight Turbo Pascal specific keywords (default: ``True``). `delphi` Highlight Borland Delphi specific keywords (default: ``True``). `freepascal` Highlight Free Pascal specific keywords (default: ``True``). `units` A list of units that should be considered builtin, supported are ``System``, ``SysUtils``, ``Classes`` and ``Math``. Default is to consider all of them builtin. """ name = 'Delphi' aliases = ['delphi', 'pas', 'pascal', 'objectpascal'] filenames = ['*.pas', '*.dpr'] mimetypes = ['text/x-pascal'] TURBO_PASCAL_KEYWORDS = ( 'absolute', 'and', 'array', 'asm', 'begin', 'break', 'case', 'const', 'constructor', 'continue', 'destructor', 'div', 'do', 'downto', 'else', 'end', 'file', 'for', 'function', 'goto', 'if', 'implementation', 'in', 'inherited', 'inline', 'interface', 'label', 'mod', 'nil', 'not', 'object', 'of', 'on', 'operator', 'or', 'packed', 'procedure', 'program', 'record', 'reintroduce', 'repeat', 'self', 'set', 'shl', 'shr', 'string', 'then', 'to', 'type', 'unit', 'until', 'uses', 'var', 'while', 'with', 'xor' ) DELPHI_KEYWORDS = ( 'as', 'class', 'except', 'exports', 'finalization', 'finally', 'initialization', 'is', 'library', 'on', 'property', 'raise', 'threadvar', 'try' ) FREE_PASCAL_KEYWORDS = ( 'dispose', 'exit', 'false', 'new', 'true' ) BLOCK_KEYWORDS = set(( 'begin', 'class', 'const', 'constructor', 'destructor', 'end', 'finalization', 'function', 'implementation', 'initialization', 'label', 'library', 'operator', 'procedure', 'program', 'property', 'record', 'threadvar', 'type', 'unit', 'uses', 'var' )) FUNCTION_MODIFIERS = set(( 'alias', 'cdecl', 'export', 'inline', 'interrupt', 'nostackframe', 'pascal', 'register', 'safecall', 'softfloat', 'stdcall', 'varargs', 'name', 'dynamic', 'near', 'virtual', 'external', 'override', 'assembler' )) # XXX: those aren't global. but currently we know no way for defining # them just for the type context. DIRECTIVES = set(( 'absolute', 'abstract', 'assembler', 'cppdecl', 'default', 'far', 'far16', 'forward', 'index', 'oldfpccall', 'private', 'protected', 'published', 'public' )) BUILTIN_TYPES = set(( 'ansichar', 'ansistring', 'bool', 'boolean', 'byte', 'bytebool', 'cardinal', 'char', 'comp', 'currency', 'double', 'dword', 'extended', 'int64', 'integer', 'iunknown', 'longbool', 'longint', 'longword', 'pansichar', 'pansistring', 'pbool', 'pboolean', 'pbyte', 'pbytearray', 'pcardinal', 'pchar', 'pcomp', 'pcurrency', 'pdate', 'pdatetime', 'pdouble', 'pdword', 'pextended', 'phandle', 'pint64', 'pinteger', 'plongint', 'plongword', 'pointer', 'ppointer', 'pshortint', 'pshortstring', 'psingle', 'psmallint', 'pstring', 'pvariant', 'pwidechar', 'pwidestring', 'pword', 'pwordarray', 'pwordbool', 'real', 'real48', 'shortint', 'shortstring', 'single', 'smallint', 'string', 'tclass', 'tdate', 'tdatetime', 'textfile', 'thandle', 'tobject', 'ttime', 'variant', 'widechar', 'widestring', 'word', 'wordbool' )) BUILTIN_UNITS = { 'System': ( 'abs', 'acquireexceptionobject', 'addr', 'ansitoutf8', 'append', 'arctan', 'assert', 'assigned', 'assignfile', 'beginthread', 'blockread', 'blockwrite', 'break', 'chdir', 'chr', 'close', 'closefile', 'comptocurrency', 'comptodouble', 'concat', 'continue', 'copy', 'cos', 'dec', 'delete', 'dispose', 'doubletocomp', 'endthread', 'enummodules', 'enumresourcemodules', 'eof', 'eoln', 'erase', 'exceptaddr', 'exceptobject', 'exclude', 'exit', 'exp', 'filepos', 'filesize', 'fillchar', 'finalize', 'findclasshinstance', 'findhinstance', 'findresourcehinstance', 'flush', 'frac', 'freemem', 'get8087cw', 'getdir', 'getlasterror', 'getmem', 'getmemorymanager', 'getmodulefilename', 'getvariantmanager', 'halt', 'hi', 'high', 'inc', 'include', 'initialize', 'insert', 'int', 'ioresult', 'ismemorymanagerset', 'isvariantmanagerset', 'length', 'ln', 'lo', 'low', 'mkdir', 'move', 'new', 'odd', 'olestrtostring', 'olestrtostrvar', 'ord', 'paramcount', 'paramstr', 'pi', 'pos', 'pred', 'ptr', 'pucs4chars', 'random', 'randomize', 'read', 'readln', 'reallocmem', 'releaseexceptionobject', 'rename', 'reset', 'rewrite', 'rmdir', 'round', 'runerror', 'seek', 'seekeof', 'seekeoln', 'set8087cw', 'setlength', 'setlinebreakstyle', 'setmemorymanager', 'setstring', 'settextbuf', 'setvariantmanager', 'sin', 'sizeof', 'slice', 'sqr', 'sqrt', 'str', 'stringofchar', 'stringtoolestr', 'stringtowidechar', 'succ', 'swap', 'trunc', 'truncate', 'typeinfo', 'ucs4stringtowidestring', 'unicodetoutf8', 'uniquestring', 'upcase', 'utf8decode', 'utf8encode', 'utf8toansi', 'utf8tounicode', 'val', 'vararrayredim', 'varclear', 'widecharlentostring', 'widecharlentostrvar', 'widechartostring', 'widechartostrvar', 'widestringtoucs4string', 'write', 'writeln' ), 'SysUtils': ( 'abort', 'addexitproc', 'addterminateproc', 'adjustlinebreaks', 'allocmem', 'ansicomparefilename', 'ansicomparestr', 'ansicomparetext', 'ansidequotedstr', 'ansiextractquotedstr', 'ansilastchar', 'ansilowercase', 'ansilowercasefilename', 'ansipos', 'ansiquotedstr', 'ansisamestr', 'ansisametext', 'ansistrcomp', 'ansistricomp', 'ansistrlastchar', 'ansistrlcomp', 'ansistrlicomp', 'ansistrlower', 'ansistrpos', 'ansistrrscan', 'ansistrscan', 'ansistrupper', 'ansiuppercase', 'ansiuppercasefilename', 'appendstr', 'assignstr', 'beep', 'booltostr', 'bytetocharindex', 'bytetocharlen', 'bytetype', 'callterminateprocs', 'changefileext', 'charlength', 'chartobyteindex', 'chartobytelen', 'comparemem', 'comparestr', 'comparetext', 'createdir', 'createguid', 'currentyear', 'currtostr', 'currtostrf', 'date', 'datetimetofiledate', 'datetimetostr', 'datetimetostring', 'datetimetosystemtime', 'datetimetotimestamp', 'datetostr', 'dayofweek', 'decodedate', 'decodedatefully', 'decodetime', 'deletefile', 'directoryexists', 'diskfree', 'disksize', 'disposestr', 'encodedate', 'encodetime', 'exceptionerrormessage', 'excludetrailingbackslash', 'excludetrailingpathdelimiter', 'expandfilename', 'expandfilenamecase', 'expanduncfilename', 'extractfiledir', 'extractfiledrive', 'extractfileext', 'extractfilename', 'extractfilepath', 'extractrelativepath', 'extractshortpathname', 'fileage', 'fileclose', 'filecreate', 'filedatetodatetime', 'fileexists', 'filegetattr', 'filegetdate', 'fileisreadonly', 'fileopen', 'fileread', 'filesearch', 'fileseek', 'filesetattr', 'filesetdate', 'filesetreadonly', 'filewrite', 'finalizepackage', 'findclose', 'findcmdlineswitch', 'findfirst', 'findnext', 'floattocurr', 'floattodatetime', 'floattodecimal', 'floattostr', 'floattostrf', 'floattotext', 'floattotextfmt', 'fmtloadstr', 'fmtstr', 'forcedirectories', 'format', 'formatbuf', 'formatcurr', 'formatdatetime', 'formatfloat', 'freeandnil', 'getcurrentdir', 'getenvironmentvariable', 'getfileversion', 'getformatsettings', 'getlocaleformatsettings', 'getmodulename', 'getpackagedescription', 'getpackageinfo', 'gettime', 'guidtostring', 'incamonth', 'includetrailingbackslash', 'includetrailingpathdelimiter', 'incmonth', 'initializepackage', 'interlockeddecrement', 'interlockedexchange', 'interlockedexchangeadd', 'interlockedincrement', 'inttohex', 'inttostr', 'isdelimiter', 'isequalguid', 'isleapyear', 'ispathdelimiter', 'isvalidident', 'languages', 'lastdelimiter', 'loadpackage', 'loadstr', 'lowercase', 'msecstotimestamp', 'newstr', 'nextcharindex', 'now', 'outofmemoryerror', 'quotedstr', 'raiselastoserror', 'raiselastwin32error', 'removedir', 'renamefile', 'replacedate', 'replacetime', 'safeloadlibrary', 'samefilename', 'sametext', 'setcurrentdir', 'showexception', 'sleep', 'stralloc', 'strbufsize', 'strbytetype', 'strcat', 'strcharlength', 'strcomp', 'strcopy', 'strdispose', 'strecopy', 'strend', 'strfmt', 'stricomp', 'stringreplace', 'stringtoguid', 'strlcat', 'strlcomp', 'strlcopy', 'strlen', 'strlfmt', 'strlicomp', 'strlower', 'strmove', 'strnew', 'strnextchar', 'strpas', 'strpcopy', 'strplcopy', 'strpos', 'strrscan', 'strscan', 'strtobool', 'strtobooldef', 'strtocurr', 'strtocurrdef', 'strtodate', 'strtodatedef', 'strtodatetime', 'strtodatetimedef', 'strtofloat', 'strtofloatdef', 'strtoint', 'strtoint64', 'strtoint64def', 'strtointdef', 'strtotime', 'strtotimedef', 'strupper', 'supports', 'syserrormessage', 'systemtimetodatetime', 'texttofloat', 'time', 'timestamptodatetime', 'timestamptomsecs', 'timetostr', 'trim', 'trimleft', 'trimright', 'tryencodedate', 'tryencodetime', 'tryfloattocurr', 'tryfloattodatetime', 'trystrtobool', 'trystrtocurr', 'trystrtodate', 'trystrtodatetime', 'trystrtofloat', 'trystrtoint', 'trystrtoint64', 'trystrtotime', 'unloadpackage', 'uppercase', 'widecomparestr', 'widecomparetext', 'widefmtstr', 'wideformat', 'wideformatbuf', 'widelowercase', 'widesamestr', 'widesametext', 'wideuppercase', 'win32check', 'wraptext' ), 'Classes': ( 'activateclassgroup', 'allocatehwnd', 'bintohex', 'checksynchronize', 'collectionsequal', 'countgenerations', 'deallocatehwnd', 'equalrect', 'extractstrings', 'findclass', 'findglobalcomponent', 'getclass', 'groupdescendantswith', 'hextobin', 'identtoint', 'initinheritedcomponent', 'inttoident', 'invalidpoint', 'isuniqueglobalcomponentname', 'linestart', 'objectbinarytotext', 'objectresourcetotext', 'objecttexttobinary', 'objecttexttoresource', 'pointsequal', 'readcomponentres', 'readcomponentresex', 'readcomponentresfile', 'rect', 'registerclass', 'registerclassalias', 'registerclasses', 'registercomponents', 'registerintegerconsts', 'registernoicon', 'registernonactivex', 'smallpoint', 'startclassgroup', 'teststreamformat', 'unregisterclass', 'unregisterclasses', 'unregisterintegerconsts', 'unregistermoduleclasses', 'writecomponentresfile' ), 'Math': ( 'arccos', 'arccosh', 'arccot', 'arccoth', 'arccsc', 'arccsch', 'arcsec', 'arcsech', 'arcsin', 'arcsinh', 'arctan2', 'arctanh', 'ceil', 'comparevalue', 'cosecant', 'cosh', 'cot', 'cotan', 'coth', 'csc', 'csch', 'cycletodeg', 'cycletograd', 'cycletorad', 'degtocycle', 'degtograd', 'degtorad', 'divmod', 'doubledecliningbalance', 'ensurerange', 'floor', 'frexp', 'futurevalue', 'getexceptionmask', 'getprecisionmode', 'getroundmode', 'gradtocycle', 'gradtodeg', 'gradtorad', 'hypot', 'inrange', 'interestpayment', 'interestrate', 'internalrateofreturn', 'intpower', 'isinfinite', 'isnan', 'iszero', 'ldexp', 'lnxp1', 'log10', 'log2', 'logn', 'max', 'maxintvalue', 'maxvalue', 'mean', 'meanandstddev', 'min', 'minintvalue', 'minvalue', 'momentskewkurtosis', 'netpresentvalue', 'norm', 'numberofperiods', 'payment', 'periodpayment', 'poly', 'popnstddev', 'popnvariance', 'power', 'presentvalue', 'radtocycle', 'radtodeg', 'radtograd', 'randg', 'randomrange', 'roundto', 'samevalue', 'sec', 'secant', 'sech', 'setexceptionmask', 'setprecisionmode', 'setroundmode', 'sign', 'simpleroundto', 'sincos', 'sinh', 'slndepreciation', 'stddev', 'sum', 'sumint', 'sumofsquares', 'sumsandsquares', 'syddepreciation', 'tan', 'tanh', 'totalvariance', 'variance' ) } ASM_REGISTERS = set(( 'ah', 'al', 'ax', 'bh', 'bl', 'bp', 'bx', 'ch', 'cl', 'cr0', 'cr1', 'cr2', 'cr3', 'cr4', 'cs', 'cx', 'dh', 'di', 'dl', 'dr0', 'dr1', 'dr2', 'dr3', 'dr4', 'dr5', 'dr6', 'dr7', 'ds', 'dx', 'eax', 'ebp', 'ebx', 'ecx', 'edi', 'edx', 'es', 'esi', 'esp', 'fs', 'gs', 'mm0', 'mm1', 'mm2', 'mm3', 'mm4', 'mm5', 'mm6', 'mm7', 'si', 'sp', 'ss', 'st0', 'st1', 'st2', 'st3', 'st4', 'st5', 'st6', 'st7', 'xmm0', 'xmm1', 'xmm2', 'xmm3', 'xmm4', 'xmm5', 'xmm6', 'xmm7' )) ASM_INSTRUCTIONS = set(( 'aaa', 'aad', 'aam', 'aas', 'adc', 'add', 'and', 'arpl', 'bound', 'bsf', 'bsr', 'bswap', 'bt', 'btc', 'btr', 'bts', 'call', 'cbw', 'cdq', 'clc', 'cld', 'cli', 'clts', 'cmc', 'cmova', 'cmovae', 'cmovb', 'cmovbe', 'cmovc', 'cmovcxz', 'cmove', 'cmovg', 'cmovge', 'cmovl', 'cmovle', 'cmovna', 'cmovnae', 'cmovnb', 'cmovnbe', 'cmovnc', 'cmovne', 'cmovng', 'cmovnge', 'cmovnl', 'cmovnle', 'cmovno', 'cmovnp', 'cmovns', 'cmovnz', 'cmovo', 'cmovp', 'cmovpe', 'cmovpo', 'cmovs', 'cmovz', 'cmp', 'cmpsb', 'cmpsd', 'cmpsw', 'cmpxchg', 'cmpxchg486', 'cmpxchg8b', 'cpuid', 'cwd', 'cwde', 'daa', 'das', 'dec', 'div', 'emms', 'enter', 'hlt', 'ibts', 'icebp', 'idiv', 'imul', 'in', 'inc', 'insb', 'insd', 'insw', 'int', 'int01', 'int03', 'int1', 'int3', 'into', 'invd', 'invlpg', 'iret', 'iretd', 'iretw', 'ja', 'jae', 'jb', 'jbe', 'jc', 'jcxz', 'jcxz', 'je', 'jecxz', 'jg', 'jge', 'jl', 'jle', 'jmp', 'jna', 'jnae', 'jnb', 'jnbe', 'jnc', 'jne', 'jng', 'jnge', 'jnl', 'jnle', 'jno', 'jnp', 'jns', 'jnz', 'jo', 'jp', 'jpe', 'jpo', 'js', 'jz', 'lahf', 'lar', 'lcall', 'lds', 'lea', 'leave', 'les', 'lfs', 'lgdt', 'lgs', 'lidt', 'ljmp', 'lldt', 'lmsw', 'loadall', 'loadall286', 'lock', 'lodsb', 'lodsd', 'lodsw', 'loop', 'loope', 'loopne', 'loopnz', 'loopz', 'lsl', 'lss', 'ltr', 'mov', 'movd', 'movq', 'movsb', 'movsd', 'movsw', 'movsx', 'movzx', 'mul', 'neg', 'nop', 'not', 'or', 'out', 'outsb', 'outsd', 'outsw', 'pop', 'popa', 'popad', 'popaw', 'popf', 'popfd', 'popfw', 'push', 'pusha', 'pushad', 'pushaw', 'pushf', 'pushfd', 'pushfw', 'rcl', 'rcr', 'rdmsr', 'rdpmc', 'rdshr', 'rdtsc', 'rep', 'repe', 'repne', 'repnz', 'repz', 'ret', 'retf', 'retn', 'rol', 'ror', 'rsdc', 'rsldt', 'rsm', 'sahf', 'sal', 'salc', 'sar', 'sbb', 'scasb', 'scasd', 'scasw', 'seta', 'setae', 'setb', 'setbe', 'setc', 'setcxz', 'sete', 'setg', 'setge', 'setl', 'setle', 'setna', 'setnae', 'setnb', 'setnbe', 'setnc', 'setne', 'setng', 'setnge', 'setnl', 'setnle', 'setno', 'setnp', 'setns', 'setnz', 'seto', 'setp', 'setpe', 'setpo', 'sets', 'setz', 'sgdt', 'shl', 'shld', 'shr', 'shrd', 'sidt', 'sldt', 'smi', 'smint', 'smintold', 'smsw', 'stc', 'std', 'sti', 'stosb', 'stosd', 'stosw', 'str', 'sub', 'svdc', 'svldt', 'svts', 'syscall', 'sysenter', 'sysexit', 'sysret', 'test', 'ud1', 'ud2', 'umov', 'verr', 'verw', 'wait', 'wbinvd', 'wrmsr', 'wrshr', 'xadd', 'xbts', 'xchg', 'xlat', 'xlatb', 'xor' )) def __init__(self, **options): Lexer.__init__(self, **options) self.keywords = set() if get_bool_opt(options, 'turbopascal', True): self.keywords.update(self.TURBO_PASCAL_KEYWORDS) if get_bool_opt(options, 'delphi', True): self.keywords.update(self.DELPHI_KEYWORDS) if get_bool_opt(options, 'freepascal', True): self.keywords.update(self.FREE_PASCAL_KEYWORDS) self.builtins = set() for unit in get_list_opt(options, 'units', list(self.BUILTIN_UNITS)): self.builtins.update(self.BUILTIN_UNITS[unit]) def get_tokens_unprocessed(self, text): scanner = Scanner(text, re.DOTALL | re.MULTILINE | re.IGNORECASE) stack = ['initial'] in_function_block = False in_property_block = False was_dot = False next_token_is_function = False next_token_is_property = False collect_labels = False block_labels = set() brace_balance = [0, 0] while not scanner.eos: token = Error if stack[-1] == 'initial': if scanner.scan(r'\s+'): token = Text elif scanner.scan(r'\{.*?\}|\(\*.*?\*\)'): if scanner.match.startswith('$'): token = Comment.Preproc else: token = Comment.Multiline elif scanner.scan(r'//.*?$'): token = Comment.Single elif scanner.scan(r'[-+*\/=<>:;,.@\^]'): token = Operator # stop label highlighting on next ";" if collect_labels and scanner.match == ';': collect_labels = False elif scanner.scan(r'[\(\)\[\]]+'): token = Punctuation # abort function naming ``foo = Function(...)`` next_token_is_function = False # if we are in a function block we count the open # braces because ootherwise it's impossible to # determine the end of the modifier context if in_function_block or in_property_block: if scanner.match == '(': brace_balance[0] += 1 elif scanner.match == ')': brace_balance[0] -= 1 elif scanner.match == '[': brace_balance[1] += 1 elif scanner.match == ']': brace_balance[1] -= 1 elif scanner.scan(r'[A-Za-z_][A-Za-z_0-9]*'): lowercase_name = scanner.match.lower() if lowercase_name == 'result': token = Name.Builtin.Pseudo elif lowercase_name in self.keywords: token = Keyword # if we are in a special block and a # block ending keyword occours (and the parenthesis # is balanced) we end the current block context if (in_function_block or in_property_block) and \ lowercase_name in self.BLOCK_KEYWORDS and \ brace_balance[0] <= 0 and \ brace_balance[1] <= 0: in_function_block = False in_property_block = False brace_balance = [0, 0] block_labels = set() if lowercase_name in ('label', 'goto'): collect_labels = True elif lowercase_name == 'asm': stack.append('asm') elif lowercase_name == 'property': in_property_block = True next_token_is_property = True elif lowercase_name in ('procedure', 'operator', 'function', 'constructor', 'destructor'): in_function_block = True next_token_is_function = True # we are in a function block and the current name # is in the set of registered modifiers. highlight # it as pseudo keyword elif in_function_block and \ lowercase_name in self.FUNCTION_MODIFIERS: token = Keyword.Pseudo # if we are in a property highlight some more # modifiers elif in_property_block and \ lowercase_name in ('read', 'write'): token = Keyword.Pseudo next_token_is_function = True # if the last iteration set next_token_is_function # to true we now want this name highlighted as # function. so do that and reset the state elif next_token_is_function: # Look if the next token is a dot. If yes it's # not a function, but a class name and the # part after the dot a function name if scanner.test(r'\s*\.\s*'): token = Name.Class # it's not a dot, our job is done else: token = Name.Function next_token_is_function = False # same for properties elif next_token_is_property: token = Name.Property next_token_is_property = False # Highlight this token as label and add it # to the list of known labels elif collect_labels: token = Name.Label block_labels.add(scanner.match.lower()) # name is in list of known labels elif lowercase_name in block_labels: token = Name.Label elif lowercase_name in self.BUILTIN_TYPES: token = Keyword.Type elif lowercase_name in self.DIRECTIVES: token = Keyword.Pseudo # builtins are just builtins if the token # before isn't a dot elif not was_dot and lowercase_name in self.builtins: token = Name.Builtin else: token = Name elif scanner.scan(r"'"): token = String stack.append('string') elif scanner.scan(r'\#(\d+|\$[0-9A-Fa-f]+)'): token = String.Char elif scanner.scan(r'\$[0-9A-Fa-f]+'): token = Number.Hex elif scanner.scan(r'\d+(?![eE]|\.[^.])'): token = Number.Integer elif scanner.scan(r'\d+(\.\d+([eE][+-]?\d+)?|[eE][+-]?\d+)'): token = Number.Float else: # if the stack depth is deeper than once, pop if len(stack) > 1: stack.pop() scanner.get_char() elif stack[-1] == 'string': if scanner.scan(r"''"): token = String.Escape elif scanner.scan(r"'"): token = String stack.pop() elif scanner.scan(r"[^']*"): token = String else: scanner.get_char() stack.pop() elif stack[-1] == 'asm': if scanner.scan(r'\s+'): token = Text elif scanner.scan(r'end'): token = Keyword stack.pop() elif scanner.scan(r'\{.*?\}|\(\*.*?\*\)'): if scanner.match.startswith('$'): token = Comment.Preproc else: token = Comment.Multiline elif scanner.scan(r'//.*?$'): token = Comment.Single elif scanner.scan(r"'"): token = String stack.append('string') elif scanner.scan(r'@@[A-Za-z_][A-Za-z_0-9]*'): token = Name.Label elif scanner.scan(r'[A-Za-z_][A-Za-z_0-9]*'): lowercase_name = scanner.match.lower() if lowercase_name in self.ASM_INSTRUCTIONS: token = Keyword elif lowercase_name in self.ASM_REGISTERS: token = Name.Builtin else: token = Name elif scanner.scan(r'[-+*\/=<>:;,.@\^]+'): token = Operator elif scanner.scan(r'[\(\)\[\]]+'): token = Punctuation elif scanner.scan(r'\$[0-9A-Fa-f]+'): token = Number.Hex elif scanner.scan(r'\d+(?![eE]|\.[^.])'): token = Number.Integer elif scanner.scan(r'\d+(\.\d+([eE][+-]?\d+)?|[eE][+-]?\d+)'): token = Number.Float else: scanner.get_char() stack.pop() # save the dot!!!11 if scanner.match.strip(): was_dot = scanner.match == '.' yield scanner.start_pos, token, scanner.match or '' class AdaLexer(RegexLexer): """ For Ada source code. .. versionadded:: 1.3 """ name = 'Ada' aliases = ['ada', 'ada95', 'ada2005'] filenames = ['*.adb', '*.ads', '*.ada'] mimetypes = ['text/x-ada'] flags = re.MULTILINE | re.IGNORECASE tokens = { 'root': [ (r'[^\S\n]+', Text), (r'--.*?\n', Comment.Single), (r'[^\S\n]+', Text), (r'function|procedure|entry', Keyword.Declaration, 'subprogram'), (r'(subtype|type)(\s+)(\w+)', bygroups(Keyword.Declaration, Text, Keyword.Type), 'type_def'), (r'task|protected', Keyword.Declaration), (r'(subtype)(\s+)', bygroups(Keyword.Declaration, Text)), (r'(end)(\s+)', bygroups(Keyword.Reserved, Text), 'end'), (r'(pragma)(\s+)(\w+)', bygroups(Keyword.Reserved, Text, Comment.Preproc)), (r'(true|false|null)\b', Keyword.Constant), (words(( 'Address', 'Byte', 'Boolean', 'Character', 'Controlled', 'Count', 'Cursor', 'Duration', 'File_Mode', 'File_Type', 'Float', 'Generator', 'Integer', 'Long_Float', 'Long_Integer', 'Long_Long_Float', 'Long_Long_Integer', 'Natural', 'Positive', 'Reference_Type', 'Short_Float', 'Short_Integer', 'Short_Short_Float', 'Short_Short_Integer', 'String', 'Wide_Character', 'Wide_String'), suffix=r'\b'), Keyword.Type), (r'(and(\s+then)?|in|mod|not|or(\s+else)|rem)\b', Operator.Word), (r'generic|private', Keyword.Declaration), (r'package', Keyword.Declaration, 'package'), (r'array\b', Keyword.Reserved, 'array_def'), (r'(with|use)(\s+)', bygroups(Keyword.Namespace, Text), 'import'), (r'(\w+)(\s*)(:)(\s*)(constant)', bygroups(Name.Constant, Text, Punctuation, Text, Keyword.Reserved)), (r'<<\w+>>', Name.Label), (r'(\w+)(\s*)(:)(\s*)(declare|begin|loop|for|while)', bygroups(Name.Label, Text, Punctuation, Text, Keyword.Reserved)), (words(( 'abort', 'abs', 'abstract', 'accept', 'access', 'aliased', 'all', 'array', 'at', 'begin', 'body', 'case', 'constant', 'declare', 'delay', 'delta', 'digits', 'do', 'else', 'elsif', 'end', 'entry', 'exception', 'exit', 'interface', 'for', 'goto', 'if', 'is', 'limited', 'loop', 'new', 'null', 'of', 'or', 'others', 'out', 'overriding', 'pragma', 'protected', 'raise', 'range', 'record', 'renames', 'requeue', 'return', 'reverse', 'select', 'separate', 'subtype', 'synchronized', 'task', 'tagged', 'terminate', 'then', 'type', 'until', 'when', 'while', 'xor'), prefix=r'\b', suffix=r'\b'), Keyword.Reserved), (r'"[^"]*"', String), include('attribute'), include('numbers'), (r"'[^']'", String.Character), (r'(\w+)(\s*|[(,])', bygroups(Name, using(this))), (r"(<>|=>|:=|[()|:;,.'])", Punctuation), (r'[*<>+=/&-]', Operator), (r'\n+', Text), ], 'numbers': [ (r'[0-9_]+#[0-9a-f]+#', Number.Hex), (r'[0-9_]+\.[0-9_]*', Number.Float), (r'[0-9_]+', Number.Integer), ], 'attribute': [ (r"(')(\w+)", bygroups(Punctuation, Name.Attribute)), ], 'subprogram': [ (r'\(', Punctuation, ('#pop', 'formal_part')), (r';', Punctuation, '#pop'), (r'is\b', Keyword.Reserved, '#pop'), (r'"[^"]+"|\w+', Name.Function), include('root'), ], 'end': [ ('(if|case|record|loop|select)', Keyword.Reserved), ('"[^"]+"|[\w.]+', Name.Function), ('\s+', Text), (';', Punctuation, '#pop'), ], 'type_def': [ (r';', Punctuation, '#pop'), (r'\(', Punctuation, 'formal_part'), (r'with|and|use', Keyword.Reserved), (r'array\b', Keyword.Reserved, ('#pop', 'array_def')), (r'record\b', Keyword.Reserved, ('record_def')), (r'(null record)(;)', bygroups(Keyword.Reserved, Punctuation), '#pop'), include('root'), ], 'array_def': [ (r';', Punctuation, '#pop'), (r'(\w+)(\s+)(range)', bygroups(Keyword.Type, Text, Keyword.Reserved)), include('root'), ], 'record_def': [ (r'end record', Keyword.Reserved, '#pop'), include('root'), ], 'import': [ (r'[\w.]+', Name.Namespace, '#pop'), default('#pop'), ], 'formal_part': [ (r'\)', Punctuation, '#pop'), (r'\w+', Name.Variable), (r',|:[^=]', Punctuation), (r'(in|not|null|out|access)\b', Keyword.Reserved), include('root'), ], 'package': [ ('body', Keyword.Declaration), ('is\s+new|renames', Keyword.Reserved), ('is', Keyword.Reserved, '#pop'), (';', Punctuation, '#pop'), ('\(', Punctuation, 'package_instantiation'), ('([\w.]+)', Name.Class), include('root'), ], 'package_instantiation': [ (r'("[^"]+"|\w+)(\s+)(=>)', bygroups(Name.Variable, Text, Punctuation)), (r'[\w.\'"]', Text), (r'\)', Punctuation, '#pop'), include('root'), ], }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
__init__.py | File | 10.65 KB | 0644 |
|
__init__.pyc | File | 10.55 KB | 0644 |
|
_asy_builtins.py | File | 26.68 KB | 0644 |
|
_asy_builtins.pyc | File | 32.76 KB | 0644 |
|
_cl_builtins.py | File | 13.72 KB | 0644 |
|
_cl_builtins.pyc | File | 25.25 KB | 0644 |
|
_cocoa_builtins.py | File | 39.04 KB | 0644 |
|
_cocoa_builtins.pyc | File | 45.61 KB | 0644 |
|
_csound_builtins.py | File | 21.14 KB | 0644 |
|
_csound_builtins.pyc | File | 24.04 KB | 0644 |
|
_lasso_builtins.py | File | 131.38 KB | 0644 |
|
_lasso_builtins.pyc | File | 121.02 KB | 0644 |
|
_lua_builtins.py | File | 8.14 KB | 0644 |
|
_lua_builtins.pyc | File | 10.73 KB | 0644 |
|
_mapping.py | File | 53.43 KB | 0644 |
|
_mapping.pyc | File | 77.25 KB | 0644 |
|
_mql_builtins.py | File | 24.16 KB | 0644 |
|
_mql_builtins.pyc | File | 28.95 KB | 0644 |
|
_openedge_builtins.py | File | 47.23 KB | 0644 |
|
_openedge_builtins.pyc | File | 80.1 KB | 0644 |
|
_php_builtins.py | File | 150.75 KB | 0644 |
|
_php_builtins.pyc | File | 134.8 KB | 0644 |
|
_postgres_builtins.py | File | 10.95 KB | 0644 |
|
_postgres_builtins.pyc | File | 13.06 KB | 0644 |
|
_scilab_builtins.py | File | 51.18 KB | 0644 |
|
_scilab_builtins.pyc | File | 71.95 KB | 0644 |
|
_sourcemod_builtins.py | File | 26.48 KB | 0644 |
|
_sourcemod_builtins.pyc | File | 31.43 KB | 0644 |
|
_stan_builtins.py | File | 9.88 KB | 0644 |
|
_stan_builtins.pyc | File | 11.97 KB | 0644 |
|
_stata_builtins.py | File | 24.55 KB | 0644 |
|
_stata_builtins.pyc | File | 36.1 KB | 0644 |
|
_tsql_builtins.py | File | 15.12 KB | 0644 |
|
_tsql_builtins.pyc | File | 15.99 KB | 0644 |
|
_vim_builtins.py | File | 55.75 KB | 0644 |
|
_vim_builtins.pyc | File | 62.26 KB | 0644 |
|
actionscript.py | File | 10.92 KB | 0644 |
|
actionscript.pyc | File | 11.36 KB | 0644 |
|
agile.py | File | 900 B | 0644 |
|
agile.pyc | File | 1.4 KB | 0644 |
|
algebra.py | File | 7.03 KB | 0644 |
|
algebra.pyc | File | 7.76 KB | 0644 |
|
ambient.py | File | 2.5 KB | 0644 |
|
ambient.pyc | File | 2.87 KB | 0644 |
|
ampl.py | File | 4.02 KB | 0644 |
|
ampl.pyc | File | 4.61 KB | 0644 |
|
apl.py | File | 3.09 KB | 0644 |
|
apl.pyc | File | 1.99 KB | 0644 |
|
archetype.py | File | 10.87 KB | 0644 |
|
archetype.pyc | File | 7.44 KB | 0644 |
|
asm.py | File | 24.67 KB | 0644 |
|
asm.pyc | File | 23.89 KB | 0644 |
|
automation.py | File | 19.19 KB | 0644 |
|
automation.pyc | File | 16.59 KB | 0644 |
|
basic.py | File | 19.83 KB | 0644 |
|
basic.pyc | File | 17.63 KB | 0644 |
|
bibtex.py | File | 4.61 KB | 0644 |
|
bibtex.pyc | File | 4.43 KB | 0644 |
|
business.py | File | 27.02 KB | 0644 |
|
business.pyc | File | 25.07 KB | 0644 |
|
c_cpp.py | File | 10.28 KB | 0644 |
|
c_cpp.pyc | File | 9.72 KB | 0644 |
|
c_like.py | File | 23.56 KB | 0644 |
|
c_like.pyc | File | 26.43 KB | 0644 |
|
capnproto.py | File | 2.14 KB | 0644 |
|
capnproto.pyc | File | 2.02 KB | 0644 |
|
chapel.py | File | 3.43 KB | 0644 |
|
chapel.pyc | File | 3.36 KB | 0644 |
|
clean.py | File | 10.16 KB | 0644 |
|
clean.pyc | File | 8.27 KB | 0644 |
|
compiled.py | File | 1.35 KB | 0644 |
|
compiled.pyc | File | 2.14 KB | 0644 |
|
configs.py | File | 27.6 KB | 0644 |
|
configs.pyc | File | 25.05 KB | 0644 |
|
console.py | File | 4.02 KB | 0644 |
|
console.pyc | File | 3.85 KB | 0644 |
|
crystal.py | File | 16.45 KB | 0644 |
|
crystal.pyc | File | 11.39 KB | 0644 |
|
csound.py | File | 12.25 KB | 0644 |
|
csound.pyc | File | 9.39 KB | 0644 |
|
css.py | File | 30.77 KB | 0644 |
|
css.pyc | File | 37.17 KB | 0644 |
|
d.py | File | 9.31 KB | 0644 |
|
d.pyc | File | 7.69 KB | 0644 |
|
dalvik.py | File | 4.32 KB | 0644 |
|
dalvik.pyc | File | 3.71 KB | 0644 |
|
data.py | File | 18.33 KB | 0644 |
|
data.pyc | File | 12.44 KB | 0644 |
|
diff.py | File | 4.76 KB | 0644 |
|
diff.pyc | File | 4.4 KB | 0644 |
|
dotnet.py | File | 27.02 KB | 0644 |
|
dotnet.pyc | File | 23.13 KB | 0644 |
|
dsls.py | File | 32.55 KB | 0644 |
|
dsls.pyc | File | 31.3 KB | 0644 |
|
dylan.py | File | 10.18 KB | 0644 |
|
dylan.pyc | File | 11.14 KB | 0644 |
|
ecl.py | File | 5.74 KB | 0644 |
|
ecl.pyc | File | 6.7 KB | 0644 |
|
eiffel.py | File | 2.42 KB | 0644 |
|
eiffel.pyc | File | 2.91 KB | 0644 |
|
elm.py | File | 2.93 KB | 0644 |
|
elm.pyc | File | 2.91 KB | 0644 |
|
erlang.py | File | 18.49 KB | 0644 |
|
erlang.pyc | File | 17.2 KB | 0644 |
|
esoteric.py | File | 9.27 KB | 0644 |
|
esoteric.pyc | File | 9.15 KB | 0644 |
|
ezhil.py | File | 2.95 KB | 0644 |
|
ezhil.pyc | File | 3.71 KB | 0644 |
|
factor.py | File | 17.44 KB | 0644 |
|
factor.pyc | File | 23.61 KB | 0644 |
|
fantom.py | File | 9.75 KB | 0644 |
|
fantom.pyc | File | 5.88 KB | 0644 |
|
felix.py | File | 9.19 KB | 0644 |
|
felix.pyc | File | 7.73 KB | 0644 |
|
forth.py | File | 6.98 KB | 0644 |
|
forth.pyc | File | 4.84 KB | 0644 |
|
fortran.py | File | 9.54 KB | 0644 |
|
fortran.pyc | File | 11.16 KB | 0644 |
|
foxpro.py | File | 25.62 KB | 0644 |
|
foxpro.pyc | File | 19.9 KB | 0644 |
|
functional.py | File | 698 B | 0644 |
|
functional.pyc | File | 1.08 KB | 0644 |
|
go.py | File | 3.61 KB | 0644 |
|
go.pyc | File | 3.37 KB | 0644 |
|
grammar_notation.py | File | 6.18 KB | 0644 |
|
grammar_notation.pyc | File | 5.56 KB | 0644 |
|
graph.py | File | 2.31 KB | 0644 |
|
graph.pyc | File | 2.34 KB | 0644 |
|
graphics.py | File | 25.23 KB | 0644 |
|
graphics.pyc | File | 23.52 KB | 0644 |
|
haskell.py | File | 30.49 KB | 0644 |
|
haskell.pyc | File | 23.51 KB | 0644 |
|
haxe.py | File | 30.23 KB | 0644 |
|
haxe.pyc | File | 18.35 KB | 0644 |
|
hdl.py | File | 18.26 KB | 0644 |
|
hdl.pyc | File | 18.96 KB | 0644 |
|
hexdump.py | File | 3.42 KB | 0644 |
|
hexdump.pyc | File | 2.95 KB | 0644 |
|
html.py | File | 18.82 KB | 0644 |
|
html.pyc | File | 15.04 KB | 0644 |
|
idl.py | File | 14.63 KB | 0644 |
|
idl.pyc | File | 18.94 KB | 0644 |
|
igor.py | File | 19.53 KB | 0644 |
|
igor.pyc | File | 24.74 KB | 0644 |
|
inferno.py | File | 3.04 KB | 0644 |
|
inferno.pyc | File | 2.92 KB | 0644 |
|
installers.py | File | 12.56 KB | 0644 |
|
installers.pyc | File | 10.6 KB | 0644 |
|
int_fiction.py | File | 54.47 KB | 0644 |
|
int_fiction.pyc | File | 34.88 KB | 0644 |
|
iolang.py | File | 1.86 KB | 0644 |
|
iolang.pyc | File | 1.94 KB | 0644 |
|
j.py | File | 4.42 KB | 0644 |
|
j.pyc | File | 4.2 KB | 0644 |
|
javascript.py | File | 58.72 KB | 0644 |
|
javascript.pyc | File | 41.33 KB | 0644 |
|
julia.py | File | 13.76 KB | 0644 |
|
julia.pyc | File | 11.5 KB | 0644 |
|
jvm.py | File | 65.18 KB | 0644 |
|
jvm.pyc | File | 50.73 KB | 0644 |
|
lisp.py | File | 137.38 KB | 0644 |
|
lisp.pyc | File | 205.18 KB | 0644 |
|
make.py | File | 7.16 KB | 0644 |
|
make.pyc | File | 5.37 KB | 0644 |
|
markup.py | File | 19.97 KB | 0644 |
|
markup.pyc | File | 17.25 KB | 0644 |
|
math.py | File | 700 B | 0644 |
|
math.pyc | File | 1.09 KB | 0644 |
|
matlab.py | File | 28.47 KB | 0644 |
|
matlab.pyc | File | 30.52 KB | 0644 |
|
ml.py | File | 27.23 KB | 0644 |
|
ml.pyc | File | 14.98 KB | 0644 |
|
modeling.py | File | 12.53 KB | 0644 |
|
modeling.pyc | File | 10.87 KB | 0644 |
|
modula2.py | File | 51.33 KB | 0644 |
|
modula2.pyc | File | 25.89 KB | 0644 |
|
monte.py | File | 6.16 KB | 0644 |
|
monte.pyc | File | 4.94 KB | 0644 |
|
ncl.py | File | 62.49 KB | 0644 |
|
ncl.pyc | File | 67.46 KB | 0644 |
|
nimrod.py | File | 5.05 KB | 0644 |
|
nimrod.pyc | File | 4.74 KB | 0644 |
|
nit.py | File | 2.68 KB | 0644 |
|
nit.pyc | File | 2.99 KB | 0644 |
|
nix.py | File | 3.94 KB | 0644 |
|
nix.pyc | File | 4.28 KB | 0644 |
|
oberon.py | File | 3.65 KB | 0644 |
|
oberon.pyc | File | 3.41 KB | 0644 |
|
objective.py | File | 22.22 KB | 0644 |
|
objective.pyc | File | 19.74 KB | 0644 |
|
ooc.py | File | 2.93 KB | 0644 |
|
ooc.pyc | File | 3 KB | 0644 |
|
other.py | File | 1.73 KB | 0644 |
|
other.pyc | File | 2.71 KB | 0644 |
|
parasail.py | File | 2.67 KB | 0644 |
|
parasail.pyc | File | 2.58 KB | 0644 |
|
parsers.py | File | 26.94 KB | 0644 |
|
parsers.pyc | File | 23.14 KB | 0644 |
|
pascal.py | File | 31.88 KB | 0644 |
|
pascal.pyc | File | 29.58 KB | 0644 |
|
pawn.py | File | 7.9 KB | 0644 |
|
pawn.pyc | File | 7.16 KB | 0644 |
|
perl.py | File | 31.26 KB | 0644 |
|
perl.pyc | File | 29.81 KB | 0644 |
|
php.py | File | 10.48 KB | 0644 |
|
php.pyc | File | 9.26 KB | 0644 |
|
praat.py | File | 12.26 KB | 0644 |
|
praat.pyc | File | 11.46 KB | 0644 |
|
prolog.py | File | 11.78 KB | 0644 |
|
prolog.pyc | File | 8.05 KB | 0644 |
|
python.py | File | 41.39 KB | 0644 |
|
python.pyc | File | 36.48 KB | 0644 |
|
qvt.py | File | 5.97 KB | 0644 |
|
qvt.pyc | File | 5.27 KB | 0644 |
|
r.py | File | 23.2 KB | 0644 |
|
r.pyc | File | 32.97 KB | 0644 |
|
rdf.py | File | 9.18 KB | 0644 |
|
rdf.pyc | File | 6.45 KB | 0644 |
|
rebol.py | File | 18.18 KB | 0644 |
|
rebol.pyc | File | 13.49 KB | 0644 |
|
resource.py | File | 2.86 KB | 0644 |
|
resource.pyc | File | 2.86 KB | 0644 |
|
rnc.py | File | 1.94 KB | 0644 |
|
rnc.pyc | File | 1.78 KB | 0644 |
|
roboconf.py | File | 2.02 KB | 0644 |
|
roboconf.pyc | File | 2.34 KB | 0644 |
|
robotframework.py | File | 18.3 KB | 0644 |
|
robotframework.pyc | File | 25.03 KB | 0644 |
|
ruby.py | File | 21.62 KB | 0644 |
|
ruby.pyc | File | 16.91 KB | 0644 |
|
rust.py | File | 7.51 KB | 0644 |
|
rust.pyc | File | 5.67 KB | 0644 |
|
sas.py | File | 9.23 KB | 0644 |
|
sas.pyc | File | 9.63 KB | 0644 |
|
scripting.py | File | 66.17 KB | 0644 |
|
scripting.pyc | File | 67.97 KB | 0644 |
|
shell.py | File | 30.69 KB | 0644 |
|
shell.pyc | File | 24.13 KB | 0644 |
|
smalltalk.py | File | 7.05 KB | 0644 |
|
smalltalk.pyc | File | 5.24 KB | 0644 |
|
smv.py | File | 2.74 KB | 0644 |
|
smv.pyc | File | 3.16 KB | 0644 |
|
snobol.py | File | 2.69 KB | 0644 |
|
snobol.pyc | File | 2.27 KB | 0644 |
|
special.py | File | 3.08 KB | 0644 |
|
special.pyc | File | 3.86 KB | 0644 |
|
sql.py | File | 28.75 KB | 0644 |
|
sql.pyc | File | 28.6 KB | 0644 |
|
stata.py | File | 3.54 KB | 0644 |
|
stata.pyc | File | 2.7 KB | 0644 |
|
supercollider.py | File | 3.43 KB | 0644 |
|
supercollider.pyc | File | 3.83 KB | 0644 |
|
tcl.py | File | 5.27 KB | 0644 |
|
tcl.pyc | File | 5.1 KB | 0644 |
|
templates.py | File | 71.73 KB | 0644 |
|
templates.pyc | File | 74.43 KB | 0644 |
|
testing.py | File | 10.5 KB | 0644 |
|
testing.pyc | File | 8.42 KB | 0644 |
|
text.py | File | 977 B | 0644 |
|
text.pyc | File | 1.54 KB | 0644 |
|
textedit.py | File | 5.92 KB | 0644 |
|
textedit.pyc | File | 5.79 KB | 0644 |
|
textfmts.py | File | 10.6 KB | 0644 |
|
textfmts.pyc | File | 8.41 KB | 0644 |
|
theorem.py | File | 18.59 KB | 0644 |
|
theorem.pyc | File | 20.07 KB | 0644 |
|
trafficscript.py | File | 1.51 KB | 0644 |
|
trafficscript.pyc | File | 1.8 KB | 0644 |
|
typoscript.py | File | 8.2 KB | 0644 |
|
typoscript.pyc | File | 6.41 KB | 0644 |
|
urbi.py | File | 5.62 KB | 0644 |
|
urbi.pyc | File | 5.48 KB | 0644 |
|
varnish.py | File | 7.1 KB | 0644 |
|
varnish.pyc | File | 7.15 KB | 0644 |
|
verification.py | File | 3.62 KB | 0644 |
|
verification.pyc | File | 3.9 KB | 0644 |
|
web.py | File | 918 B | 0644 |
|
web.pyc | File | 1.4 KB | 0644 |
|
webmisc.py | File | 38.96 KB | 0644 |
|
webmisc.pyc | File | 28.98 KB | 0644 |
|
whiley.py | File | 3.92 KB | 0644 |
|
whiley.pyc | File | 3.23 KB | 0644 |
|
x10.py | File | 1.92 KB | 0644 |
|
x10.pyc | File | 2.6 KB | 0644 |
|