%{ #include #include #include #include "jqplib.h" #include "jqp.tab.h" #include "jqpstopwords.h" #include "bintree.h" /* for init_new_node() */ /* $Id: jqp.l,v 1.11 2005/09/04 01:08:57 joshr Exp $ */ /* no comments in next section. */ /* We should do case-insensitivity through a lex command line switch */ /* Also, we should use some flex fanciness for ':isalnum:' multilingual sweetness */ %} qstring \"[^\"\n]*[\"\n] %% {qstring} { debug("QSTRING"); char *tmp = strdup(yytext+1); /* copy, skipping open quote */ debug(tmp); if (tmp[yyleng-2] != '"') { debug("PUNTING, unterminated quoted string"); warning("Unterminated character string", (char*)0); } else { tmp[yyleng-2] = '\0'; /* overwrite closing quote */ yylval.tree = init_new_node(tmp, QSTRING, NULL, NULL); } free(tmp); return QSTRING; /* from lex&yacc, page 84 */ } \( { debug("OPAREN"); yylval.tree = init_new_node(yytext, OPAREN, NULL, NULL); return OPAREN; } \) { debug("CPAREN"); yylval.tree = init_new_node(yytext, CPAREN, NULL, NULL); return CPAREN; } = { debug("EQUALS"); yylval.tree = init_new_node(yytext, EQUALS, NULL, NULL); return EQUALS; } [Nn][Oo][Tt] { debug("NOT"); yylval.tree = init_new_node(yytext, NOT, NULL, NULL); return NOT; } [Aa][Nn][Dd] { debug("AND"); yylval.tree = init_new_node(yytext, AND, NULL, NULL); return AND; } [Oo][Rr] { debug("OR"); yylval.tree = init_new_node(yytext, OR, NULL, NULL); return OR; } [a-zA-Z][a-zA-Z0-9]* { debug(yytext); yylval.tree = init_new_node(yytext, WORD, NULL, NULL); return WORD; } [- ]+ { /* skip whitespace (tab or spacechar, or -) */ } %% /* code that was here was moved to jqplib.c */