[TxMt] C syntax fixes

Oscar Bonilla ob at bitmover.com
Thu Jan 19 23:18:57 UTC 2006


Please disregard my previous email... I think I've fixed it. Here's a  
patch:

This patch fixes the following:

- "#else" directives are now tagged with the proper scope
- "#define" for things that are not functions do not get tagged as  
functions
- Functions defined in multiple lines are tagged as functions.

Thanks,

-Oscar

Index: Bundles/C.tmbundle/Syntaxes/C.plist
===================================================================
--- Bundles/C.tmbundle/Syntaxes/C.plist	(revision 2567)
+++ Bundles/C.tmbundle/Syntaxes/C.plist	(working copy)
@@ -10,9 +10,9 @@
	<key>firstLineMatch</key>
	<string>-[*]-( Mode:)? C -[*]-</string>
	<key>foldingStartMarker</key>
-	<string>/\*\*(?!\*)|\{\s*($|//|/\*(?!.*?\*/.*\S))|^@(interface| 
protocol|implementation)\b</string>
+	<string>(/\*\*|\{\s*(/\*.*\*/\s*|//.*)?$)</string>
	<key>foldingStopMarker</key>
-	<string>(?<!\*)\*\*/|^\s*\}|^@end\b</string>
+	<string>(\*\*/|^\s*\})</string>
	<key>keyEquivalent</key>
	<string>~^C</string>
	<key>name</key>
@@ -141,7 +141,7 @@
		</dict>
		<dict>
			<key>begin</key>
-			<string>^\s*#\s*(define)\s+([a-zA-Z_][a-zA-Z0-9_]*)(?:\(((?:\s*[a- 
zA-Z_][a-zA-Z0-9_]*\s*,?)*)\)|\b)</string>
+			<string>^\s*#\s*(define)\s+([a-zA-Z_][a-zA-Z0-9_]*)(?:\(((?:\s*[a- 
zA-Z_][a-zA-Z0-9_]*\s*,?)*)\))</string>
			<key>captures</key>
			<dict>
				<key>1</key>
@@ -239,7 +239,7 @@
		</dict>
		<dict>
			<key>begin</key>
-			<string>^\s*#\s*(defined|elif|else|if|ifdef|ifndef|line|pragma| 
undef)\b</string>
+			<string>^\s*#\s*(define|defined|elif|else|if|ifdef|ifndef|line| 
pragma|undef)\b</string>
			<key>captures</key>
			<dict>
				<key>1</key>
@@ -294,9 +294,9 @@
				     )
				)
				([A-Za-z_][A-Za-z0-9_:]+)              # actual name
-				 \s*\( (?=[^)]*\)                      # match "(" and use look- 
ahead for ")"
+				 \s*\( ((?=[^)]*\)                      # match "(" and use look- 
ahead for ")"
				 (\s+const)?\s*                        # optional const modifier
-				 (\{|\n))                              # start bracket or end-of- 
line
+				 (\{|\n))|\n)                              # start bracket or  
end-of-line
			</string>
			<key>beginCaptures</key>
			<dict>
@@ -319,39 +319,6 @@
			</array>
		</dict>
		<dict>
-			<key>begin</key>
-			<string>(?x)
-				(?:  ^                                 # begin-of-line
-				  |  (?: (?<!else|new) (?<=\w)\s+      #  or word + space  
before name
-				       | (?<!&&)       (?<=[*&])\s*    #  or  
type modifier before name
-				     )
-				)
-				([A-Za-z_][A-Za-z0-9_:]+)              # actual name
-				 \s*\( (?=[^)]*\)                      # match "(" and use look- 
ahead for ")"
-				 (\s+const)?\s*                        # optional const modifier
-				 (;))                                  # start bracket or end-of- 
line
-			</string>
-			<key>beginCaptures</key>
-			<dict>
-				<key>1</key>
-				<dict>
-					<key>name</key>
-					<string>entity.name.function.c</string>
-				</dict>
-			</dict>
-			<key>end</key>
-			<string>\)</string>
-			<key>name</key>
-			<string>declaration.function.prototype.c</string>
-			<key>patterns</key>
-			<array>
-				<dict>
-					<key>include</key>
-					<string>$base</string>
-				</dict>
-			</array>
-		</dict>
-		<dict>
			<key>include</key>
			<string>source.open-gl</string>
		</dict>
@@ -554,7 +521,7 @@
		<key>preprocessor-rule-other</key>
		<dict>
			<key>begin</key>
-			<string>^\s*(#\s*(if(n?def)?)\b.*(?:(?=(?://|/\*))|$))</string>
+			<string>^\s*(#\s*(if(n?def)?)\b)</string>
			<key>captures</key>
			<dict>
				<key>1</key>
@@ -584,7 +551,7 @@
			<array>
				<dict>
					<key>match</key>
-					<string>\\(\\|[abefnprtv'"?]|[0-3]\d{,2}|[4-7]\d?|x[a-zA-Z0-9]+) 
</string>
+					<string>\\(\\|[abefnrtv'"?]|[0-3]\d{,2}|[4-7]\d?|x[a-zA-Z0-9]+) 
</string>
					<key>name</key>
					<string>constant.character.escape.c</string>
				</dict>

--
pgp fingerprint: BC64 2E7A CAEF 39E1 9544  80CA F7D5 784D FB46 16C1




More information about the textmate mailing list