1 /* ttt-lex.l - flex-based lexical analyzer
3 * Copyright © 2005 Carl Worth
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Author: Carl Worth <cworth@cworth.org>
28 #include "ttt-token.h"
30 #define YY_DECL int yylex (yyscan_t yyscanner, ttt_token_t *token)
31 #define STRING_BUF_SIZE 8000
33 /* Shut off some compiler warnings due to annoying flex bugs. */
35 int yyget_column (yyscan_t yyscanner);
36 void yyset_column (int column_no , yyscan_t yyscanner);
44 char string_buf[STRING_BUF_SIZE];
50 token->type = TTT_TOKEN_TYPE_NEWLINE;
53 /* This dead code is just to shut off a
54 * compiler warning due to an annoying flex
60 string_buf_ptr = string_buf;
66 *string_buf_ptr++ = '"';
70 *string_buf_ptr++ = '\\';
77 *string_buf_ptr++ = *s++;
82 *string_buf_ptr = '\0';
83 token->type = TTT_TOKEN_TYPE_STRING;
84 token->u.string = xstrdup (string_buf);
89 [^ \t\r\n\"][^ \t\r\n\"]* {
90 token->type = TTT_TOKEN_TYPE_STRING;
91 token->u.string = xstrdup (yytext);