github.com/spotify/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/misc/xcode/4/go.xclangspec (about)

     1  /*
     2  	Copyright 2012 The Go Authors. All rights reserved.
     3  	Use of this source code is governed by a BSD-style
     4  	license that can be found in the LICENSE file.
     5  
     6  	go.xclangspec
     7  	Go language specification for Xcode 4.x.
     8  
     9  	This is a preliminary version that supports basic syntax coloring
    10  	(such as keywords, literals, and comments) and an attempt to provide
    11  	some structure information (incomplete).
    12  
    13  	There is not much documentation available regarding the format
    14  	of .xclangspec files. As a starting point, see for instance the
    15  	outdated documentation at:
    16  
    17  		http://maxao.free.fr/xcode-plugin-interface/specifications.html
    18  
    19  */
    20  
    21  (
    22  
    23  // ----------------------------------------------------------------------------
    24  // Keywords
    25  
    26  // TODO How do we get general Unicode identifiers?
    27  
    28  	{
    29  		Identifier = "xcode.lang.go.identifier";
    30  		Syntax = {
    31  			StartChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
    32  			Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
    33  			Words = (
    34  				"break",
    35  				"case",
    36  				"chan",
    37  				"const",
    38  				"continue",
    39  
    40  				"default",
    41  				"defer",
    42  				"else",
    43  				"fallthrough",
    44  				"for",
    45  
    46  				"func",
    47  				"go",
    48  				"goto",
    49  				"if",
    50  				"import",
    51  
    52  				"interface",
    53  				"map",
    54  				"package",
    55  				"range",
    56  				"return",
    57  
    58  				"select",
    59  				"struct",
    60  				"switch",
    61  				"type",
    62  				"var",
    63  			);
    64  			Type = "xcode.syntax.keyword";
    65  			AltType = "xcode.syntax.identifier";  // non-keywords are identifiers
    66  		};
    67  	},
    68  
    69  // TODO decide what should go here, if anything
    70  	{
    71  		Identifier = "xcode.lang.go.interestingOperators";
    72  		Syntax = {
    73  			Words = (
    74  				"...",
    75  				".",
    76  				"*",
    77  				",",
    78  				":",
    79   			);
    80  			Type = "xcode.syntax.plain";
    81  		};
    82  	},
    83  
    84  	{
    85  		Identifier = "xcode.lang.go.rawstring";
    86  		Syntax = {
    87  			Start = "`";
    88  			End = "`";
    89  			Type = "xcode.syntax.string";
    90  		};
    91  	},
    92  
    93  // ----------------------------------------------------------------------------
    94  // Syntax Coloring
    95  
    96  	{
    97  		Identifier = "xcode.lang.go";
    98  		Description = "Go Coloring";
    99  		BasedOn = "xcode.lang.simpleColoring";
   100  		IncludeInMenu = YES;
   101  		Name = "Go";
   102  		Syntax = {
   103  			Tokenizer = "xcode.lang.go.lexer.toplevel";
   104  			IncludeRules = (
   105  				"xcode.lang.go.block",
   106  				"xcode.lang.go.bracketexpr",
   107  				"xcode.lang.go.parenexpr",
   108  			);
   109  			Type = "xcode.syntax.plain";
   110  		};
   111  	},
   112  
   113  	// The following rule returns tokens to the other rules
   114  	{
   115  		Identifier = "xcode.lang.go.lexer";
   116  		Syntax = {
   117  			IncludeRules = (
   118  				"xcode.lang.go.comment",
   119  				"xcode.lang.go.comment.singleline",
   120  				"xcode.lang.string",
   121  				"xcode.lang.character",
   122  				"xcode.lang.go.rawstring",
   123  				"xcode.lang.go.identifier",
   124  				"xcode.lang.number",
   125  				"xcode.lang.go.interestingOperators",
   126  			);
   127  		};
   128  	},
   129  
   130  	{
   131  		Identifier = "xcode.lang.go.lexer.toplevel";
   132  		Syntax = {
   133  			IncludeRules = (
   134  				"xcode.lang.go.comment",
   135  				"xcode.lang.go.comment.singleline",
   136  				"xcode.lang.string",
   137  				"xcode.lang.character",
   138  				"xcode.lang.go.rawstring",
   139  				"xcode.lang.go.type.declaration",
   140  				"xcode.lang.go.method.declaration",
   141  				"xcode.lang.go.function.declaration",
   142  				"xcode.lang.go.identifier",
   143  				"xcode.lang.number",
   144  			);
   145  		};
   146  	},
   147  
   148  	{
   149  		Identifier = "xcode.lang.go.method.declaration";
   150  		Syntax = {
   151  			Tokenizer = "xcode.lang.go.lexer";
   152  			Rules = (
   153  				"func",
   154  				"xcode.lang.go.parenexpr",
   155  				"xcode.lang.go.identifier",
   156  				"xcode.lang.go.parenexpr",
   157  			);
   158  			Type = "xcode.syntax.declaration.method";
   159  		};
   160  	},
   161  
   162  	{
   163  		Identifier = "xcode.lang.go.type.declaration";
   164  		Syntax = {
   165  			Tokenizer = "xcode.lang.go.lexer";
   166  			Rules = (
   167  				"type",
   168  				"xcode.lang.go.identifier",
   169  			);
   170  			Type = "xcode.syntax.typedef";
   171  		};
   172  	},
   173  
   174  	{
   175  		Identifier = "xcode.lang.go.function.declaration";
   176  		Syntax = {
   177  			Tokenizer = "xcode.lang.go.lexer";
   178  			Rules = (
   179  				"func",
   180  				"xcode.lang.go.identifier",
   181  				"xcode.lang.go.parenexpr",
   182  			);
   183  			Type = "xcode.syntax.declaration.function";
   184  		};
   185  	},
   186  
   187  // ----------------------------------------------------------------------------
   188  // Blocks
   189  
   190  	{
   191  		Identifier = "xcode.lang.go.block";
   192  		Syntax = {
   193  			Tokenizer = "xcode.lang.go.lexer";
   194  			Start = "{";
   195  			End = "}";
   196  			Foldable = YES;
   197  			Recursive = YES;
   198  			IncludeRules = (
   199  				"xcode.lang.go.bracketexpr",
   200  				"xcode.lang.go.parenexpr",
   201  			);
   202  		};
   203  	},
   204  
   205  	{
   206  		Identifier = "xcode.lang.go.parenexpr";
   207  		Syntax = {
   208  			Tokenizer = "xcode.lang.go.lexer";
   209  			Start = "(";
   210  			End = ")";
   211  			Recursive = YES;
   212  			IncludeRules = (
   213  				"xcode.lang.go.bracketexpr",
   214  				"xcode.lang.go.block",
   215  			);
   216  		};
   217  	},
   218  
   219  	{
   220  		Identifier = "xcode.lang.go.bracketexpr";
   221  		Syntax = {
   222  			Tokenizer = "xcode.lang.go.lexer";
   223  			Start = "[";
   224  			End = "]";
   225  			Recursive = YES;
   226  			IncludeRules = (
   227  				"xcode.lang.go.parenexpr",
   228  			);
   229  		};
   230  	},
   231  
   232  	{
   233  		Identifier = "xcode.lang.go.comment";
   234  		Syntax = {
   235  			Start = "/*";
   236  			End = "*/";
   237  			Foldable = YES;
   238  			IncludeRules = (
   239  				"xcode.lang.url",
   240  				"xcode.lang.url.mail",
   241  				"xcode.lang.comment.mark",
   242  			);
   243  			Type = "xcode.syntax.comment";
   244  		};
   245  	},
   246  
   247  	{
   248  		Identifier = "xcode.lang.go.comment.singleline";
   249  		Syntax = {
   250  			Start = "//";
   251  			End = "\n";
   252  			IncludeRules = (
   253  				"xcode.lang.url",
   254  				"xcode.lang.url.mail",
   255  				"xcode.lang.comment.mark",
   256  			);
   257  			Type = "xcode.syntax.comment";
   258  		};
   259  	},
   260  
   261  	// This rule recognizes special comments markers and adds them
   262  	// to the list of file markers at the top of the editor window.
   263  	// This overrides the markers specified in
   264  	// /Developer/Library/PrivateFrameworks/XcodeEdit.framework/Versions/A/Resources/BaseSupport.xclangspec
   265  	// and appears to apply them to all languages. Thus, for now
   266  	// "inherit" the existing markers here for backward-compatibility.
   267  	{
   268  		Identifier = "xcode.lang.comment.mark";
   269  		Syntax = {
   270  			StartChars = "BMTF!?";
   271  			Match = (
   272  				// Go-specific markers
   273  				"^\(BUG.*$\)$",			// include "BUG" in the markers list
   274  				"^\(TODO.*$\)$",		// include "TODO" in the markers list
   275  				// inherited markers
   276  				"^MARK:[ \t]+\(.*\)$",
   277  				"^\(TODO:[ \t]+.*\)$",		// include "TODO: " in the markers list
   278  				"^\(FIXME:[ \t]+.*\)$",		// include "FIXME: " in the markers list
   279  				"^\(!!!:.*\)$",			// include "!!!:" in the markers list
   280  				"^\(\\?\\?\\?:.*\)$"		// include "???:" in the markers list
   281  			);
   282  			// This is the order of captures. All of the match strings above need the same order.
   283  			CaptureTypes = (
   284  				"xcode.syntax.mark"
   285  			);
   286  			Type = "xcode.syntax.comment";
   287  		};
   288  	},
   289  
   290  )