/src/libetonyek/src/lib/PAG1Token.cpp
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* |
3 | | * This file is part of the libetonyek project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | */ |
9 | | |
10 | | #include "PAG1Token.h" |
11 | | |
12 | | #include <cassert> |
13 | | #include <cstring> |
14 | | #include <memory> |
15 | | |
16 | | #include "IWORKTokenizerBase.h" |
17 | | |
18 | | using std::strlen; |
19 | | |
20 | | namespace libetonyek |
21 | | { |
22 | | namespace |
23 | | { |
24 | | |
25 | | #include "PAG1Token.inc" |
26 | | |
27 | | } |
28 | | } |
29 | | |
30 | | namespace libetonyek |
31 | | { |
32 | | |
33 | | namespace |
34 | | { |
35 | | |
36 | | class Tokenizer : public IWORKTokenizerBase |
37 | | { |
38 | | int queryId(const char *name) const override; |
39 | | }; |
40 | | |
41 | | int Tokenizer::queryId(const char *const name) const |
42 | 0 | { |
43 | 0 | assert(name); |
44 | |
|
45 | 0 | const size_t length = strlen(name); |
46 | 0 | assert(0 < length); |
47 | |
|
48 | 0 | const Token *const token = Perfect_Hash::in_word_set(name, (unsigned) length); |
49 | 0 | return token ? token->id : 0; |
50 | 0 | } |
51 | | |
52 | | } |
53 | | |
54 | | namespace PAG1Token |
55 | | { |
56 | | |
57 | | const IWORKTokenizer &getTokenizer() |
58 | 718 | { |
59 | 718 | static Tokenizer tokenizer; |
60 | 718 | return tokenizer; |
61 | 718 | } |
62 | | |
63 | | } |
64 | | |
65 | | } |
66 | | |
67 | | /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ |