diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-05-14 22:39:17 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-05-14 22:39:17 +0000 |
commit | 467944c01e5978b0f543353e1a7dd3150fd69e6f (patch) | |
tree | 398d3fc383152f342448c1e0c7271d7ddf32b574 | |
parent | 455f1eca057580a8557ed11c0e6a8e835d0d74a3 (diff) | |
download | sequelpro-467944c01e5978b0f543353e1a7dd3150fd69e6f.tar.gz sequelpro-467944c01e5978b0f543353e1a7dd3150fd69e6f.tar.bz2 sequelpro-467944c01e5978b0f543353e1a7dd3150fd69e6f.zip |
• optimized SQLtokenizer lexer
-rw-r--r-- | Source/SPSQLTokenizer.h | 15 | ||||
-rw-r--r-- | Source/SPSQLTokenizer.l | 49 |
2 files changed, 30 insertions, 34 deletions
diff --git a/Source/SPSQLTokenizer.h b/Source/SPSQLTokenizer.h index 7f459440..3427e57d 100644 --- a/Source/SPSQLTokenizer.h +++ b/Source/SPSQLTokenizer.h @@ -20,13 +20,8 @@ // // More info at <http://code.google.com/p/sequel-pro/> -#define SP_SQL_TOKEN_DOUBLE_QUOTED_TEXT 1 -#define SP_SQL_TOKEN_SINGLE_QUOTED_TEXT 2 -#define SP_SQL_TOKEN_COMMENT 3 -#define SP_SQL_TOKEN_BACKTICK_QUOTED_TEXT 4 -#define SP_SQL_TOKEN_DELIM_START 5 -#define SP_SQL_TOKEN_DELIM_VALUE 6 -#define SP_SQL_TOKEN_DELIM_END 7 -#define SP_SQL_TOKEN_WHITESPACE 8 -#define SP_SQL_TOKEN_SEMICOLON 9 -#define SP_SQL_TOKEN_COMPOUND 10 +#define SP_SQL_TOKEN_DELIM_VALUE 1 +#define SP_SQL_TOKEN_DELIM_END 2 +#define SP_SQL_TOKEN_SEMICOLON 3 +#define SP_SQL_TOKEN_COMPOUND_END 4 +#define SP_SQL_TOKEN_IGNORE 5 diff --git a/Source/SPSQLTokenizer.l b/Source/SPSQLTokenizer.l index 95d0f76c..e38ad8ea 100644 --- a/Source/SPSQLTokenizer.l +++ b/Source/SPSQLTokenizer.l @@ -36,41 +36,42 @@ int yyuoffset, yyuleng; %option noyywrap %option case-insensitive -s [ \t\n\r] -dkey "delimiter" -scol ";" -dval [!-゚] -compound "create"(.|\n|\r)+?"begin"(.|\n|\r)+?{s}+"end"{s}*?{scol} +s [ \t\n\r] +dkey "delimiter" +scol ";" +dval [!-゚] +compstart "begin"{s} +compend {s}"end" %x comment %x delim %x delimbody +%x comp +%x compbody %% -\"([^"\\]|\\(.|[\n\r]))*\"? { return SP_SQL_TOKEN_DOUBLE_QUOTED_TEXT; } -'([^'\\]|\\(.|[\n\r]))*'? { return SP_SQL_TOKEN_SINGLE_QUOTED_TEXT; } -`[^`]*`? { return SP_SQL_TOKEN_BACKTICK_QUOTED_TEXT; } +\"([^"\\]|\\(.|[\n\r]))*\"? { return SP_SQL_TOKEN_IGNORE; } +'([^'\\]|\\(.|[\n\r]))*'? { return SP_SQL_TOKEN_IGNORE; } +`[^`]*`? { return SP_SQL_TOKEN_IGNORE; } -"/*" { BEGIN(comment); return SP_SQL_TOKEN_COMMENT; } -<comment>[^*]* { return SP_SQL_TOKEN_COMMENT; } -<comment>"*"+ { return SP_SQL_TOKEN_COMMENT; } -<comment>"*"+"/" { BEGIN(INITIAL); return SP_SQL_TOKEN_COMMENT; } +"/*" { BEGIN(comment); return SP_SQL_TOKEN_IGNORE; } +<comment>[^*]* { return SP_SQL_TOKEN_IGNORE; } +<comment>"*"+ { return SP_SQL_TOKEN_IGNORE; } +<comment>"*"+"/" { BEGIN(INITIAL); return SP_SQL_TOKEN_IGNORE; } #[^\n\r]*(\n|\r)? | ---[ \t][^\n\r]*(\n|\r)? { return SP_SQL_TOKEN_COMMENT; } - -{s}+ { return SP_SQL_TOKEN_WHITESPACE; } - -{dkey}{s}+ { BEGIN(delim); return SP_SQL_TOKEN_DELIM_START; } -<delim>{dval}+ { BEGIN(delimbody); return SP_SQL_TOKEN_DELIM_VALUE; } -<delimbody>{s}+{dkey}{s}+{scol} { BEGIN(INITIAL); return SP_SQL_TOKEN_DELIM_END; } - -{compound} { return SP_SQL_TOKEN_COMPOUND; } - -{scol} { return SP_SQL_TOKEN_SEMICOLON; } -[.\r\n] { return SP_SQL_TOKEN_WHITESPACE; } +--[ \t][^\n\r]*(\n|\r)? { return SP_SQL_TOKEN_IGNORE; } +{s}+ { return SP_SQL_TOKEN_IGNORE; } +{s}*{dkey}{s}+ { BEGIN(delim); return SP_SQL_TOKEN_IGNORE; } +<delim>{dval}+ { BEGIN(delimbody); return SP_SQL_TOKEN_DELIM_VALUE; } +<delimbody>{s}+{dkey}{s}+{scol}{s}* { BEGIN(INITIAL); return SP_SQL_TOKEN_DELIM_END; } +{compstart} { BEGIN(comp); return SP_SQL_TOKEN_IGNORE; } +<comp>{dval}+ { BEGIN(compbody); return SP_SQL_TOKEN_IGNORE; } +<compbody>{compend}{s}*{scol} { BEGIN(INITIAL); return SP_SQL_TOKEN_COMPOUND_END; } +{scol}{s}* { return SP_SQL_TOKEN_SEMICOLON; } +[.\r\n]+ { return SP_SQL_TOKEN_IGNORE; } <<EOF>> { |