blob: 6ff4e3063d4dc14b182e78144b2e7b2ea441af63 (
plain) (
blame)
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
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <vespa/fsa/fsa.h>
#if (__GNUG__ <3 || (__GNUG__ == 3 && __GNUC_MINOR__ < 1))
namespace std {
const char *left = "";
}
#endif
using namespace fsa;
int main(int argc, char** argv)
{
if(argc!=2){
std::cerr << "usage: lookup_test fsafile <input >output" << std::endl;
exit(1);
}
FSA f(argv[1]);
FSA::HashedState fs(f);
std::string input;
while(!std::cin.eof()){
getline(std::cin,input);
if(input.size()>0){
fs.start(input);
if(fs.isFinal()){
std::cout << "'" << input << "'" << " is accepted, hash value: " << fs.hash()
<< ", data size: " << fs.dataSize()
<< ", data string: \""
<< std::setw(fs.dataSize()) << std::left << fs.data()
<< "\"" << std::endl;
}
else{
std::cout << "'" << input << "'" << " is not accepted." << std::endl;
}
}
}
return 0;
}
|