forked from galaxykate/tracery
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.cpp
More file actions
executable file
·38 lines (31 loc) · 721 Bytes
/
app.cpp
File metadata and controls
executable file
·38 lines (31 loc) · 721 Bytes
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
//
// Output an example line from a JSON Tracery grammar.
//
#include <cstdio>
#include <fstream>
#include <iostream>
#include <string>
#include "tracery.h"
using namespace tracery;
using namespace modifiers;
int main(int argc, char** argv)
{
std::string rules;
if (argc == 2)
{
std::ifstream file(argv[1]);
if (file.is_open())
{
std::string line;
while (getline(file,line))
{
rules += line;
}
file.close();
}
}
Grammar grammar = tracery::Grammar(rules);
grammar.add_modifiers(base_english());
std::cout << grammar.flatten("#origin#") << std::endl << std::endl;
return 0;
}