home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import re
- from pygments.lexer import RegexLexer, ExtendedRegexLexer, bygroups, using, include, this
- from pygments.token import Text, Comment, Operator, Keyword, Name, String, Number, Other, Punctuation
- from pygments.util import get_bool_opt, get_list_opt, looks_like_xml, html_doctype_matches
- from pygments.lexers.agile import RubyLexer
- __all__ = [
- 'HtmlLexer',
- 'XmlLexer',
- 'JavascriptLexer',
- 'CssLexer',
- 'PhpLexer',
- 'ActionScriptLexer',
- 'XsltLexer',
- 'ActionScript3Lexer',
- 'MxmlLexer',
- 'HaxeLexer',
- 'HamlLexer',
- 'SassLexer',
- 'ObjectiveJLexer',
- 'CoffeeScriptLexer']
-
- class JavascriptLexer(RegexLexer):
- name = 'JavaScript'
- aliases = [
- 'js',
- 'javascript']
- filenames = [
- '*.js']
- mimetypes = [
- 'application/x-javascript',
- 'text/x-javascript',
- 'text/javascript']
- flags = re.DOTALL
- tokens = {
- 'commentsandwhitespace': [
- ('\\s+', Text),
- ('<!--', Comment),
- ('//.*?\\n', Comment.Single),
- ('/\\*.*?\\*/', Comment.Multiline)],
- 'slashstartsregex': [
- include('commentsandwhitespace'),
- ('/(\\\\.|[^[/\\\\\\n]|\\[(\\\\.|[^\\]\\\\\\n])*])+/([gim]+\\b|\\B)', String.Regex, '#pop'),
- ('(?=/)', Text, ('#pop', 'badregex')),
- ('', Text, '#pop')],
- 'badregex': [
- ('\n', Text, '#pop')],
- 'root': [
- ('^(?=\\s|/|<!--)', Text, 'slashstartsregex'),
- include('commentsandwhitespace'),
- ('\\+\\+|--|~|&&|\\?|:|\\|\\||\\\\(?=\\n)|(<<|>>>?|==?|!=?|[-<>+*%&\\|\\^/])=?', Operator, 'slashstartsregex'),
- ('[{(\\[;,]', Punctuation, 'slashstartsregex'),
- ('[})\\].]', Punctuation),
- ('(for|in|while|do|break|return|continue|switch|case|default|if|else|throw|try|catch|finally|new|delete|typeof|instanceof|void|this)\\b', Keyword, 'slashstartsregex'),
- ('(var|with|function)\\b', Keyword.Declaration, 'slashstartsregex'),
- ('(abstract|boolean|byte|char|class|const|debugger|double|enum|export|extends|final|float|goto|implements|import|int|interface|long|native|package|private|protected|public|short|static|super|synchronized|throws|transient|volatile)\\b', Keyword.Reserved),
- ('(true|false|null|NaN|Infinity|undefined)\\b', Keyword.Constant),
- ('(Array|Boolean|Date|Error|Function|Math|netscape|Number|Object|Packages|RegExp|String|sun|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|window)\\b', Name.Builtin),
- ('[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
- ('[0-9][0-9]*\\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
- ('0x[0-9a-fA-F]+', Number.Hex),
- ('[0-9]+', Number.Integer),
- ('"(\\\\\\\\|\\\\"|[^"])*"', String.Double),
- ("'(\\\\\\\\|\\\\'|[^'])*'", String.Single)] }
-
-
- class ActionScriptLexer(RegexLexer):
- name = 'ActionScript'
- aliases = [
- 'as',
- 'actionscript']
- filenames = [
- '*.as']
- mimetypes = [
- 'application/x-actionscript',
- 'text/x-actionscript',
- 'text/actionscript']
- flags = re.DOTALL
- tokens = {
- 'root': [
- ('\\s+', Text),
- ('//.*?\\n', Comment.Single),
- ('/\\*.*?\\*/', Comment.Multiline),
- ('/(\\\\\\\\|\\\\/|[^/\\n])*/[gim]*', String.Regex),
- ('[~\\^\\*!%&<>\\|+=:;,/?\\\\-]+', Operator),
- ('[{}\\[\\]();.]+', Punctuation),
- ('(case|default|for|each|in|while|do|break|return|continue|if|else|throw|try|catch|var|with|new|typeof|arguments|instanceof|this|switch)\\b', Keyword),
- ('(class|public|final|internal|native|override|private|protected|static|import|extends|implements|interface|intrinsic|return|super|dynamic|function|const|get|namespace|package|set)\\b', Keyword.Declaration),
- ('(true|false|null|NaN|Infinity|-Infinity|undefined|Void)\\b', Keyword.Constant),
- ('(Accessibility|AccessibilityProperties|ActionScriptVersion|ActivityEvent|AntiAliasType|ApplicationDomain|AsBroadcaster|Array|AsyncErrorEvent|AVM1Movie|BevelFilter|Bitmap|BitmapData|BitmapDataChannel|BitmapFilter|BitmapFilterQuality|BitmapFilterType|BlendMode|BlurFilter|Boolean|ByteArray|Camera|Capabilities|CapsStyle|Class|Color|ColorMatrixFilter|ColorTransform|ContextMenu|ContextMenuBuiltInItems|ContextMenuEvent|ContextMenuItem|ConvultionFilter|CSMSettings|DataEvent|Date|DefinitionError|DeleteObjectSample|Dictionary|DisplacmentMapFilter|DisplayObject|DisplacmentMapFilterMode|DisplayObjectContainer|DropShadowFilter|Endian|EOFError|Error|ErrorEvent|EvalError|Event|EventDispatcher|EventPhase|ExternalInterface|FileFilter|FileReference|FileReferenceList|FocusDirection|FocusEvent|Font|FontStyle|FontType|FrameLabel|FullScreenEvent|Function|GlowFilter|GradientBevelFilter|GradientGlowFilter|GradientType|Graphics|GridFitType|HTTPStatusEvent|IBitmapDrawable|ID3Info|IDataInput|IDataOutput|IDynamicPropertyOutputIDynamicPropertyWriter|IEventDispatcher|IExternalizable|IllegalOperationError|IME|IMEConversionMode|IMEEvent|int|InteractiveObject|InterpolationMethod|InvalidSWFError|InvokeEvent|IOError|IOErrorEvent|JointStyle|Key|Keyboard|KeyboardEvent|KeyLocation|LineScaleMode|Loader|LoaderContext|LoaderInfo|LoadVars|LocalConnection|Locale|Math|Matrix|MemoryError|Microphone|MorphShape|Mouse|MouseEvent|MovieClip|MovieClipLoader|Namespace|NetConnection|NetStatusEvent|NetStream|NewObjectSample|Number|Object|ObjectEncoding|PixelSnapping|Point|PrintJob|PrintJobOptions|PrintJobOrientation|ProgressEvent|Proxy|QName|RangeError|Rectangle|ReferenceError|RegExp|Responder|Sample|Scene|ScriptTimeoutError|Security|SecurityDomain|SecurityError|SecurityErrorEvent|SecurityPanel|Selection|Shape|SharedObject|SharedObjectFlushStatus|SimpleButton|Socket|Sound|SoundChannel|SoundLoaderContext|SoundMixer|SoundTransform|SpreadMethod|Sprite|StackFrame|StackOverflowError|Stage|StageAlign|StageDisplayState|StageQuality|StageScaleMode|StaticText|StatusEvent|String|StyleSheet|SWFVersion|SyncEvent|SyntaxError|System|TextColorType|TextField|TextFieldAutoSize|TextFieldType|TextFormat|TextFormatAlign|TextLineMetrics|TextRenderer|TextSnapshot|Timer|TimerEvent|Transform|TypeError|uint|URIError|URLLoader|URLLoaderDataFormat|URLRequest|URLRequestHeader|URLRequestMethod|URLStream|URLVariabeles|VerifyError|Video|XML|XMLDocument|XMLList|XMLNode|XMLNodeType|XMLSocket|XMLUI)\\b', Name.Builtin),
- ('(decodeURI|decodeURIComponent|encodeURI|escape|eval|isFinite|isNaN|isXMLName|clearInterval|fscommand|getTimer|getURL|getVersion|isFinite|parseFloat|parseInt|setInterval|trace|updateAfterEvent|unescape)\\b', Name.Function),
- ('[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
- ('[0-9][0-9]*\\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
- ('0x[0-9a-f]+', Number.Hex),
- ('[0-9]+', Number.Integer),
- ('"(\\\\\\\\|\\\\"|[^"])*"', String.Double),
- ("'(\\\\\\\\|\\\\'|[^'])*'", String.Single)] }
-
- def analyse_text(text):
- return 0.05
-
-
-
- class ActionScript3Lexer(RegexLexer):
- name = 'ActionScript 3'
- aliases = [
- 'as3',
- 'actionscript3']
- filenames = [
- '*.as']
- mimetypes = [
- 'application/x-actionscript',
- 'text/x-actionscript',
- 'text/actionscript']
- identifier = '[$a-zA-Z_][a-zA-Z0-9_]*'
- flags = re.DOTALL | re.MULTILINE
- tokens = {
- 'root': [
- ('\\s+', Text),
- ('(function\\s+)(' + identifier + ')(\\s*)(\\()', bygroups(Keyword.Declaration, Name.Function, Text, Operator), 'funcparams'),
- ('(var|const)(\\s+)(' + identifier + ')(\\s*)(:)(\\s*)(' + identifier + ')', bygroups(Keyword.Declaration, Text, Name, Text, Punctuation, Text, Keyword.Type)),
- ('(import|package)(\\s+)((?:' + identifier + '|\\.)+)(\\s*)', bygroups(Keyword, Text, Name.Namespace, Text)),
- ('(new)(\\s+)(' + identifier + ')(\\s*)(\\()', bygroups(Keyword, Text, Keyword.Type, Text, Operator)),
- ('//.*?\\n', Comment.Single),
- ('/\\*.*?\\*/', Comment.Multiline),
- ('/(\\\\\\\\|\\\\/|[^\\n])*/[gisx]*', String.Regex),
- ('(\\.)(' + identifier + ')', bygroups(Operator, Name.Attribute)),
- ('(case|default|for|each|in|while|do|break|return|continue|if|else|throw|try|catch|with|new|typeof|arguments|instanceof|this|switch|import|include|as|is)\\b', Keyword),
- ('(class|public|final|internal|native|override|private|protected|static|import|extends|implements|interface|intrinsic|return|super|dynamic|function|const|get|namespace|package|set)\\b', Keyword.Declaration),
- ('(true|false|null|NaN|Infinity|-Infinity|undefined|void)\\b', Keyword.Constant),
- ('(decodeURI|decodeURIComponent|encodeURI|escape|eval|isFinite|isNaN|isXMLName|clearInterval|fscommand|getTimer|getURL|getVersion|isFinite|parseFloat|parseInt|setInterval|trace|updateAfterEvent|unescape)\\b', Name.Function),
- (identifier, Name),
- ('[0-9][0-9]*\\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
- ('0x[0-9a-f]+', Number.Hex),
- ('[0-9]+', Number.Integer),
- ('"(\\\\\\\\|\\\\"|[^"])*"', String.Double),
- ("'(\\\\\\\\|\\\\'|[^'])*'", String.Single),
- ('[~\\^\\*!%&<>\\|+=:;,/?\\\\{}\\[\\]();.-]+', Operator)],
- 'funcparams': [
- ('\\s+', Text),
- ('(\\s*)(\\.\\.\\.)?(' + identifier + ')(\\s*)(:)(\\s*)(' + identifier + '|\\*)(\\s*)', bygroups(Text, Punctuation, Name, Text, Operator, Text, Keyword.Type, Text), 'defval'),
- ('\\)', Operator, 'type')],
- 'type': [
- ('(\\s*)(:)(\\s*)(' + identifier + '|\\*)', bygroups(Text, Operator, Text, Keyword.Type), '#pop:2'),
- ('\\s*', Text, '#pop:2')],
- 'defval': [
- ('(=)(\\s*)([^(),]+)(\\s*)(,?)', bygroups(Operator, Text, using(this), Text, Operator), '#pop'),
- (',?', Operator, '#pop')] }
-
- def analyse_text(text):
- if re.match('\\w+\\s*:\\s*\\w', text):
- return 0.3
- return 0.1
-
-
-
- class CssLexer(RegexLexer):
- name = 'CSS'
- aliases = [
- 'css']
- filenames = [
- '*.css']
- mimetypes = [
- 'text/css']
- tokens = {
- 'root': [
- include('basics')],
- 'basics': [
- ('\\s+', Text),
- ('/\\*(?:.|\\n)*?\\*/', Comment),
- ('{', Punctuation, 'content'),
- ('\\:[a-zA-Z0-9_-]+', Name.Decorator),
- ('\\.[a-zA-Z0-9_-]+', Name.Class),
- ('\\#[a-zA-Z0-9_-]+', Name.Function),
- ('@[a-zA-Z0-9_-]+', Keyword, 'atrule'),
- ('[a-zA-Z0-9_-]+', Name.Tag),
- ('[~\\^\\*!%&\\[\\]\\(\\)<>\\|+=@:;,./?-]', Operator),
- ('"(\\\\\\\\|\\\\"|[^"])*"', String.Double),
- ("'(\\\\\\\\|\\\\'|[^'])*'", String.Single)],
- 'atrule': [
- ('{', Punctuation, 'atcontent'),
- (';', Punctuation, '#pop'),
- include('basics')],
- 'atcontent': [
- include('basics'),
- ('}', Punctuation, '#pop:2')],
- 'content': [
- ('\\s+', Text),
- ('}', Punctuation, '#pop'),
- ('url\\(.*?\\)', String.Other),
- ('^@.*?$', Comment.Preproc),
- ('(azimuth|background-attachment|background-color|background-image|background-position|background-repeat|background|border-bottom-color|border-bottom-style|border-bottom-width|border-left-color|border-left-style|border-left-width|border-right|border-right-color|border-right-style|border-right-width|border-top-color|border-top-style|border-top-width|border-bottom|border-collapse|border-left|border-width|border-color|border-spacing|border-style|border-top|border|caption-side|clear|clip|color|content|counter-increment|counter-reset|cue-after|cue-before|cue|cursor|direction|display|elevation|empty-cells|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|height|letter-spacing|line-height|list-style-type|list-style-image|list-style-position|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|marker-offset|marks|max-height|max-width|min-height|min-width|opacity|orphans|outline|outline-color|outline-style|outline-width|overflow(?:-x|-y|)|padding-bottom|padding-left|padding-right|padding-top|padding|page|page-break-after|page-break-before|page-break-inside|pause-after|pause-before|pause|pitch|pitch-range|play-during|position|quotes|richness|right|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|table-layout|text-align|text-decoration|text-indent|text-shadow|text-transform|top|unicode-bidi|vertical-align|visibility|voice-family|volume|white-space|widows|width|word-spacing|z-index|bottom|left|above|absolute|always|armenian|aural|auto|avoid|baseline|behind|below|bidi-override|blink|block|bold|bolder|both|capitalize|center-left|center-right|center|circle|cjk-ideographic|close-quote|collapse|condensed|continuous|crop|crosshair|cross|cursive|dashed|decimal-leading-zero|decimal|default|digits|disc|dotted|double|e-resize|embed|extra-condensed|extra-expanded|expanded|fantasy|far-left|far-right|faster|fast|fixed|georgian|groove|hebrew|help|hidden|hide|higher|high|hiragana-iroha|hiragana|icon|inherit|inline-table|inline|inset|inside|invert|italic|justify|katakana-iroha|katakana|landscape|larger|large|left-side|leftwards|level|lighter|line-through|list-item|loud|lower-alpha|lower-greek|lower-roman|lowercase|ltr|lower|low|medium|message-box|middle|mix|monospace|n-resize|narrower|ne-resize|no-close-quote|no-open-quote|no-repeat|none|normal|nowrap|nw-resize|oblique|once|open-quote|outset|outside|overline|pointer|portrait|px|relative|repeat-x|repeat-y|repeat|rgb|ridge|right-side|rightwards|s-resize|sans-serif|scroll|se-resize|semi-condensed|semi-expanded|separate|serif|show|silent|slow|slower|small-caps|small-caption|smaller|soft|solid|spell-out|square|static|status-bar|super|sw-resize|table-caption|table-cell|table-column|table-column-group|table-footer-group|table-header-group|table-row|table-row-group|text|text-bottom|text-top|thick|thin|transparent|ultra-condensed|ultra-expanded|underline|upper-alpha|upper-latin|upper-roman|uppercase|url|visible|w-resize|wait|wider|x-fast|x-high|x-large|x-loud|x-low|x-small|x-soft|xx-large|xx-small|yes)\\b', Keyword),
- ('(indigo|gold|firebrick|indianred|yellow|darkolivegreen|darkseagreen|mediumvioletred|mediumorchid|chartreuse|mediumslateblue|black|springgreen|crimson|lightsalmon|brown|turquoise|olivedrab|cyan|silver|skyblue|gray|darkturquoise|goldenrod|darkgreen|darkviolet|darkgray|lightpink|teal|darkmagenta|lightgoldenrodyellow|lavender|yellowgreen|thistle|violet|navy|orchid|blue|ghostwhite|honeydew|cornflowerblue|darkblue|darkkhaki|mediumpurple|cornsilk|red|bisque|slategray|darkcyan|khaki|wheat|deepskyblue|darkred|steelblue|aliceblue|gainsboro|mediumturquoise|floralwhite|coral|purple|lightgrey|lightcyan|darksalmon|beige|azure|lightsteelblue|oldlace|greenyellow|royalblue|lightseagreen|mistyrose|sienna|lightcoral|orangered|navajowhite|lime|palegreen|burlywood|seashell|mediumspringgreen|fuchsia|papayawhip|blanchedalmond|peru|aquamarine|white|darkslategray|ivory|dodgerblue|lemonchiffon|chocolate|orange|forestgreen|slateblue|olive|mintcream|antiquewhite|darkorange|cadetblue|moccasin|limegreen|saddlebrown|darkslateblue|lightskyblue|deeppink|plum|aqua|darkgoldenrod|maroon|sandybrown|magenta|tan|rosybrown|pink|lightblue|palevioletred|mediumseagreen|dimgray|powderblue|seagreen|snow|mediumblue|midnightblue|paleturquoise|palegoldenrod|whitesmoke|darkorchid|salmon|lightslategray|lawngreen|lightgreen|tomato|hotpink|lightyellow|lavenderblush|linen|mediumaquamarine|green|blueviolet|peachpuff)\\b', Name.Builtin),
- ('\\!important', Comment.Preproc),
- ('/\\*(?:.|\\n)*?\\*/', Comment),
- ('\\#[a-zA-Z0-9]{1,6}', Number),
- ('[\\.-]?[0-9]*[\\.]?[0-9]+(em|px|\\%|pt|pc|in|mm|cm|ex)', Number),
- ('-?[0-9]+', Number),
- ('[~\\^\\*!%&<>\\|+=@:,./?-]+', Operator),
- ('[\\[\\]();]+', Punctuation),
- ('"(\\\\\\\\|\\\\"|[^"])*"', String.Double),
- ("'(\\\\\\\\|\\\\'|[^'])*'", String.Single),
- ('[a-zA-Z][a-zA-Z0-9]+', Name)] }
-
-
- class ObjectiveJLexer(RegexLexer):
- name = 'Objective-J'
- aliases = [
- 'objective-j',
- 'objectivej',
- 'obj-j',
- 'objj']
- filenames = [
- '*.j']
- mimetypes = [
- 'text/x-objective-j']
- _ws = '(?:\\s|//.*?\\n|/[*].*?[*]/)*'
- flags = re.DOTALL | re.MULTILINE
- tokens = {
- 'root': [
- include('whitespace'),
- ('^(' + _ws + '[\\+-]' + _ws + ')([\\(a-zA-Z_].*?[^\\(])(' + _ws + '{)', bygroups(using(this), using(this, state = 'function_signature'), using(this))),
- ('(@interface|@implementation)(\\s+)', bygroups(Keyword, Text), 'classname'),
- ('(@class|@protocol)(\\s*)', bygroups(Keyword, Text), 'forward_classname'),
- ('(\\s*)(@end)(\\s*)', bygroups(Text, Keyword, Text)),
- include('statements'),
- ('[{\\(\\)}]', Punctuation),
- (';', Punctuation)],
- 'whitespace': [
- ('(@import)(\\s+)("(\\\\\\\\|\\\\"|[^"])*")', bygroups(Comment.Preproc, Text, String.Double)),
- ('(@import)(\\s+)(<(\\\\\\\\|\\\\>|[^>])*>)', bygroups(Comment.Preproc, Text, String.Double)),
- ('(#(?:include|import))(\\s+)("(\\\\\\\\|\\\\"|[^"])*")', bygroups(Comment.Preproc, Text, String.Double)),
- ('(#(?:include|import))(\\s+)(<(\\\\\\\\|\\\\>|[^>])*>)', bygroups(Comment.Preproc, Text, String.Double)),
- ('#if\\s+0', Comment.Preproc, 'if0'),
- ('#', Comment.Preproc, 'macro'),
- ('\\n', Text),
- ('\\s+', Text),
- ('\\\\\\n', Text),
- ('//(\\n|(.|\\n)*?[^\\\\]\\n)', Comment.Single),
- ('/(\\\\\\n)?[*](.|\\n)*?[*](\\\\\\n)?/', Comment.Multiline),
- ('<!--', Comment)],
- 'slashstartsregex': [
- include('whitespace'),
- ('/(\\\\.|[^[/\\\\\\n]|\\[(\\\\.|[^\\]\\\\\\n])*])+/([gim]+\\b|\\B)', String.Regex, '#pop'),
- ('(?=/)', Text, ('#pop', 'badregex')),
- ('', Text, '#pop')],
- 'badregex': [
- ('\n', Text, '#pop')],
- 'statements': [
- ('(L|@)?"', String, 'string'),
- ("(L|@)?'(\\\\.|\\\\[0-7]{1,3}|\\\\x[a-fA-F0-9]{1,2}|[^\\\\\\'\\n])'", String.Char),
- ('"(\\\\\\\\|\\\\"|[^"])*"', String.Double),
- ("'(\\\\\\\\|\\\\'|[^'])*'", String.Single),
- ('(\\d+\\.\\d*|\\.\\d+|\\d+)[eE][+-]?\\d+[lL]?', Number.Float),
- ('(\\d+\\.\\d*|\\.\\d+|\\d+[fF])[fF]?', Number.Float),
- ('0x[0-9a-fA-F]+[Ll]?', Number.Hex),
- ('0[0-7]+[Ll]?', Number.Oct),
- ('\\d+[Ll]?', Number.Integer),
- ('^(?=\\s|/|<!--)', Text, 'slashstartsregex'),
- ('\\+\\+|--|~|&&|\\?|:|\\|\\||\\\\(?=\\n)|(<<|>>>?|==?|!=?|[-<>+*%&\\|\\^/])=?', Operator, 'slashstartsregex'),
- ('[{(\\[;,]', Punctuation, 'slashstartsregex'),
- ('[})\\].]', Punctuation),
- ('(for|in|while|do|break|return|continue|switch|case|default|if|else|throw|try|catch|finally|new|delete|typeof|instanceof|void|prototype|__proto__)\\b', Keyword, 'slashstartsregex'),
- ('(var|with|function)\\b', Keyword.Declaration, 'slashstartsregex'),
- ('(@selector|@private|@protected|@public|@encode|@synchronized|@try|@throw|@catch|@finally|@end|@property|@synthesize|@dynamic|@for|@accessors|new)\\b', Keyword),
- ('(int|long|float|short|double|char|unsigned|signed|void|id|BOOL|bool|boolean|IBOutlet|IBAction|SEL|@outlet|@action)\\b', Keyword.Type),
- ('(self|super)\\b', Name.Builtin),
- ('(TRUE|YES|FALSE|NO|Nil|nil|NULL)\\b', Keyword.Constant),
- ('(true|false|null|NaN|Infinity|undefined)\\b', Keyword.Constant),
- ('(ABS|ASIN|ACOS|ATAN|ATAN2|SIN|COS|TAN|EXP|POW|CEIL|FLOOR|ROUND|MIN|MAX|RAND|SQRT|E|LN2|LN10|LOG2E|LOG10E|PI|PI2|PI_2|SQRT1_2|SQRT2)\\b', Keyword.Constant),
- ('(Array|Boolean|Date|Error|Function|Math|netscape|Number|Object|Packages|RegExp|String|sun|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|window)\\b', Name.Builtin),
- ('([$a-zA-Z_][a-zA-Z0-9_]*)(' + _ws + ')(?=\\()', bygroups(Name.Function, using(this))),
- ('[$a-zA-Z_][a-zA-Z0-9_]*', Name)],
- 'classname': [
- ('([a-zA-Z_][a-zA-Z0-9_]*)(' + _ws + ':' + _ws + ')([a-zA-Z_][a-zA-Z0-9_]*)?', bygroups(Name.Class, using(this), Name.Class), '#pop'),
- ('([a-zA-Z_][a-zA-Z0-9_]*)(' + _ws + '\\()([a-zA-Z_][a-zA-Z0-9_]*)(\\))', bygroups(Name.Class, using(this), Name.Label, Text), '#pop'),
- ('([a-zA-Z_][a-zA-Z0-9_]*)', Name.Class, '#pop')],
- 'forward_classname': [
- ('([a-zA-Z_][a-zA-Z0-9_]*)(\\s*,\\s*)', bygroups(Name.Class, Text), '#push'),
- ('([a-zA-Z_][a-zA-Z0-9_]*)(\\s*;?)', bygroups(Name.Class, Text), '#pop')],
- 'function_signature': [
- include('whitespace'),
- ('(\\(' + _ws + ')([a-zA-Z_][a-zA-Z0-9_]+)(' + _ws + '\\)' + _ws + ')([$a-zA-Z_][a-zA-Z0-9_]+' + _ws + ':)', bygroups(using(this), Keyword.Type, using(this), Name.Function), 'function_parameters'),
- ('(\\(' + _ws + ')([a-zA-Z_][a-zA-Z0-9_]+)(' + _ws + '\\)' + _ws + ')([$a-zA-Z_][a-zA-Z0-9_]+)', bygroups(using(this), Keyword.Type, using(this), Name.Function), '#pop'),
- ('([$a-zA-Z_][a-zA-Z0-9_]+' + _ws + ':)', bygroups(Name.Function), 'function_parameters'),
- ('([$a-zA-Z_][a-zA-Z0-9_]+)', bygroups(Name.Function), '#pop'),
- ('', Text, '#pop')],
- 'function_parameters': [
- include('whitespace'),
- ('(\\(' + _ws + ')([^\\)]+)(' + _ws + '\\)' + _ws + ')+([$a-zA-Z_][a-zA-Z0-9_]+)', bygroups(using(this), Keyword.Type, using(this), Text)),
- ('([$a-zA-Z_][a-zA-Z0-9_]+' + _ws + ':)', Name.Function),
- ('(:)', Name.Function),
- ('(,' + _ws + '...)', using(this)),
- ('([$a-zA-Z_][a-zA-Z0-9_]+)', Text)],
- 'expression': [
- ('([$a-zA-Z_][a-zA-Z0-9_]*)(\\()', bygroups(Name.Function, Punctuation)),
- ('(\\))', Punctuation, '#pop')],
- 'string': [
- ('"', String, '#pop'),
- ('\\\\([\\\\abfnrtv"\\\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
- ('[^\\\\"\\n]+', String),
- ('\\\\\\n', String),
- ('\\\\', String)],
- 'macro': [
- ('[^/\\n]+', Comment.Preproc),
- ('/[*](.|\\n)*?[*]/', Comment.Multiline),
- ('//.*?\\n', Comment.Single, '#pop'),
- ('/', Comment.Preproc),
- ('(?<=\\\\)\\n', Comment.Preproc),
- ('\\n', Comment.Preproc, '#pop')],
- 'if0': [
- ('^\\s*#if.*?(?<!\\\\)\\n', Comment.Preproc, '#push'),
- ('^\\s*#endif.*?(?<!\\\\)\\n', Comment.Preproc, '#pop'),
- ('.*?\\n', Comment)] }
-
- def analyse_text(text):
- if re.search('^\\s*@import\\s+[<"]', text, re.MULTILINE):
- return True
- return False
-
-
-
- class HtmlLexer(RegexLexer):
- name = 'HTML'
- aliases = [
- 'html']
- filenames = [
- '*.html',
- '*.htm',
- '*.xhtml',
- '*.xslt']
- mimetypes = [
- 'text/html',
- 'application/xhtml+xml']
- flags = re.IGNORECASE | re.DOTALL
- tokens = {
- 'root': [
- ('[^<&]+', Text),
- ('&\\S*?;', Name.Entity),
- ('\\<\\!\\[CDATA\\[.*?\\]\\]\\>', Comment.Preproc),
- ('<!--', Comment, 'comment'),
- ('<\\?.*?\\?>', Comment.Preproc),
- ('<![^>]*>', Comment.Preproc),
- ('<\\s*script\\s*', Name.Tag, ('script-content', 'tag')),
- ('<\\s*style\\s*', Name.Tag, ('style-content', 'tag')),
- ('<\\s*[a-zA-Z0-9:]+', Name.Tag, 'tag'),
- ('<\\s*/\\s*[a-zA-Z0-9:]+\\s*>', Name.Tag)],
- 'comment': [
- ('[^-]+', Comment),
- ('-->', Comment, '#pop'),
- ('-', Comment)],
- 'tag': [
- ('\\s+', Text),
- ('[a-zA-Z0-9_:-]+\\s*=', Name.Attribute, 'attr'),
- ('[a-zA-Z0-9_:-]+', Name.Attribute),
- ('/?\\s*>', Name.Tag, '#pop')],
- 'script-content': [
- ('<\\s*/\\s*script\\s*>', Name.Tag, '#pop'),
- ('.+?(?=<\\s*/\\s*script\\s*>)', using(JavascriptLexer))],
- 'style-content': [
- ('<\\s*/\\s*style\\s*>', Name.Tag, '#pop'),
- ('.+?(?=<\\s*/\\s*style\\s*>)', using(CssLexer))],
- 'attr': [
- ('".*?"', String, '#pop'),
- ("'.*?'", String, '#pop'),
- ('[^\\s>]+', String, '#pop')] }
-
- def analyse_text(text):
- if html_doctype_matches(text):
- return 0.5
-
-
-
- class PhpLexer(RegexLexer):
- name = 'PHP'
- aliases = [
- 'php',
- 'php3',
- 'php4',
- 'php5']
- filenames = [
- '*.php',
- '*.php[345]']
- mimetypes = [
- 'text/x-php']
- flags = re.IGNORECASE | re.DOTALL | re.MULTILINE
- tokens = {
- 'root': [
- ('<\\?(php)?', Comment.Preproc, 'php'),
- ('[^<]+', Other),
- ('<', Other)],
- 'php': [
- ('\\?>', Comment.Preproc, '#pop'),
- ("<<<(\\'?)([a-zA-Z_][a-zA-Z0-9_]*)\\1\\n.*?\\n\\2\\;?\\n", String),
- ('\\s+', Text),
- ('#.*?\\n', Comment.Single),
- ('//.*?\\n', Comment.Single),
- ('/\\*\\*/', Comment.Multiline),
- ('/\\*\\*.*?\\*/', String.Doc),
- ('/\\*.*?\\*/', Comment.Multiline),
- ('(->|::)(\\s*)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Text, Name.Attribute)),
- ('[~!%^&*+=|:.<>/?@-]+', Operator),
- ('[\\[\\]{}();,]+', Punctuation),
- ('(class)(\\s+)', bygroups(Keyword, Text), 'classname'),
- ('(function)(\\s*)(?=\\()', bygroups(Keyword, Text)),
- ('(function)(\\s+)(&?)(\\s*)', bygroups(Keyword, Text, Operator, Text), 'functionname'),
- ('(const)(\\s+)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Keyword, Text, Name.Constant)),
- ('(and|E_PARSE|old_function|E_ERROR|or|as|E_WARNING|parent|eval|PHP_OS|break|exit|case|extends|PHP_VERSION|cfunction|FALSE|print|for|require|continue|foreach|require_once|declare|return|default|static|do|switch|die|stdClass|echo|else|TRUE|elseif|var|empty|if|xor|enddeclare|include|virtual|endfor|include_once|while|endforeach|global|__FILE__|endif|list|__LINE__|endswitch|new|__sleep|endwhile|not|array|__wakeup|E_ALL|NULL|final|php_user_filter|interface|implements|public|private|protected|abstract|clone|try|catch|throw|this|use|namespace)\\b', Keyword),
- ('(true|false|null)\x08', Keyword.Constant),
- ('\\$\\{\\$+[a-zA-Z_][a-zA-Z0-9_]*\\}', Name.Variable),
- ('\\$+[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable),
- ('[\\\\a-zA-Z_][\\\\a-zA-Z0-9_]*', Name.Other),
- ('[0-9](\\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?', Number),
- ("'([^'\\\\]*(?:\\\\.[^'\\\\]*)*)'", String.Single),
- ('`([^`\\\\]*(?:\\\\.[^`\\\\]*)*)`', String.Backtick),
- ('"', String.Double, 'string')],
- 'classname': [
- ('[a-zA-Z_][\\\\a-zA-Z0-9_]*', Name.Class, '#pop')],
- 'functionname': [
- ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop')],
- 'string': [
- ('"', String.Double, '#pop'),
- ('[^{$"\\\\]+', String.Double),
- ('\\\\([nrt\\"$]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})', String.Escape),
- ('\\$[a-zA-Z_][a-zA-Z0-9_]*(\\[\\S+\\]|->[a-zA-Z_][a-zA-Z0-9_]*)?', String.Interpol),
- ('(\\{\\$\\{)(.*?)(\\}\\})', bygroups(String.Interpol, using(this, _startinline = True), String.Interpol)),
- ('(\\{)(\\$.*?)(\\})', bygroups(String.Interpol, using(this, _startinline = True), String.Interpol)),
- ('(\\$\\{)(\\S+)(\\})', bygroups(String.Interpol, Name.Variable, String.Interpol)),
- ('[${\\\\]+', String.Double)] }
-
- def __init__(self, **options):
- self.funcnamehighlighting = get_bool_opt(options, 'funcnamehighlighting', True)
- self.disabledmodules = get_list_opt(options, 'disabledmodules', [
- 'unknown'])
- self.startinline = get_bool_opt(options, 'startinline', False)
- if '_startinline' in options:
- self.startinline = options.pop('_startinline')
-
- self._functions = set()
- if self.funcnamehighlighting:
- MODULES = MODULES
- import pygments.lexers._phpbuiltins
- for key, value in MODULES.iteritems():
- if key not in self.disabledmodules:
- self._functions.update(value)
- continue
-
-
- RegexLexer.__init__(self, **options)
-
-
- def get_tokens_unprocessed(self, text):
- stack = [
- 'root']
- if self.startinline:
- stack.append('php')
-
- for index, token, value in RegexLexer.get_tokens_unprocessed(self, text, stack):
- if token is Name.Other:
- if value in self._functions:
- yield (index, Name.Builtin, value)
- continue
-
-
- yield (index, token, value)
-
-
-
- def analyse_text(text):
- rv = 0
- if re.search('<\\?(?!xml)', text):
- rv += 0.3
-
- if '?>' in text:
- rv += 0.1
-
- return rv
-
-
-
- class XmlLexer(RegexLexer):
- flags = re.MULTILINE | re.DOTALL
- name = 'XML'
- aliases = [
- 'xml']
- filenames = [
- '*.xml',
- '*.xsl',
- '*.rss',
- '*.xslt',
- '*.xsd',
- '*.wsdl']
- mimetypes = [
- 'text/xml',
- 'application/xml',
- 'image/svg+xml',
- 'application/rss+xml',
- 'application/atom+xml',
- 'application/xsl+xml',
- 'application/xslt+xml']
- tokens = {
- 'root': [
- ('[^<&]+', Text),
- ('&\\S*?;', Name.Entity),
- ('\\<\\!\\[CDATA\\[.*?\\]\\]\\>', Comment.Preproc),
- ('<!--', Comment, 'comment'),
- ('<\\?.*?\\?>', Comment.Preproc),
- ('<![^>]*>', Comment.Preproc),
- ('<\\s*[a-zA-Z0-9:._-]+', Name.Tag, 'tag'),
- ('<\\s*/\\s*[a-zA-Z0-9:._-]+\\s*>', Name.Tag)],
- 'comment': [
- ('[^-]+', Comment),
- ('-->', Comment, '#pop'),
- ('-', Comment)],
- 'tag': [
- ('\\s+', Text),
- ('[a-zA-Z0-9_.:-]+\\s*=', Name.Attribute, 'attr'),
- ('/?\\s*>', Name.Tag, '#pop')],
- 'attr': [
- ('\\s+', Text),
- ('".*?"', String, '#pop'),
- ("'.*?'", String, '#pop'),
- ('[^\\s>]+', String, '#pop')] }
-
- def analyse_text(text):
- if looks_like_xml(text):
- return 0.5
-
-
-
- class XsltLexer(XmlLexer):
- name = 'XSLT'
- aliases = [
- 'xslt']
- filenames = [
- '*.xsl',
- '*.xslt']
- EXTRA_KEYWORDS = set([
- 'apply-imports',
- 'apply-templates',
- 'attribute',
- 'attribute-set',
- 'call-template',
- 'choose',
- 'comment',
- 'copy',
- 'copy-of',
- 'decimal-format',
- 'element',
- 'fallback',
- 'for-each',
- 'if',
- 'import',
- 'include',
- 'key',
- 'message',
- 'namespace-alias',
- 'number',
- 'otherwise',
- 'output',
- 'param',
- 'preserve-space',
- 'processing-instruction',
- 'sort',
- 'strip-space',
- 'stylesheet',
- 'template',
- 'text',
- 'transform',
- 'value-of',
- 'variable',
- 'when',
- 'with-param'])
-
- def get_tokens_unprocessed(self, text):
- for index, token, value in XmlLexer.get_tokens_unprocessed(self, text):
- m = re.match('</?xsl:([^>]*)/?>?', value)
- if token is Name.Tag and m and m.group(1) in self.EXTRA_KEYWORDS:
- yield (index, Keyword, value)
- continue
- yield (index, token, value)
-
-
-
- def analyse_text(text):
- if looks_like_xml(text) and '<xsl' in text:
- return 0.8
-
-
-
- class MxmlLexer(RegexLexer):
- flags = re.MULTILINE | re.DOTALL
- name = 'MXML'
- aliases = [
- 'mxml']
- filenames = [
- '*.mxml']
- mimetimes = [
- 'text/xml',
- 'application/xml']
- tokens = {
- 'root': [
- ('[^<&]+', Text),
- ('&\\S*?;', Name.Entity),
- ('(\\<\\!\\[CDATA\\[)(.*?)(\\]\\]\\>)', bygroups(String, using(ActionScript3Lexer), String)),
- ('<!--', Comment, 'comment'),
- ('<\\?.*?\\?>', Comment.Preproc),
- ('<![^>]*>', Comment.Preproc),
- ('<\\s*[a-zA-Z0-9:._-]+', Name.Tag, 'tag'),
- ('<\\s*/\\s*[a-zA-Z0-9:._-]+\\s*>', Name.Tag)],
- 'comment': [
- ('[^-]+', Comment),
- ('-->', Comment, '#pop'),
- ('-', Comment)],
- 'tag': [
- ('\\s+', Text),
- ('[a-zA-Z0-9_.:-]+\\s*=', Name.Attribute, 'attr'),
- ('/?\\s*>', Name.Tag, '#pop')],
- 'attr': [
- ('\\s+', Text),
- ('".*?"', String, '#pop'),
- ("'.*?'", String, '#pop'),
- ('[^\\s>]+', String, '#pop')] }
-
-
- class HaxeLexer(RegexLexer):
- name = 'haXe'
- aliases = [
- 'hx',
- 'haXe']
- filenames = [
- '*.hx']
- mimetypes = [
- 'text/haxe']
- ident = '(?:[a-zA-Z_][a-zA-Z0-9_]*)'
- typeid = '(?:(?:[a-z0-9_\\.])*[A-Z_][A-Za-z0-9_]*)'
- key_prop = '(?:default|null|never)'
- key_decl_mod = '(?:public|private|override|static|inline|extern|dynamic)'
- flags = re.DOTALL | re.MULTILINE
- tokens = {
- 'root': [
- include('whitespace'),
- include('comments'),
- (key_decl_mod, Keyword.Declaration),
- include('enumdef'),
- include('typedef'),
- include('classdef'),
- include('imports')],
- 'comments': [
- ('//.*?\\n', Comment.Single),
- ('/\\*.*?\\*/', Comment.Multiline),
- ('#[^\\n]*', Comment.Preproc)],
- 'whitespace': [
- include('comments'),
- ('\\s+', Text)],
- 'codekeywords': [
- ('\\b(if|else|while|do|for|in|break|continue|return|switch|case|try|catch|throw|null|trace|new|this|super|untyped|cast|callback|here)\\b', Keyword.Reserved)],
- 'literals': [
- ('0[xX][0-9a-fA-F]+', Number.Hex),
- ('[0-9]+', Number.Integer),
- ('[0-9][0-9]*\\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
- ("'(\\\\\\\\|\\\\'|[^'])*'", String.Single),
- ('"(\\\\\\\\|\\\\"|[^"])*"', String.Double),
- ('~/([^\\n])*?/[gisx]*', String.Regex),
- ('\\b(true|false|null)\\b', Keyword.Constant)],
- 'codeblock': [
- include('whitespace'),
- include('new'),
- include('case'),
- include('anonfundef'),
- include('literals'),
- include('vardef'),
- include('codekeywords'),
- ('[();,\\[\\]]', Punctuation),
- ('(?:=|\\+=|-=|\\*=|/=|%=|&=|\\|=|\\^=|<<=|>>=|>>>=|\\|\\||&&|\\.\\.\\.|==|!=|>|<|>=|<=|\\||&|\\^|<<|>>|>>>|\\+|\\-|\\*|/|%|!|\\+\\+|\\-\\-|~|\\.|\\?|\\:)', Operator),
- (ident, Name),
- ('}', Punctuation, '#pop'),
- ('{', Punctuation, '#push')],
- 'propertydef': [
- ('(\\()(' + key_prop + ')(,)(' + key_prop + ')(\\))', bygroups(Punctuation, Keyword.Reserved, Punctuation, Keyword.Reserved, Punctuation))],
- 'new': [
- ('\\bnew\\b', Keyword, 'typedecl')],
- 'case': [
- ('\\b(case)(\\s+)(' + ident + ')(\\s*)(\\()', bygroups(Keyword.Reserved, Text, Name, Text, Punctuation), 'funargdecl')],
- 'vardef': [
- ('\\b(var)(\\s+)(' + ident + ')', bygroups(Keyword.Declaration, Text, Name.Variable), 'vardecl')],
- 'vardecl': [
- include('whitespace'),
- include('typelabel'),
- ('=', Operator, '#pop'),
- (';', Punctuation, '#pop')],
- 'instancevardef': [
- (key_decl_mod, Keyword.Declaration),
- ('\\b(var)(\\s+)(' + ident + ')', bygroups(Keyword.Declaration, Text, Name.Variable.Instance), 'instancevardecl')],
- 'instancevardecl': [
- include('vardecl'),
- include('propertydef')],
- 'anonfundef': [
- ('\\bfunction\\b', Keyword.Declaration, 'fundecl')],
- 'instancefundef': [
- (key_decl_mod, Keyword.Declaration),
- ('\\b(function)(\\s+)(' + ident + ')', bygroups(Keyword.Declaration, Text, Name.Function), 'fundecl')],
- 'fundecl': [
- include('whitespace'),
- include('typelabel'),
- include('generictypedecl'),
- ('\\(', Punctuation, 'funargdecl'),
- ('(?=[a-zA-Z0-9_])', Text, '#pop'),
- ('{', Punctuation, ('#pop', 'codeblock')),
- (';', Punctuation, '#pop')],
- 'funargdecl': [
- include('whitespace'),
- (ident, Name.Variable),
- include('typelabel'),
- include('literals'),
- ('=', Operator),
- (',', Punctuation),
- ('\\?', Punctuation),
- ('\\)', Punctuation, '#pop')],
- 'typelabel': [
- (':', Punctuation, 'type')],
- 'typedecl': [
- include('whitespace'),
- (typeid, Name.Class),
- ('<', Punctuation, 'generictypedecl'),
- ('(?=[{}()=,a-z])', Text, '#pop')],
- 'type': [
- include('whitespace'),
- (typeid, Name.Class),
- ('<', Punctuation, 'generictypedecl'),
- ('->', Keyword.Type),
- ('(?=[{}(),;=])', Text, '#pop')],
- 'generictypedecl': [
- include('whitespace'),
- (typeid, Name.Class),
- ('<', Punctuation, '#push'),
- ('>', Punctuation, '#pop'),
- (',', Punctuation)],
- 'imports': [
- ('(package|import|using)(\\s+)([^;]+)(;)', bygroups(Keyword.Namespace, Text, Name.Namespace, Punctuation))],
- 'typedef': [
- ('typedef', Keyword.Declaration, ('typedefprebody', 'typedecl'))],
- 'typedefprebody': [
- include('whitespace'),
- ('(=)(\\s*)({)', bygroups(Punctuation, Text, Punctuation), ('#pop', 'typedefbody'))],
- 'enumdef': [
- ('enum', Keyword.Declaration, ('enumdefprebody', 'typedecl'))],
- 'enumdefprebody': [
- include('whitespace'),
- ('{', Punctuation, ('#pop', 'enumdefbody'))],
- 'classdef': [
- ('class', Keyword.Declaration, ('classdefprebody', 'typedecl'))],
- 'classdefprebody': [
- include('whitespace'),
- ('(extends|implements)', Keyword.Declaration, 'typedecl'),
- ('{', Punctuation, ('#pop', 'classdefbody'))],
- 'interfacedef': [
- ('interface', Keyword.Declaration, ('interfacedefprebody', 'typedecl'))],
- 'interfacedefprebody': [
- include('whitespace'),
- ('(extends)', Keyword.Declaration, 'typedecl'),
- ('{', Punctuation, ('#pop', 'classdefbody'))],
- 'typedefbody': [
- include('whitespace'),
- include('instancevardef'),
- include('instancefundef'),
- ('>', Punctuation, 'typedecl'),
- (',', Punctuation),
- ('}', Punctuation, '#pop')],
- 'enumdefbody': [
- include('whitespace'),
- (ident, Name.Variable.Instance),
- ('\\(', Punctuation, 'funargdecl'),
- (';', Punctuation),
- ('}', Punctuation, '#pop')],
- 'classdefbody': [
- include('whitespace'),
- include('instancevardef'),
- include('instancefundef'),
- ('}', Punctuation, '#pop'),
- include('codeblock')] }
-
- def analyse_text(text):
- if re.match('\\w+\\s*:\\s*\\w', text):
- return 0.3
-
-
-
- def _indentation(lexer, match, ctx):
- indentation = match.group(0)
- yield (match.start(), Text, indentation)
- ctx.last_indentation = indentation
- ctx.pos = match.end()
- if hasattr(ctx, 'block_state') and ctx.block_state and indentation.startswith(ctx.block_indentation) and indentation != ctx.block_indentation:
- ctx.stack.append(ctx.block_state)
- else:
- ctx.block_state = None
- ctx.block_indentation = None
- ctx.stack.append('content')
-
-
- def _starts_block(token, state):
-
- def callback(lexer, match, ctx):
- yield (match.start(), token, match.group(0))
- if hasattr(ctx, 'last_indentation'):
- ctx.block_indentation = ctx.last_indentation
- else:
- ctx.block_indentation = ''
- ctx.block_state = state
- ctx.pos = match.end()
-
- return callback
-
-
- class HamlLexer(ExtendedRegexLexer):
- name = 'Haml'
- aliases = [
- 'haml',
- 'HAML']
- filenames = [
- '*.haml']
- mimetypes = [
- 'text/x-haml']
- flags = re.IGNORECASE
- _dot = '(?: \\|\\n(?=.* \\|)|.)'
- tokens = {
- 'root': [
- ('[ \\t]*\\n', Text),
- ('[ \\t]*', _indentation)],
- 'css': [
- ('\\.[a-z0-9_:-]+', Name.Class, 'tag'),
- ('\\#[a-z0-9_:-]+', Name.Function, 'tag')],
- 'eval-or-plain': [
- ('[&!]?==', Punctuation, 'plain'),
- ('([&!]?[=~])(' + _dot + '*\n)', bygroups(Punctuation, using(RubyLexer)), 'root'),
- ('', Text, 'plain')],
- 'content': [
- include('css'),
- ('%[a-z0-9_:-]+', Name.Tag, 'tag'),
- ('!!!' + _dot + '*\n', Name.Namespace, '#pop'),
- ('(/)(\\[' + _dot + '*?\\])(' + _dot + '*\n)', bygroups(Comment, Comment.Special, Comment), '#pop'),
- ('/' + _dot + '*\n', _starts_block(Comment, 'html-comment-block'), '#pop'),
- ('-#' + _dot + '*\n', _starts_block(Comment.Preproc, 'haml-comment-block'), '#pop'),
- ('(-)(' + _dot + '*\n)', bygroups(Punctuation, using(RubyLexer)), '#pop'),
- (':' + _dot + '*\n', _starts_block(Name.Decorator, 'filter-block'), '#pop'),
- include('eval-or-plain')],
- 'tag': [
- include('css'),
- ('\\{(,\\n|' + _dot + ')*?\\}', using(RubyLexer)),
- ('\\[' + _dot + '*?\\]', using(RubyLexer)),
- ('\\(', Text, 'html-attributes'),
- ('/[ \\t]*\\n', Punctuation, '#pop:2'),
- ('[<>]{1,2}(?=[ \\t=])', Punctuation),
- include('eval-or-plain')],
- 'plain': [
- ('([^#\\n]|#[^{\\n]|(\\\\\\\\)*\\\\#\\{)+', Text),
- ('(#\\{)(' + _dot + '*?)(\\})', bygroups(String.Interpol, using(RubyLexer), String.Interpol)),
- ('\\n', Text, 'root')],
- 'html-attributes': [
- ('\\s+', Text),
- ('[a-z0-9_:-]+[ \\t]*=', Name.Attribute, 'html-attribute-value'),
- ('[a-z0-9_:-]+', Name.Attribute),
- ('\\)', Text, '#pop')],
- 'html-attribute-value': [
- ('[ \\t]+', Text),
- ('[a-z0-9_]+', Name.Variable, '#pop'),
- ('@[a-z0-9_]+', Name.Variable.Instance, '#pop'),
- ('\\$[a-z0-9_]+', Name.Variable.Global, '#pop'),
- ("'(\\\\\\\\|\\\\'|[^'\\n])*'", String, '#pop'),
- ('"(\\\\\\\\|\\\\"|[^"\\n])*"', String, '#pop')],
- 'html-comment-block': [
- (_dot + '+', Comment),
- ('\\n', Text, 'root')],
- 'haml-comment-block': [
- (_dot + '+', Comment.Preproc),
- ('\\n', Text, 'root')],
- 'filter-block': [
- ('([^#\\n]|#[^{\\n]|(\\\\\\\\)*\\\\#\\{)+', Name.Decorator),
- ('(#\\{)(' + _dot + '*?)(\\})', bygroups(String.Interpol, using(RubyLexer), String.Interpol)),
- ('\\n', Text, 'root')] }
-
-
- class SassLexer(ExtendedRegexLexer):
- name = 'Sass'
- aliases = [
- 'sass',
- 'SASS']
- filenames = [
- '*.sass']
- mimetypes = [
- 'text/x-sass']
- flags = re.IGNORECASE
- tokens = {
- 'root': [
- ('[ \\t]*\\n', Text),
- ('[ \\t]*', _indentation)],
- 'content': [
- ('//[^\\n]*', _starts_block(Comment.Single, 'single-comment'), 'root'),
- ('/\\*[^\\n]*', _starts_block(Comment.Multiline, 'multi-comment'), 'root'),
- ('@import', Keyword, 'import'),
- ('@for', Keyword, 'for'),
- ('@(debug|if|while)', Keyword, 'script'),
- ('@[a-z0-9_-]+', Keyword, 'selector'),
- ('=[\\w-]+', Name.Function, 'script'),
- ('\\+[\\w-]+', Name.Decorator, 'script'),
- ('(![a-z_]\\w*)([ \\t]*(?:\\|\\|)?=)', bygroups(Name.Variable, Operator), 'script'),
- (':', Name.Attribute, 'old-style-attr'),
- ('(?=[^\\s:"\\[]+\\s*[=:]([ \\t]|$))', Name.Attribute, 'new-style-attr'),
- ('', Text, 'selector')],
- 'single-comment': [
- ('.+', Comment.Single),
- ('\\n', Text, 'root')],
- 'multi-comment': [
- ('.+', Comment.Multiline),
- ('\\n', Text, 'root')],
- 'import': [
- ('[ \\t]+', Text),
- ('[^\\s]+', String),
- ('\\n', Text, 'root')],
- 'for': [
- ('(from|to|through)', Operator.Word),
- include('script')],
- 'old-style-attr': [
- ('[^\\s:="\\[]+', Name.Attribute),
- ('#{', String.Interpol, 'interpolation'),
- ('[ \\t]*=', Operator, 'script'),
- ('', Text, 'value')],
- 'new-style-attr': [
- ('[^\\s:="\\[]+', Name.Attribute),
- ('#{', String.Interpol, 'interpolation'),
- ('[ \\t]*=', Operator, 'script'),
- (':', Name.Attribute, 'value')],
- 'value': [
- ('[ \\t]+', Text),
- ('url\\(', String.Other, 'string-url'),
- ('(azimuth|background-attachment|background-color|background-image|background-position|background-repeat|background|border-bottom-color|border-bottom-style|border-bottom-width|border-left-color|border-left-style|border-left-width|border-right|border-right-color|border-right-style|border-right-width|border-top-color|border-top-style|border-top-width|border-bottom|border-collapse|border-left|border-width|border-color|border-spacing|border-style|border-top|border|caption-side|clear|clip|color|content|counter-increment|counter-reset|cue-after|cue-before|cue|cursor|direction|display|elevation|empty-cells|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|height|letter-spacing|line-height|list-style-type|list-style-image|list-style-position|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|marker-offset|marks|max-height|max-width|min-height|min-width|opacity|orphans|outline|outline-color|outline-style|outline-width|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page|page-break-after|page-break-before|page-break-inside|pause-after|pause-before|pause|pitch|pitch-range|play-during|position|quotes|richness|right|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|table-layout|text-align|text-decoration|text-indent|text-shadow|text-transform|top|unicode-bidi|vertical-align|visibility|voice-family|volume|white-space|widows|width|word-spacing|z-index|bottom|left|above|absolute|always|armenian|aural|auto|avoid|baseline|behind|below|bidi-override|blink|block|bold|bolder|both|capitalize|center-left|center-right|center|circle|cjk-ideographic|close-quote|collapse|condensed|continuous|crop|crosshair|cross|cursive|dashed|decimal-leading-zero|decimal|default|digits|disc|dotted|double|e-resize|embed|extra-condensed|extra-expanded|expanded|fantasy|far-left|far-right|faster|fast|fixed|georgian|groove|hebrew|help|hidden|hide|higher|high|hiragana-iroha|hiragana|icon|inherit|inline-table|inline|inset|inside|invert|italic|justify|katakana-iroha|katakana|landscape|larger|large|left-side|leftwards|level|lighter|line-through|list-item|loud|lower-alpha|lower-greek|lower-roman|lowercase|ltr|lower|low|medium|message-box|middle|mix|monospace|n-resize|narrower|ne-resize|no-close-quote|no-open-quote|no-repeat|none|normal|nowrap|nw-resize|oblique|once|open-quote|outset|outside|overline|pointer|portrait|px|relative|repeat-x|repeat-y|repeat|rgb|ridge|right-side|rightwards|s-resize|sans-serif|scroll|se-resize|semi-condensed|semi-expanded|separate|serif|show|silent|slow|slower|small-caps|small-caption|smaller|soft|solid|spell-out|square|static|status-bar|super|sw-resize|table-caption|table-cell|table-column|table-column-group|table-footer-group|table-header-group|table-row|table-row-group|text|text-bottom|text-top|thick|thin|transparent|ultra-condensed|ultra-expanded|underline|upper-alpha|upper-latin|upper-roman|uppercase|url|visible|w-resize|wait|wider|x-fast|x-high|x-large|x-loud|x-low|x-small|x-soft|xx-large|xx-small|yes)\\b', Name.Constant),
- ('(indigo|gold|firebrick|indianred|yellow|darkolivegreen|darkseagreen|mediumvioletred|mediumorchid|chartreuse|mediumslateblue|black|springgreen|crimson|lightsalmon|brown|turquoise|olivedrab|cyan|silver|skyblue|gray|darkturquoise|goldenrod|darkgreen|darkviolet|darkgray|lightpink|teal|darkmagenta|lightgoldenrodyellow|lavender|yellowgreen|thistle|violet|navy|orchid|blue|ghostwhite|honeydew|cornflowerblue|darkblue|darkkhaki|mediumpurple|cornsilk|red|bisque|slategray|darkcyan|khaki|wheat|deepskyblue|darkred|steelblue|aliceblue|gainsboro|mediumturquoise|floralwhite|coral|purple|lightgrey|lightcyan|darksalmon|beige|azure|lightsteelblue|oldlace|greenyellow|royalblue|lightseagreen|mistyrose|sienna|lightcoral|orangered|navajowhite|lime|palegreen|burlywood|seashell|mediumspringgreen|fuchsia|papayawhip|blanchedalmond|peru|aquamarine|white|darkslategray|ivory|dodgerblue|lemonchiffon|chocolate|orange|forestgreen|slateblue|olive|mintcream|antiquewhite|darkorange|cadetblue|moccasin|limegreen|saddlebrown|darkslateblue|lightskyblue|deeppink|plum|aqua|darkgoldenrod|maroon|sandybrown|magenta|tan|rosybrown|pink|lightblue|palevioletred|mediumseagreen|dimgray|powderblue|seagreen|snow|mediumblue|midnightblue|paleturquoise|palegoldenrod|whitesmoke|darkorchid|salmon|lightslategray|lawngreen|lightgreen|tomato|hotpink|lightyellow|lavenderblush|linen|mediumaquamarine|green|blueviolet|peachpuff)\\b', Name.Entity),
- ('\\!important', Name.Exception),
- ('/\\*', Comment, 'inline-comment'),
- ('\\#[a-z0-9]{1,6}', Number.Hex),
- ('(-?\\d+)(\\%|[a-z]+)?', bygroups(Number.Integer, Keyword.Type)),
- ('(-?\\d*\\.\\d+)(\\%|[a-z]+)?', bygroups(Number.Float, Keyword.Type)),
- ('#{', String.Interpol, 'interpolation'),
- ('[~\\^\\*!&%<>\\|+=@:,./?-]+', Operator),
- ('[\\[\\]();]+', Punctuation),
- ('"', String.Double, 'string-double'),
- ("'", String.Single, 'string-single'),
- ('[a-z][\\w-]*', Name),
- ('\\n', Text, 'root')],
- 'script': [
- ('[ \\t]+', Text),
- ('![\\w_]+', Name.Variable),
- ('[+\\-*/%=(),!><]', Operator),
- ('"', String.Double, 'string-double'),
- ("'", String.Single, 'string-single'),
- ('\\#[a-z0-9]{1,6}', Number.Hex),
- ('(-?\\d+)(\\%|[a-z]+)?', bygroups(Number.Integer, Keyword.Type)),
- ('(-?\\d*\\.\\d+)(\\%|[a-z]+)?', bygroups(Number.Float, Keyword.Type)),
- ('(black|silver|gray|white|maroon|red|purple|fuchsia|green|lime|olive|yellow|navy|blue|teal|aqua)\\b', Name.Builtin),
- ('(true|false)', Name.Pseudo),
- ('(and|or|not)', Operator.Word),
- ('(\\\\.|[^\\s\\\\+*\\/%(),=!])+(?=[ \\t]*\\()', Name.Function),
- ('(\\\\.|[^\\s\\\\+*\\/%(),=!])+', Name),
- ('\\n', Text, 'root')],
- 'interpolation': [
- ('\\}', String.Interpol, '#pop'),
- include('script')],
- 'selector': [
- ('[ \\t]+', Text),
- ('\\:', Name.Decorator, 'pseudo-class'),
- ('\\.', Name.Class, 'class'),
- ('\\#', Name.Namespace, 'id'),
- ('[a-zA-Z0-9_-]+', Name.Tag),
- ('#\\{', String.Interpol, 'interpolation'),
- ('&', Keyword),
- ('[~\\^\\*!&\\[\\]\\(\\)<>\\|+=@:;,./?-]', Operator),
- ('"', String.Double, 'string-double'),
- ("'", String.Single, 'string-single'),
- ('\\n', Text, 'root')],
- 'string-double': [
- ('(\\\\.|#(?=[^\\n{])|[^\\n"#])+', String.Double),
- ('#\\{', String.Interpol, 'interpolation'),
- ('"', String.Double, '#pop')],
- 'string-single': [
- ("(\\\\.|#(?=[^\\n{])|[^\\n'#])+", String.Double),
- ('#\\{', String.Interpol, 'interpolation'),
- ("'", String.Double, '#pop')],
- 'string-url': [
- ('(\\\\#|#(?=[^\\n{])|[^\\n#)])+', String.Other),
- ('#\\{', String.Interpol, 'interpolation'),
- ('\\)', String.Other, '#pop')],
- 'inline-comment': [
- ('(\\\\#|#(?=[^\\n{])|\\*(?=[^\\n/])|[^\\n#*])+', Comment),
- ('#\\{', String.Interpol, 'interpolation'),
- ('\\*/', Comment, '#pop')],
- 'pseudo-class': [
- ('[\\w-]+', Name.Decorator),
- ('#\\{', String.Interpol, 'interpolation'),
- ('', Text, '#pop')],
- 'class': [
- ('[\\w-]+', Name.Class),
- ('#\\{', String.Interpol, 'interpolation'),
- ('', Text, '#pop')],
- 'id': [
- ('[\\w-]+', Name.Namespace),
- ('#\\{', String.Interpol, 'interpolation'),
- ('', Text, '#pop')] }
-
-
- class CoffeeScriptLexer(RegexLexer):
- name = 'CoffeeScript'
- aliases = [
- 'coffee-script',
- 'coffeescript']
- filenames = [
- '*.coffee']
- mimetypes = [
- 'text/coffeescript']
- flags = re.DOTALL
- tokens = {
- 'commentsandwhitespace': [
- ('\\s+', Text),
- ('#.*?\\n', Comment.Single)],
- 'slashstartsregex': [
- include('commentsandwhitespace'),
- ('/(\\\\.|[^[/\\\\\\n]|\\[(\\\\.|[^\\]\\\\\\n])*])+/([gim]+\\b|\\B)', String.Regex, '#pop'),
- ('(?=/)', Text, ('#pop', 'badregex')),
- ('', Text, '#pop')],
- 'badregex': [
- ('\n', Text, '#pop')],
- 'root': [
- ('^(?=\\s|/|<!--)', Text, 'slashstartsregex'),
- include('commentsandwhitespace'),
- ('\\+\\+|--|~|&&|\\band\\b|\\bor\\b|\\bis\\b|\\bisnt\\b|\\bnot\\b|\\?|:|\\|\\||\\\\(?=\\n)|(<<|>>>?|==?|!=?|[-<>+*`%&\\|\\^/])=?', Operator, 'slashstartsregex'),
- ('[{(\\[;,]', Punctuation, 'slashstartsregex'),
- ('[})\\].]', Punctuation),
- ('(for|in|of|while|break|return|continue|switch|when|then|if|else|throw|try|catch|finally|new|delete|typeof|instanceof|super|extends|this)\\b', Keyword, 'slashstartsregex'),
- ('(true|false|yes|no|on|off|null|NaN|Infinity|undefined)\\b', Keyword.Constant),
- ('(Array|Boolean|Date|Error|Function|Math|netscape|Number|Object|Packages|RegExp|String|sun|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|window)\\b', Name.Builtin),
- ('[$a-zA-Z_][a-zA-Z0-9_\\.:]*:\\s', Name.Variable, 'slashstartsregex'),
- ('[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
- ('[0-9][0-9]*\\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
- ('0x[0-9a-fA-F]+', Number.Hex),
- ('[0-9]+', Number.Integer),
- ('"(\\\\\\\\|\\\\"|[^"])*"', String.Double),
- ("'(\\\\\\\\|\\\\'|[^'])*'", String.Single)] }
-
-