]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/example/qi/compiler_tutorial/conjure3/conjure_static_lexer_generate.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / example / qi / compiler_tutorial / conjure3 / conjure_static_lexer_generate.cpp
1 // Copyright (c) 2001-2011 Hartmut Kaiser
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 // This small utility program generates the 2 static lexers, the static table
7 // driven and the static switch based lexer.
8
9 #include <fstream>
10 #include <iostream>
11
12 #include "lexer_def.hpp"
13 #include <boost/spirit/include/lex_generate_static_lexertl.hpp>
14
15 int main()
16 {
17 typedef std::string::const_iterator base_iterator_type;
18 typedef client::lexer::conjure_tokens<base_iterator_type> lexer_type;
19
20 lexer_type lexer;
21
22 // first generate the static switch based lexer
23 std::ofstream out_static("conjure_static_switch_lexer.hpp");
24
25 bool result = boost::spirit::lex::lexertl::generate_static_switch(
26 lexer, out_static, "conjure_static_switch");
27 if (!result) {
28 std::cerr << "Failed to generate static switch based lexer\n";
29 return -1;
30 }
31
32 // now generate the static table based lexer
33 std::ofstream out("conjure_static_lexer.hpp");
34 result = boost::spirit::lex::lexertl::generate_static(
35 lexer, out, "conjure_static");
36 if (!result) {
37 std::cerr << "Failed to generate static table based lexer\n";
38 return -1;
39 }
40
41 return 0;
42 }
43