/** * SyntaxHighlighter - Swift Brush * http://codepirate.seaandco.com/ * * @version * 1.0.0 (February 22 2009) * * @author * Geoffrey Byers * * @copyright * Copyright (C) 2009 Geoffrey Byers. * * Licensed under a GNU Lesser General Public License. * http://creativecommons.org/licenses/LGPL/2.1/ * * Updated From: * Code Syntax Highlighter for Objective-C. * Version 0.0.2 * Copyright (C) 2006 Shin, YoungJin. * http://scottdensmore.typepad.com/blog/2008/12/objective-c-cocoa-syntax-highlighter.html */ SyntaxHighlighter.brushes.Swift = function() { var datatypes = 'T String Character Int Int8 Int16 Int32 Int64 UInt UInt8 UInt16 UInt32 UInt64 Double Float '; datatypes += 'String? Character? Int? Int8? Int16? Int32? Int64? UInt? UInt8? UInt16? UInt32? UInt64? Double? Float? '; datatypes += 'AnyObject'; var keywords = 'true nil false '; keywords += 'var let typealias '; keywords += 'if else for in while do switch case default continue break fallthrough return '; keywords += 'assert func -> return inout enum class struct static self mutating '; keywords += 'init convenience required deinit unowned lazy subscript overridde super '; keywords += 'is as extension protocol inout @objc '; var functions = 'get set willSet didSet'; this.regexList = [ { regex: /\b(_)\b/gi, css: 'keyword' }, // keyword { regex: /\b([\d_]+(\.[\d_eE]+)?|0x[a-f0-9p_\-]+(\.[a-f0-9p\-_]+)?|0b[0-1]+|0o[0-7_]+)\b/gi, css: 'value' }, // numbers { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings { regex: new RegExp(this.getKeywords(datatypes), 'gm'), css: 'color1' }, // datatypes { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keyword { regex: new RegExp('\\bNS\\w+\\b', 'g'), css: 'keyword' }, // keyword { regex: new RegExp('@\\w+\\b', 'g'), css: 'keyword' }, // keyword { regex: /(?!\@interface\b)\@[\$\w]+\b/g, css: 'color1' }, // annotation @anno ]; } SyntaxHighlighter.brushes.Swift.prototype = new SyntaxHighlighter.Highlighter(); SyntaxHighlighter.brushes.Swift.aliases = ['swift'];