From 5405d049d611adc0a76ec2f1a1d8960b2fe10def Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Thu, 26 Mar 2009 23:09:23 +0000 Subject: Rename tokens.h to SPEditorTokens.h and tokens.l to SPEditorTokens.l. --- Source/CMTextView.m | 4 +- Source/SPEditorTokens.h | 17 +++ Source/SPEditorTokens.l | 300 ++++++++++++++++++++++++++++++++++++++++++++++++ Source/TableSource.m | 2 +- Source/tokens.h | 17 --- Source/tokens.l | 300 ------------------------------------------------ 6 files changed, 320 insertions(+), 320 deletions(-) create mode 100644 Source/SPEditorTokens.h create mode 100644 Source/SPEditorTokens.l delete mode 100644 Source/tokens.h delete mode 100644 Source/tokens.l diff --git a/Source/CMTextView.m b/Source/CMTextView.m index cd00cafb..d62783da 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -27,7 +27,7 @@ /* all the extern variables and prototypes required for flex (used for syntax highlighting) */ -#import "tokens.h" +#import "SPEditorTokens.h" extern int yylex(); extern int yyuoffset, yyuleng; typedef struct yy_buffer_state *YY_BUFFER_STATE; @@ -86,7 +86,7 @@ YY_BUFFER_STATE yy_scan_string (const char *); /* List of keywords for autocompletion. If you add a keyword here, -it should also be added to the flex file tokens.l +it should also be added to the flex file SPEditorTokens.l */ -(NSArray *)keywords { return [NSArray arrayWithObjects: diff --git a/Source/SPEditorTokens.h b/Source/SPEditorTokens.h new file mode 100644 index 00000000..1d854e10 --- /dev/null +++ b/Source/SPEditorTokens.h @@ -0,0 +1,17 @@ +/* + * SPEditorTokens.h + * sequel-pro + * + * Created by Jakob on 3/15/09. + * + * This file defines all the tokens used for parsing the source code + */ + +#define SPT_DOUBLE_QUOTED_TEXT 1 +#define SPT_SINGLE_QUOTED_TEXT 2 +#define SPT_BACKTICK_QUOTED_TEXT 3 +#define SPT_RESERVED_WORD 4 +#define SPT_COMMENT 5 +#define SPT_WHITESPACE 6 +#define SPT_WORD 7 +#define SPT_OTHER 8 \ No newline at end of file diff --git a/Source/SPEditorTokens.l b/Source/SPEditorTokens.l new file mode 100644 index 00000000..08e84d7d --- /dev/null +++ b/Source/SPEditorTokens.l @@ -0,0 +1,300 @@ +%{ + +/* + * SPEditorTokens.l - created by Jakob on 3/15/09 for Sequel Pro + * + * This is the lex file used for syntax coloring. + * To add new keywords, just add a line where the other + * keywords are and replace spaces with {s} + * + * If you're new to lex and interested what the code below does, I found + * "The Lex And Yacc Page" at http://dinosaur.compilertools.net/ to be + * very helpful. Keep in mind that Xcode actually uses flex, the GNU + * version of lex. There's a very thorough Texinfo manual for flex + * available. (type 'info flex' in the Terminal) + */ + +#import "SPEditorTokens.h" +int utf8strlen(const char *s); +int yyuoffset, yyuleng; + +#define YY_NO_UNPUT + +//keep track of the current utf-8 character (not byte) offset and token length +#define YY_USER_ACTION { yyuoffset += yyuleng; yyuleng = utf8strlen(yytext); } +%} +%option noyywrap +%option case-insensitive +s [ \t\n]+ +word [a-z_0-9] +nonword [^a-z_0-9#\n\t] +%x comment +%% +\"([^"\\]|\\(.|\n))*\"? { return SPT_DOUBLE_QUOTED_TEXT; } /* double quoted strings */ +'([^'\\]|\\(.|\n))*'? { return SPT_SINGLE_QUOTED_TEXT; } /* single quoted strings */ +`[^`]*`? { return SPT_BACKTICK_QUOTED_TEXT; } /* identifier quoting */ + +"/*" { BEGIN(comment); return SPT_COMMENT; } /* beginning of a c style comment */ +[^*]* { return SPT_COMMENT; } /* anything except * in a c cmnt */ +"*"+ { return SPT_COMMENT; } /* a range of * */ +"*"+"/" { BEGIN(INITIAL); return SPT_COMMENT; } /* a range of * with trailing / + Thanks to John Dickinson for publishing + this method of parsing C comments on + http://www.stillhq.com/pdfdb/000561/data.pdf + */ + +#[^\n]*\n? | /* # Comments */ +--[ \t][^\n]*\n? { return SPT_COMMENT; } /* -- Comments */ + +{s} { return SPT_WHITESPACE; } /* ignore spaces */ +ADD | +ACCESSIBLE | +ADD | +ALL | +ALTER | +ANALYZE | +AND | +AS | +ASC | +ASENSITIVE | +BEFORE | +BETWEEN | +BIGINT | +BINARY | +BLOB | +BOTH | +BY | +CALL | +CASCADE | +CASE | +CHANGE | +CHAR | +CHARACTER | +CHECK | +COLLATE | +COLUMN | +CONDITION | +CONSTRAINT | +CONTINUE | +CONVERT | +CREATE | +CROSS | +CURRENT_DATE | +CURRENT_TIME | +CURRENT_TIMESTAMP | +CURRENT_USER | +CURSOR | +DATABASE | +DATABASES | +DAY_HOUR | +DAY_MICROSECOND | +DAY_MINUTE | +DAY_SECOND | +DEC | +DECIMAL | +DECLARE | +DEFAULT | +DELAYED | +DELETE | +DESC | +DESCRIBE | +DETERMINISTIC | +DISTINCT | +DISTINCTROW | +DIV | +DOUBLE | +DROP | +DUAL | +EACH | +ELSE | +ELSEIF | +ENCLOSED | +ESCAPED | +EXISTS | +EXIT | +EXPLAIN | +FALSE | +FETCH | +FLOAT | +FLOAT4 | +FLOAT8 | +FOR | +FORCE | +FOREIGN | +FROM | +FULLTEXT | +GRANT | +GROUP | +HAVING | +HIGH_PRIORITY | +HOUR_MICROSECOND | +HOUR_MINUTE | +HOUR_SECOND | +IF | +IGNORE | +IN | +INDEX | +INFILE | +INNER | +INOUT | +INSENSITIVE | +INSERT | +INT | +INT1 | +INT2 | +INT3 | +INT4 | +INT8 | +INTEGER | +INTERVAL | +INTO | +IS | +ITERATE | +JOIN | +KEY | +KEYS | +KILL | +LEADING | +LEAVE | +LEFT | +LIKE | +LIMIT | +LINEAR | +LINES | +LOAD | +LOCALTIME | +LOCALTIMESTAMP | +LOCK | +LONG | +LONGBLOB | +LONGTEXT | +LOOP | +LOW_PRIORITY | +MASTER_SSL_VERIFY_SERVER_CERT | +MATCH | +MEDIUMBLOB | +MEDIUMINT | +MEDIUMTEXT | +MIDDLEINT | +MINUTE_MICROSECOND | +MINUTE_SECOND | +MOD | +MODIFIES | +NATURAL | +NOT | +NO_WRITE_TO_BINLOG | +NULL | +NUMERIC | +ON | +OPTIMIZE | +OPTION | +OPTIONALLY | +OR | +ORDER | +OUT | +OUTER | +OUTFILE | +PRECISION | +PRIMARY | +PROCEDURE | +PURGE | +RANGE | +READ | +READS | +READ_WRITE | +REAL | +REFERENCES | +REGEXP | +RELEASE | +RENAME | +REPEAT | +REPLACE | +REQUIRE | +RESTRICT | +RETURN | +REVOKE | +RIGHT | +RLIKE | +SCHEMA | +SCHEMAS | +SECOND_MICROSECOND | +SELECT | +SENSITIVE | +SEPARATOR | +SET | +SHOW | +SMALLINT | +SPATIAL | +SPECIFIC | +SQL | +SQLEXCEPTION | +SQLSTATE | +SQLWARNING | +SQL_BIG_RESULT | +SQL_CALC_FOUND_ROWS | +SQL_SMALL_RESULT | +SSL | +STARTING | +STRAIGHT_JOIN | +TABLE | +TERMINATED | +THEN | +TINYBLOB | +TINYINT | +TINYTEXT | +TO | +TRAILING | +TRIGGER | +TRUE | +UNDO | +UNION | +UNIQUE | +UNLOCK | +UNSIGNED | +UPDATE | +USAGE | +USE | +USING | +UTC_DATE | +UTC_TIME | +UTC_TIMESTAMP | +VALUES | +VARBINARY | +VARCHAR | +VARCHARACTER | +VARYING | +WHEN | +WHERE | +WHILE | +WITH | +WRITE | +XOR | +YEAR_MONTH | +ZEROFILL { return SPT_RESERVED_WORD; } /* all the mysql reserved words */ +{word}+ { return SPT_WORD; } /* return any word */ +{nonword} { return SPT_OTHER; } /* return anything else */ + +<> { + BEGIN(INITIAL); /* make sure we return to initial state when finished! */ + yy_delete_buffer(YY_CURRENT_BUFFER); + return 0; + } +%% + +int utf8strlen(const char *s) +/* + This simple function calculates the string length of an UTF-8 string + It's fast enough and easy to comprehend + + Adapted from Kragen Javier Sitaker's my_strlen_utf8_c function as + found on http://canonical.org/~kragen/strlen-utf8.html + */ +{ + int j=0; + while (*s) + { + if ((*s & 0xC0) != 0x80) j++; + s++; + } + return (j); +} \ No newline at end of file diff --git a/Source/TableSource.m b/Source/TableSource.m index 692fa98e..117ce99b 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -1118,7 +1118,7 @@ traps enter and esc and make/cancel editing without entering next row - (void)tableView:(NSTableView *)tableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { //make sure that the message is from the right table view - if (tableView!=tableSourceView) return NO; + if (tableView!=tableSourceView) return; [aCell setEnabled:([tablesListInstance tableType] == SP_TABLETYPE_TABLE)]; } diff --git a/Source/tokens.h b/Source/tokens.h deleted file mode 100644 index ff4b70b0..00000000 --- a/Source/tokens.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * tokens.h - * sequel-pro - * - * Created by Jakob on 3/15/09. - * - * This file defines all the tokens used for parsing the source code - */ - -#define SPT_DOUBLE_QUOTED_TEXT 1 -#define SPT_SINGLE_QUOTED_TEXT 2 -#define SPT_BACKTICK_QUOTED_TEXT 3 -#define SPT_RESERVED_WORD 4 -#define SPT_COMMENT 5 -#define SPT_WHITESPACE 6 -#define SPT_WORD 7 -#define SPT_OTHER 8 \ No newline at end of file diff --git a/Source/tokens.l b/Source/tokens.l deleted file mode 100644 index 7aa80ed4..00000000 --- a/Source/tokens.l +++ /dev/null @@ -1,300 +0,0 @@ -%{ - -/* - * tokens.l - created by Jakob on 3/15/09 for Sequel Pro - * - * This is the lex file used for syntax coloring. - * To add new keywords, just add a line where the other - * keywords are and replace spaces with {s} - * - * If you're new to lex and interested what the code below does, I found - * "The Lex And Yacc Page" at http://dinosaur.compilertools.net/ to be - * very helpful. Keep in mind that Xcode actually uses flex, the GNU - * version of lex. There's a very thorough Texinfo manual for flex - * available. (type 'info flex' in the Terminal) - */ - -#import "tokens.h" -int utf8strlen(const char *s); -int yyuoffset, yyuleng; - -#define YY_NO_UNPUT - -//keep track of the current utf-8 character (not byte) offset and token length -#define YY_USER_ACTION { yyuoffset += yyuleng; yyuleng = utf8strlen(yytext); } -%} -%option noyywrap -%option case-insensitive -s [ \t\n]+ -word [a-z_0-9] -nonword [^a-z_0-9#\n\t] -%x comment -%% -\"([^"\\]|\\(.|\n))*\"? { return SPT_DOUBLE_QUOTED_TEXT; } /* double quoted strings */ -'([^'\\]|\\(.|\n))*'? { return SPT_SINGLE_QUOTED_TEXT; } /* single quoted strings */ -`[^`]*`? { return SPT_BACKTICK_QUOTED_TEXT; } /* identifier quoting */ - -"/*" { BEGIN(comment); return SPT_COMMENT; } /* beginning of a c style comment */ -[^*]* { return SPT_COMMENT; } /* anything except * in a c cmnt */ -"*"+ { return SPT_COMMENT; } /* a range of * */ -"*"+"/" { BEGIN(INITIAL); return SPT_COMMENT; } /* a range of * with trailing / - Thanks to John Dickinson for publishing - this method of parsing C comments on - http://www.stillhq.com/pdfdb/000561/data.pdf - */ - -#[^\n]*\n? | /* # Comments */ ---[ \t][^\n]*\n? { return SPT_COMMENT; } /* -- Comments */ - -{s} { return SPT_WHITESPACE; } /* ignore spaces */ -ADD | -ACCESSIBLE | -ADD | -ALL | -ALTER | -ANALYZE | -AND | -AS | -ASC | -ASENSITIVE | -BEFORE | -BETWEEN | -BIGINT | -BINARY | -BLOB | -BOTH | -BY | -CALL | -CASCADE | -CASE | -CHANGE | -CHAR | -CHARACTER | -CHECK | -COLLATE | -COLUMN | -CONDITION | -CONSTRAINT | -CONTINUE | -CONVERT | -CREATE | -CROSS | -CURRENT_DATE | -CURRENT_TIME | -CURRENT_TIMESTAMP | -CURRENT_USER | -CURSOR | -DATABASE | -DATABASES | -DAY_HOUR | -DAY_MICROSECOND | -DAY_MINUTE | -DAY_SECOND | -DEC | -DECIMAL | -DECLARE | -DEFAULT | -DELAYED | -DELETE | -DESC | -DESCRIBE | -DETERMINISTIC | -DISTINCT | -DISTINCTROW | -DIV | -DOUBLE | -DROP | -DUAL | -EACH | -ELSE | -ELSEIF | -ENCLOSED | -ESCAPED | -EXISTS | -EXIT | -EXPLAIN | -FALSE | -FETCH | -FLOAT | -FLOAT4 | -FLOAT8 | -FOR | -FORCE | -FOREIGN | -FROM | -FULLTEXT | -GRANT | -GROUP | -HAVING | -HIGH_PRIORITY | -HOUR_MICROSECOND | -HOUR_MINUTE | -HOUR_SECOND | -IF | -IGNORE | -IN | -INDEX | -INFILE | -INNER | -INOUT | -INSENSITIVE | -INSERT | -INT | -INT1 | -INT2 | -INT3 | -INT4 | -INT8 | -INTEGER | -INTERVAL | -INTO | -IS | -ITERATE | -JOIN | -KEY | -KEYS | -KILL | -LEADING | -LEAVE | -LEFT | -LIKE | -LIMIT | -LINEAR | -LINES | -LOAD | -LOCALTIME | -LOCALTIMESTAMP | -LOCK | -LONG | -LONGBLOB | -LONGTEXT | -LOOP | -LOW_PRIORITY | -MASTER_SSL_VERIFY_SERVER_CERT | -MATCH | -MEDIUMBLOB | -MEDIUMINT | -MEDIUMTEXT | -MIDDLEINT | -MINUTE_MICROSECOND | -MINUTE_SECOND | -MOD | -MODIFIES | -NATURAL | -NOT | -NO_WRITE_TO_BINLOG | -NULL | -NUMERIC | -ON | -OPTIMIZE | -OPTION | -OPTIONALLY | -OR | -ORDER | -OUT | -OUTER | -OUTFILE | -PRECISION | -PRIMARY | -PROCEDURE | -PURGE | -RANGE | -READ | -READS | -READ_WRITE | -REAL | -REFERENCES | -REGEXP | -RELEASE | -RENAME | -REPEAT | -REPLACE | -REQUIRE | -RESTRICT | -RETURN | -REVOKE | -RIGHT | -RLIKE | -SCHEMA | -SCHEMAS | -SECOND_MICROSECOND | -SELECT | -SENSITIVE | -SEPARATOR | -SET | -SHOW | -SMALLINT | -SPATIAL | -SPECIFIC | -SQL | -SQLEXCEPTION | -SQLSTATE | -SQLWARNING | -SQL_BIG_RESULT | -SQL_CALC_FOUND_ROWS | -SQL_SMALL_RESULT | -SSL | -STARTING | -STRAIGHT_JOIN | -TABLE | -TERMINATED | -THEN | -TINYBLOB | -TINYINT | -TINYTEXT | -TO | -TRAILING | -TRIGGER | -TRUE | -UNDO | -UNION | -UNIQUE | -UNLOCK | -UNSIGNED | -UPDATE | -USAGE | -USE | -USING | -UTC_DATE | -UTC_TIME | -UTC_TIMESTAMP | -VALUES | -VARBINARY | -VARCHAR | -VARCHARACTER | -VARYING | -WHEN | -WHERE | -WHILE | -WITH | -WRITE | -XOR | -YEAR_MONTH | -ZEROFILL { return SPT_RESERVED_WORD; } /* all the mysql reserved words */ -{word}+ { return SPT_WORD; } /* return any word */ -{nonword} { return SPT_OTHER; } /* return anything else */ - -<> { - BEGIN(INITIAL); /* make sure we return to initial state when finished! */ - yy_delete_buffer(YY_CURRENT_BUFFER); - return 0; - } -%% - -int utf8strlen(const char *s) -/* - This simple function calculates the string length of an UTF-8 string - It's fast enough and easy to comprehend - - Adapted from Kragen Javier Sitaker's my_strlen_utf8_c function as - found on http://canonical.org/~kragen/strlen-utf8.html - */ -{ - int j=0; - while (*s) - { - if ((*s & 0xC0) != 0x80) j++; - s++; - } - return (j); -} \ No newline at end of file -- cgit v1.2.3