File: archer_query.lex

package info (click to toggle)
bow 19991122-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,544 kB
  • ctags: 2,987
  • sloc: ansic: 38,660; lisp: 1,072; makefile: 594; perl: 492; yacc: 149; sh: 91
file content (45 lines) | stat: -rw-r--r-- 1,072 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
%{
#include <string.h>
#include <bow/archer_query.h>
#include <archer_query_y.h>
%}

%option noyywrap

WORD            [_[:alnum:]]+
NUMBER          [[:digit:]]+
WS              [[:space:]\n]+
WEIGHT          [[:digit:]]*"."[[:digit:]]+
 
%%

{NUMBER}        archer_query_lval.string = strdup(archer_query_text); return NUMBER;
{WORD}          archer_query_lval.string = strdup(archer_query_text); return WORD;
{WS}
":"             return ':';
"["             return '[';
"]"             return ']';
"+"             return '+';
"-"             return '-';
"\""            return '"';
","             return ',';
"~"             return '~';
">"             return '>';
"<"             return '<';
"("             return '(';
")"             return ')';
.               {
                  char buf[256];

		  sprintf(buf, "Invalid character: %s\n", yytext);
		  archer_query_error(buf);
                }
%%

void archer_query_setup(const char* string) {
  static YY_BUFFER_STATE buffer = NULL;

  if(buffer) yy_delete_buffer(buffer);
  buffer = yy_scan_string(string);
}