File: deflexer.c

package info (click to toggle)
libbow 19981105-1.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,604 kB
  • ctags: 1,612
  • sloc: ansic: 17,174; makefile: 453; perl: 391; sh: 91
file content (82 lines) | stat: -rw-r--r-- 3,201 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* Define and set the default lexer. */

/* Copyright (C) 1997, 1998 Andrew McCallum

   Written by:  Andrew Kachites McCallum <mccallum@cs.cmu.edu>

   This file is part of the Bag-Of-Words Library, `libbow'.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License
   as published by the Free Software Foundation, version 2.
   
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA */

#include <bow/libbow.h>

/* Default instances of the lexers that can be modified by libbow's
   argp cmdline argument processing. */
static bow_lexer_simple _bow_default_lexer_simple;
static bow_lexer_simple _bow_default_lexer_white;
static bow_lexer_simple _bow_default_lexer_suffixing;
static bow_lexer_gram _bow_default_lexer_gram;
static bow_lexer_indirect _bow_default_lexer_html;
static bow_lexer_indirect _bow_default_lexer_email;

bow_lexer_simple *bow_default_lexer_simple;
bow_lexer_simple *bow_default_lexer_white;
bow_lexer_simple *bow_default_lexer_suffixing;
bow_lexer_indirect *bow_default_lexer_indirect;
bow_lexer_gram *bow_default_lexer_gram;
bow_lexer_indirect *bow_default_lexer_html;
bow_lexer_indirect *bow_default_lexer_email;

/* The default lexer used by all library functions. */
/* NOTE: Be sure to set this to a value, otherwise some linkers (like
   SunOS's) will not actually include this .o file in the executable,
   and then _bow_default_lexer() will not get called, and then the
   lexer's will not get initialized properly.  Ug. */
bow_lexer *bow_default_lexer = (void*)-1;

void _bow_default_lexer_init ()  __attribute__ ((constructor));

void
_bow_default_lexer_init ()
{
  static int done = 0;

  if (done)
    return;
  done = 1;

  _bow_default_lexer_simple = *bow_alpha_lexer;
  _bow_default_lexer_white = *bow_white_lexer;
  _bow_default_lexer_suffixing = *bow_suffixing_lexer;
  _bow_default_lexer_gram = *bow_gram_lexer;
  _bow_default_lexer_html = *bow_html_lexer;
  _bow_default_lexer_email = *bow_email_lexer;

  _bow_default_lexer_gram.indirect_lexer.underlying_lexer =
    (bow_lexer*)(&_bow_default_lexer_simple);
  _bow_default_lexer_html.underlying_lexer =
    (bow_lexer*)(&_bow_default_lexer_simple);
  _bow_default_lexer_email.underlying_lexer =
    (bow_lexer*)(&_bow_default_lexer_simple);

  bow_default_lexer_simple = &_bow_default_lexer_simple;
  bow_default_lexer_white = &_bow_default_lexer_white;
  bow_default_lexer_suffixing = &_bow_default_lexer_suffixing;
  bow_default_lexer_gram = &_bow_default_lexer_gram;
  bow_default_lexer_html = &_bow_default_lexer_html;
  bow_default_lexer_email = &_bow_default_lexer_email;

  bow_default_lexer = (bow_lexer*) bow_default_lexer_gram;
  bow_default_lexer_indirect = &(bow_default_lexer_gram->indirect_lexer);
}