diff options
author | marko@hundin.mysql.fi <> | 2004-06-22 16:15:58 +0300 |
---|---|---|
committer | marko@hundin.mysql.fi <> | 2004-06-22 16:15:58 +0300 |
commit | 5abd76355ee6a57b65d8711e29b3d9930bd2b289 (patch) | |
tree | 006cafebf1a4b23ec2f5906626239f95cf686e0a /innobase/pars/pars0lex.l | |
parent | 700c2332586d5f28ae4c7241456e1370425b2ed7 (diff) | |
download | mariadb-git-5abd76355ee6a57b65d8711e29b3d9930bd2b289.tar.gz |
lexyy.c, pars0lex.l:
Document the handling of quoted strings
Diffstat (limited to 'innobase/pars/pars0lex.l')
-rw-r--r-- | innobase/pars/pars0lex.l | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/innobase/pars/pars0lex.l b/innobase/pars/pars0lex.l index 4e2399613cb..811057d48a1 100644 --- a/innobase/pars/pars0lex.l +++ b/innobase/pars/pars0lex.l @@ -114,11 +114,34 @@ ID [a-z_A-Z][a-z_A-Z0-9]* } "'" { +/* Quoted character string literals are handled in an explicit +start state 'quoted'. This state is entered and the buffer for +the scanned string is emptied upon encountering a starting quote. + +In the state 'quoted', only two actions are possible (defined below). */ BEGIN(quoted); stringbuf_len = 0; } -<quoted>[^\']+ string_append(yytext, yyleng); -<quoted>"'"+ { string_append(yytext, yyleng / 2); +<quoted>[^\']+ { + /* Got a sequence of characters other than "'": + append to string buffer */ + string_append(yytext, yyleng); +} +<quoted>"'"+ { + /* Got a sequence of "'" characters: + append half of them to string buffer, + as "''" represents a single "'". + We apply truncating division, + so that "'''" will result in "'". */ + + string_append(yytext, yyleng / 2); + + /* If we got an odd number of quotes, then the + last quote we got is the terminating quote. + At the end of the string, we return to the + initial start state and report the scanned + string literal. */ + if (yyleng % 2) { BEGIN(INITIAL); yylval = sym_tab_add_str_lit( |