Made the pre-processor capable of recognizing and ignoring Xcode's '#pragma mark' mark-ups

Conflicts:

	Objective-J/Preprocessor.js
This commit is contained in:
Ross Boucher
2010-04-09 14:26:29 -07:00
parent 489f2bcfa0
commit 47ecd40c4f
+39
View File
@@ -34,6 +34,8 @@ var TOKEN_ACCESSORS = "accessors",
TOKEN_SUPER = "super",
TOKEN_VAR = "var",
TOKEN_IN = "in",
TOKEN_PRAGMA = "pragma",
TOKEN_MARK = "mark",
TOKEN_EQUAL = '=',
TOKEN_PLUS = '+',
@@ -50,6 +52,7 @@ var TOKEN_ACCESSORS = "accessors",
TOKEN_OPEN_BRACKET = '[',
TOKEN_DOUBLE_QUOTE = '"',
TOKEN_PREPROCESSOR = '@',
TOKEN_HASH = '#',
TOKEN_CLOSE_BRACKET = ']',
TOKEN_QUESTION_MARK = '?',
TOKEN_OPEN_PARENTHESIS = '(',
@@ -363,6 +366,33 @@ Preprocessor.prototype.directive = function(tokens, aStringBuffer, allowedDirect
return buffer;
}
Preprocessor.prototype.hash = function(tokens, aStringBuffer)
{
// Grab the next token, C preprocessor directives follow '#' immediately.
var buffer = aStringBuffer ? aStringBuffer : new StringBuffer(),
token = tokens.next();
// #pragma (C Preprocessor directive)
if (token === TOKEN_PRAGMA)
{
token = tokens.skip_whitespace();
// '#pragma mark' directive is used in Xcode editor for creating labels,
// which is irrelevant to Cappuccino - just swallow this line
if (token === TOKEN_MARK)
{
while ((token = tokens.next()).indexOf("\n") < 0);
}
}
// if not a #pragma directive, it should not be processed here
else
{
tokens.previous();
CONCAT(aStringBuffer, TOKEN_HASH);
return;
}
}
Preprocessor.prototype.implementation = function(tokens, /*StringBuffer*/ aStringBuffer)
{
var buffer = aStringBuffer,
@@ -542,6 +572,11 @@ Preprocessor.prototype.implementation = function(tokens, /*StringBuffer*/ aStrin
CONCAT(instance_methods, this.method(tokens, ivar_names));
}
// If we reach a # symbol, we may be at a C preprocessor directive.
else if (token == TOKEN_HASH)
{
this.hash(tokens, buffer);
}
// Check if we've reached @end...
else if (token == TOKEN_PREPROCESSOR)
{
@@ -896,6 +931,10 @@ Preprocessor.prototype.preprocess = function(tokens, /*StringBuffer*/ aStringBuf
// If we reach an @ symbol, we are at a preprocessor directive.
else if (token == TOKEN_PREPROCESSOR)
this.directive(tokens, buffer);
// If we reach a # symbol, we may be at a C preprocessor directive.
else if (token == TOKEN_HASH)
this.hash(tokens, buffer);
// If we reach a bracket, we will either be preprocessing a message send, a literal
// array, or an array index.