├── HISTORY.md
├── JSPT
├── bin
│ ├── .ignore
│ ├── genguid
│ ├── install.dir
│ │ └── jecho
│ ├── install.li32
│ ├── install.li64
│ ├── jecho
│ ├── json2prj
│ │ ├── Makefile.php
│ │ ├── include
│ │ │ ├── guid.class.php
│ │ │ └── print.php
│ │ ├── make.php
│ │ └── vcproj.php
│ ├── jspt
│ ├── li32
│ │ └── prj2json
│ ├── prj2make
│ ├── prj2vcproj
│ ├── prjconv
│ └── win32
│ │ └── prj2json.exe
└── prj2json
│ ├── ProjectJson.cpp
│ └── build
│ ├── Makefile.li32
│ ├── Makefile.li64
│ ├── build
│ ├── build.prj
│ ├── vc8-win32.vcproj
│ └── vc8-win64.vcproj
├── README.md
├── examples
├── boost-lambda
│ ├── calc
│ │ ├── Calc.cpp
│ │ ├── Makefile
│ │ ├── build
│ │ └── calc.prj
│ └── print
│ │ ├── Makefile
│ │ ├── Simplest.cpp
│ │ ├── build
│ │ └── print.prj
├── boost-phoenix
│ ├── calc
│ │ ├── Calc.cpp
│ │ ├── Makefile
│ │ ├── build
│ │ └── calc.prj
│ └── print
│ │ ├── Makefile
│ │ ├── Simplest.cpp
│ │ ├── build
│ │ └── print.prj
├── calculator
│ ├── Calc.cpp
│ ├── Makefile
│ ├── build
│ ├── calculator(vc9).vcproj
│ ├── calculator.prj
│ ├── calculator.vcproj
│ └── readme.txt
├── circuit
│ ├── Circuit.cpp
│ ├── Makefile
│ ├── build
│ └── circuit.prj
├── emulator
│ ├── Emulator.cpp
│ ├── Emulator.vcproj
│ ├── Makefile
│ ├── build
│ └── emulator.prj
├── grammar
│ ├── Makefile
│ ├── SimpleGrammar.cpp
│ ├── build
│ └── grammar.prj
├── grammar2
│ ├── Makefile
│ ├── SimpleGrammar.cpp
│ ├── build
│ └── grammar2.prj
├── htmltext
│ ├── HtmlText.cpp
│ ├── Makefile
│ ├── build
│ └── htmltext.prj
├── includefiles
│ ├── IncludeFiles.cpp
│ ├── Makefile
│ ├── build
│ └── includefiles.prj
├── json-print
│ ├── Makefile
│ ├── Simplest.cpp
│ ├── build
│ └── json-print.prj
├── json-print2
│ ├── Makefile
│ ├── Simplest.cpp
│ ├── build
│ └── json-print2.prj
├── lang
│ ├── Lang.cpp
│ ├── Makefile
│ ├── build
│ ├── input.lang
│ ├── lang.prj
│ └── readme.txt
├── projects.plf
├── removecomments
│ ├── Makefile
│ ├── RemoveCppComments.cpp
│ ├── build
│ └── removecomments.prj
├── removecomments2
│ ├── Makefile
│ ├── RemoveCppComments.cpp
│ ├── build
│ └── removecomments2.prj
├── simplest
│ ├── Makefile
│ ├── Simplest.cpp
│ ├── build
│ ├── simplest.prj
│ └── simplest.vcproj
├── simplest2
│ ├── Makefile
│ ├── Simplest.cpp
│ ├── build
│ ├── simplest.vcproj
│ └── simplest2.prj
├── token
│ ├── Main.cpp
│ └── token.vcproj
├── urlparams
│ ├── Makefile
│ ├── ParseUrlParams.cpp
│ ├── build
│ └── urlparams.prj
├── validation
│ ├── Makefile.li32
│ ├── Makefile.li64
│ ├── Simplest.cpp
│ ├── build
│ └── validation.prj
└── variant
│ ├── Makefile
│ ├── Variant.cpp
│ ├── Variant.h
│ ├── build
│ └── variant.prj
├── include
└── tpl
│ ├── Basic.h
│ ├── BinRegExp.h
│ ├── Emulator.h
│ ├── RegExp.h
│ ├── binary
│ ├── Assignment.h
│ ├── Basic.h
│ ├── ComPtr.h
│ ├── Composition.h
│ ├── Customization.h
│ ├── MatchResult.h
│ ├── Operator.h
│ ├── Ref.h
│ ├── Storage.h
│ └── Terminal.h
│ ├── boost
│ ├── Lambda.h
│ └── Phoenix.h
│ ├── c
│ ├── Comment.h
│ └── Lex.h
│ ├── emu
│ ├── CPU.h
│ ├── Code.h
│ ├── Function.h
│ ├── Instruction.h
│ ├── Label.h
│ ├── Var.h
│ └── _OldVar.h
│ ├── ext
│ └── Calculator.h
│ ├── html
│ ├── Lex.h
│ └── entity
│ │ ├── Latin-1.h
│ │ └── Symbol.h
│ └── regex
│ ├── Action.h
│ ├── Append.h
│ ├── Assign.h
│ ├── Basic.h
│ ├── Case.h
│ ├── Composition.h
│ ├── Concretion.h
│ ├── Condition.h
│ ├── Customization.h
│ ├── DOM.h
│ ├── Find.h
│ ├── Match.h
│ ├── Operator.h
│ ├── Predicate.h
│ ├── Ref.h
│ ├── RuleTraits.h
│ ├── Terminal.h
│ ├── Token.h
│ ├── Transformation.h
│ ├── UComposition.h
│ ├── detail
│ ├── STLHeaders.h
│ └── TypeTraits.h
│ ├── grammar
│ ├── Action.h
│ ├── Concretion.h
│ ├── Condition.h
│ └── Operator.h
│ └── result
│ ├── Context.h
│ ├── Document.h
│ └── Mark.h
└── test
└── testtpl
├── Demo.cpp
├── Makefile
├── SimpleBinary.cpp
├── StdAfx.cpp
├── TestTpl.cpp
├── TestTpl.vcproj
├── Transformation.cpp
├── WordText.cpp
├── XmlProcess.cpp
├── stdafx.h
└── testtpl.prj.li
/HISTORY.md:
--------------------------------------------------------------------------------
1 | My C/C++ Open Source Projects
2 | =====
3 |
4 | ## winx - A C++ GUI Library for Windows
5 |
6 | It was open sourced on [Sourceforge](https://sourceforge.net/projects/winx/) on 2006-08-14.
7 |
8 | * https://sourceforge.net/projects/winx/
9 | * https://code.google.com/archive/p/winx/
10 | * https://github.com/xushiwei/winx
11 |
12 | ## stdext - A C++ STL Extensions Libary
13 |
14 | It was originally part of `winx` and became an independent open source project on 2008-01-23.
15 |
16 | * https://code.google.com/archive/p/stdext/
17 | * https://github.com/xushiwei/stdext
18 |
19 | ## memory - C++ Memory Management Innovation: GC Allocator
20 |
21 | It was originally part of `stdext` and became an independent open source project on 2008-04-28.
22 |
23 | Most of the C++ programmers do not benefit from Garbage Collection technique (GC). Here is a new memory management technique named GC Allocator (Note it is not GC).
24 |
25 | * https://www.codeproject.com/KB/cpp/gc-allocator.aspx
26 | * http://svn.boost.org/svn/boost/sandbox/memory/ (not available)
27 | * https://github.com/xushiwei/memory
28 |
29 | ## tpl - Text Processing Language
30 |
31 | TPL is a Text Processing Library/Language.
32 |
33 | It was open sourced on [Google Code](https://code.google.com/archive/p/libtpl/) on 2008-06-21.
34 |
35 | * https://code.google.com/archive/p/libtpl/
36 | * https://github.com/xushiwei/tpl
37 |
--------------------------------------------------------------------------------
/JSPT/bin/.ignore:
--------------------------------------------------------------------------------
1 | prj2json.exe
2 | jspt.bat
3 |
4 |
--------------------------------------------------------------------------------
/JSPT/bin/genguid:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 |
6 |
7 |
--------------------------------------------------------------------------------
/JSPT/bin/install.dir/jecho:
--------------------------------------------------------------------------------
1 | ~/bin/jspt.dir/jecho $*
2 |
3 |
--------------------------------------------------------------------------------
/JSPT/bin/install.li32:
--------------------------------------------------------------------------------
1 | if [ -z $PLATFORM ]; then
2 | PLATFORM=li32
3 | fi
4 |
5 | AppPath0=`dirname $0`
6 | AppPath=`cd $AppPath0; pwd`
7 |
8 | if [ -z $1 ]; then
9 | TargetDir=~/bin
10 | else
11 | TargetDir=$1
12 | fi
13 |
14 | echo "$AppPath/prjconv \$*" > $TargetDir/prjconv
15 | chmod +x $TargetDir/prjconv
16 |
17 | rm -f $AppPath/prj2json.exe
18 |
19 | sed -i -e "s|PLATFORM=.*|PLATFORM=$PLATFORM|" $AppPath/prj2make
20 |
21 | for File in $AppPath/prj2* ; do
22 | cp $File $TargetDir/
23 | done
24 |
25 | cd $AppPath
26 | ln -s -f $PLATFORM/prj2json prj2json.exe
27 | cp -f jspt jspt.bat
28 |
29 | mkdir -p ~/bin
30 | ln -s -f $AppPath ~/bin/jspt.dir
31 | cp $AppPath/install.dir/* ~/bin
32 |
33 |
--------------------------------------------------------------------------------
/JSPT/bin/install.li64:
--------------------------------------------------------------------------------
1 | PLATFORM=li64
2 |
3 | AppPath=`dirname $0`
4 | $AppPath/install.li32
5 |
6 |
--------------------------------------------------------------------------------
/JSPT/bin/jecho:
--------------------------------------------------------------------------------
1 | AppPath=`dirname $0`
2 | $AppPath/jspt $AppPath/json2prj/include/print.php $*
3 |
4 |
--------------------------------------------------------------------------------
/JSPT/bin/json2prj/Makefile.php:
--------------------------------------------------------------------------------
1 | link make.php
--------------------------------------------------------------------------------
/JSPT/bin/json2prj/include/guid.class.php:
--------------------------------------------------------------------------------
1 | Name = $_ENV["COMPUTERNAME"];
20 | $address->IP = $_SERVER["SERVER_ADDR"];
21 | return $address;
22 | }
23 |
24 | function toString()
25 | {
26 | return strtolower($this->Name.'/'.$this->IP);
27 | }
28 | }
29 |
30 | class Random
31 | {
32 | function nextLong()
33 | {
34 | $tmp = rand(0,1)?'-':'';
35 | return $tmp.rand(1000, 9999).rand(1000, 9999).rand(1000, 9999).rand(100, 999).rand(100, 999);
36 | }
37 | }
38 |
39 | // 三段
40 | // 一段是微秒 一段是地址 一段是随机数
41 | class Guid
42 | {
43 | var $valueBeforeMD5;
44 | var $valueAfterMD5;
45 |
46 | function Guid()
47 | {
48 | $this->getGuid();
49 | }
50 |
51 | function getGuid()
52 | {
53 | $address = NetAddress::getLocalHost();
54 | $this->valueBeforeMD5 = $address->toString().':'.System::currentTimeMillis().':'.Random::nextLong();
55 | $this->valueAfterMD5 = md5($this->valueBeforeMD5);
56 | }
57 |
58 | function newGuid()
59 | {
60 | $Guid = new Guid();
61 | return $Guid;
62 | }
63 |
64 | function toString()
65 | {
66 | $raw = strtoupper($this->valueAfterMD5);
67 | return substr($raw,0,8).'-'.substr($raw,8,4).'-'.substr($raw,12,4).'-'.substr($raw,16,4).'-'.substr($raw,20);
68 | }
69 | }
70 |
71 | function createGuid()
72 | {
73 | $guid = new Guid();
74 | return $guid->toString();
75 | }
76 | ?>
77 |
--------------------------------------------------------------------------------
/JSPT/bin/json2prj/include/print.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/JSPT/bin/jspt:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | output\n\n";
6 | return;
7 | }
8 |
9 | $argv = $_SERVER["argv"];
10 | if ($argc == 2)
11 | $doc = json_decode(stream_get_contents(STDIN));
12 | else
13 | $doc = json_decode(file_get_contents($argv[2]));
14 | require($argv[1]);
15 | ?>
16 |
--------------------------------------------------------------------------------
/JSPT/bin/li32/prj2json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xushiwei/tpl/c0c5f86e99b072345418b812412894d2b25a4296/JSPT/bin/li32/prj2json
--------------------------------------------------------------------------------
/JSPT/bin/prj2make:
--------------------------------------------------------------------------------
1 | if [ -z $1 ]; then
2 | PLATFORM=li32
3 | export PRJCONV_OS=linux
4 | export PRJCONV_BITS=32
5 | export PRJCONV_OUTFILE=Makefile.li32
6 | prjconv make
7 | export PRJCONV_BITS=64
8 | export PRJCONV_OUTFILE=Makefile.li64
9 | prjconv make
10 | ln -s -f Makefile.$PLATFORM Makefile
11 | else
12 | export PRJCONV_BITS=independent
13 | export PRJCONV_OUTFILE=Makefile
14 | prjconv make
15 | fi
16 |
17 |
--------------------------------------------------------------------------------
/JSPT/bin/prj2vcproj:
--------------------------------------------------------------------------------
1 | export PRJCONV_BITS=32
2 | export PRJCONV_OUTFILE=vc8-win32.vcproj
3 | prjconv vcproj $*
4 | export PRJCONV_BITS=64
5 | export PRJCONV_OUTFILE=vc8-win64.vcproj
6 | prjconv vcproj $*
7 |
8 |
--------------------------------------------------------------------------------
/JSPT/bin/prjconv:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 | [.prj]\n";
8 | echo "Here can be:\n";
9 | chdir($AppPath . "/json2prj");
10 | foreach (glob("*.php") as $File) {
11 | echo "\t" . pathinfo($File, PATHINFO_FILENAME) . "\n";
12 | }
13 | return -1;
14 | }
15 |
16 | $PhpFile = $AppPath . "/json2prj/" . $argv[1] . ".php";
17 | if (!file_exists($PhpFile)) {
18 | echo "ERROR: $PhpFile doesn't exists!\n\n";
19 | return -2;
20 | }
21 |
22 | if ($argc < 3) {
23 | $PrjFile = pathinfo(getcwd(), PATHINFO_BASENAME) . ".prj";
24 | }
25 | else {
26 | $PrjFile = $argv[2];
27 | }
28 | if (!file_exists($PrjFile)) {
29 | echo "ERROR: $PrjFile doesn't exists!\n\n";
30 | return -3;
31 | }
32 |
33 | $Cmd = $AppPath . "/prj2json.exe " . $PrjFile . " | " . $AppPath . "/jspt.bat " . $PhpFile;
34 | $PRJCONV_OUTFILE = getenv("PRJCONV_OUTFILE");
35 | if ($PRJCONV_OUTFILE) {
36 | $Cmd .= " > " . $PRJCONV_OUTFILE;
37 | }
38 | system($Cmd);
39 | ?>
40 |
--------------------------------------------------------------------------------
/JSPT/bin/win32/prj2json.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xushiwei/tpl/c0c5f86e99b072345418b812412894d2b25a4296/JSPT/bin/win32/prj2json.exe
--------------------------------------------------------------------------------
/JSPT/prj2json/ProjectJson.cpp:
--------------------------------------------------------------------------------
1 | #define TPL_USE_AUTO_ALLOC
2 | #include
3 | #include
4 |
5 | using namespace tpl;
6 |
7 | // -------------------------------------------------------------------------
8 |
9 | #define PRJ_PATH token<'\r', '\n', '['>()
10 | #define PRJ_ITEM token<';', '\r', '\n'>()
11 |
12 | int main(int argc, const char* argv[])
13 | {
14 | const bool array = true;
15 |
16 | NS_STDEXT::ErrorLog err;
17 | if (argc < 2) {
18 | err.print("Usage: prj2json \n");
19 | return -1;
20 | }
21 |
22 | NS_STDEXT::FileBuf file(argv[1]);
23 | if (!file.good()) {
24 | err.print(">>> ERROR: open input file failed!\n");
25 | return -2;
26 | }
27 |
28 | typedef DOM<> dom;
29 |
30 | dom::Mark tagInclude("include", array);
31 | dom::NodeMark tagCfg("config", array);
32 | dom::Mark tagName("name");
33 | dom::NodeMark tagProduct("product");
34 | dom::Mark tagType("type");
35 | dom::Mark tagPath("path");
36 | dom::Mark tagOption("option", array);
37 | dom::Mark tagDefine("define", array);
38 | dom::Mark tagObjDir("objdir");
39 | dom::Mark tagLibDir("libdir", array);
40 | dom::Mark tagLib("lib", array);
41 | dom::Mark tagSrc("src", array);
42 |
43 | dom::Allocator alloc;
44 | dom::Document doc(alloc);
45 |
46 | dom::NodeMark tagPlatform("platform");
47 | dom::Mark tagCPU("cpu");
48 | dom::Mark tagByteSwap("byteswap");
49 | dom::Mark tagBits("bits");
50 | dom::Mark tagOS("os");
51 |
52 | dom::Node* plat = doc.insertNode(alloc, tagPlatform);
53 |
54 | #define PRJ_INSERT_LEAF(tag, data) \
55 | plat->insertLeaf(alloc, tag, NS_STDEXT::TempString(data))
56 |
57 | #if defined(__INTEL__)
58 | PRJ_INSERT_LEAF(tagCPU, "intel");
59 | #elif defined(__SPARC__)
60 | PRJ_INSERT_LEAF(tagCPU, "sparc");
61 | #endif
62 |
63 | #if defined(__BYTESWAP__) || defined(BYTESWAP)
64 | PRJ_INSERT_LEAF(tagByteSwap, "true");
65 | #else
66 | PRJ_INSERT_LEAF(tagByteSwap, "false");
67 | #endif
68 |
69 | #if defined(__32BIT__) || defined(_WIN32)
70 | PRJ_INSERT_LEAF(tagBits, "32");
71 | #elif defined(__64BIT__) || defined(_WIN64)
72 | PRJ_INSERT_LEAF(tagBits, "64");
73 | #endif
74 |
75 | #if defined(__LINUX__) || defined(LINUX)
76 | PRJ_INSERT_LEAF(tagOS, "linux");
77 | #elif defined(_WIN32) || defined(_WIN64) || defined(X_OS_WINDOWS)
78 | PRJ_INSERT_LEAF(tagOS, "windows");
79 | #endif
80 |
81 | if (file >> (skipws() % ("//" + find_eol()))
82 | [
83 | !(
84 | gr(icase["[include]"]) + *gr(PRJ_PATH/tagInclude)
85 | ) +
86 | +(
87 | (
88 | gr(icase["[config"] + ws() + find(']')/tagName + ']') +
89 | +gr(
90 | c_symbol()
91 | [
92 | case_(eqICase("product"))
93 | [
94 | skip_non_eol_ws_
95 | [
96 | gr(c_symbol()/tagType) + gr(PRJ_PATH/tagPath)
97 | ]/tagProduct
98 | ],
99 | case_(eqICase("options"))
100 | [
101 | !(
102 | skip_non_eol_ws_
103 | [
104 | gr(PRJ_ITEM/tagOption) % ';'
105 | ]
106 | )
107 | ],
108 | case_(eqICase("defines"))
109 | [
110 | !(
111 | skip_non_eol_ws_
112 | [
113 | gr(PRJ_ITEM/tagDefine) % ';'
114 | ]
115 | )
116 | ],
117 | case_(eqICase("objdir"))
118 | [
119 | !(
120 | skip_non_eol_ws_
121 | [
122 | gr(PRJ_PATH/tagObjDir)
123 | ]
124 | )
125 | ],
126 | case_(eqICase("libdir"))
127 | [
128 | !(
129 | skip_non_eol_ws_
130 | [
131 | gr(PRJ_ITEM/tagLibDir) % ';'
132 | ]
133 | )
134 | ],
135 | case_(eqICase("libraries"))
136 | [
137 | !(
138 | skip_non_eol_ws_
139 | [
140 | gr(PRJ_ITEM/tagLib) % ';'
141 | ]
142 | )
143 | ]
144 | ]
145 | )
146 | )/tagCfg
147 | ) +
148 | (
149 | gr(icase["[source]"]) + +gr(PRJ_PATH/tagSrc)
150 | )
151 | ]/doc)
152 | {
153 | NS_STDEXT::OutputLog log;
154 | json_print(alloc, log, doc);
155 | return 0;
156 | }
157 |
158 | err.print("Invalid project format!!!\n");
159 | return -3;
160 | }
161 |
162 | // -------------------------------------------------------------------------
163 |
164 |
--------------------------------------------------------------------------------
/JSPT/prj2json/build/Makefile.li32:
--------------------------------------------------------------------------------
1 | OSAbbr = li
2 | Bits = 32
3 | Platform = li32
4 |
5 | #
6 | # Configuration Default
7 | #
8 | ifeq ($(CFG),)
9 | CFG = Debug
10 | endif
11 |
12 | IncludeDir = -I../../../../tpl/include -I../../../../stdext/include
13 |
14 | #
15 | # Configuration Release
16 | #
17 | ifeq ($(CFG), Release)
18 | ProductDir = ../../bin/$(Platform)
19 | ObjectDir = Release
20 | Product = ../../bin/$(Platform)/prj2json
21 | CFlags = $(Defines) -fPIC -D__32BIT__ -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions -Wall
22 | CXXFlags = $(CFlags) -fno-rtti
23 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
24 | CompileCXX = @g++ -c $(IncludeDir) $(CXXFlags) -o $@ $<
25 | Link = @g++ $(LibDir) -o $(Product)
26 | CheckLink = @ldd -u -r $(Product); echo
27 | LD_LIBRARY_PATH += :$(ProductDir)
28 | endif
29 |
30 | #
31 | # Configuration Debug
32 | #
33 | ifeq ($(CFG), Debug)
34 | ProductDir = Debug
35 | ObjectDir = Debug
36 | Product = Debug/prj2json
37 | CFlags = $(Defines) -fPIC -D__32BIT__ -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions -Wall
38 | CXXFlags = $(CFlags) -fno-rtti
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @g++ -c $(IncludeDir) $(CXXFlags) -o $@ $<
41 | Link = @g++ $(LibDir) -o $(Product)
42 | CheckLink = @ldd -u -r $(Product); echo
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/ProjectJson.o : \
76 | ../ProjectJson.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 | Objects = $(ObjectDir)/ProjectJson.o
81 |
82 | $(Product) : $(Objects)
83 | @echo "---> Creating" $@ "..."
84 | @rm -f $@
85 | $(Link) $(Objects) $(Libraries)
86 | $(CheckLink)
87 |
88 |
--------------------------------------------------------------------------------
/JSPT/prj2json/build/Makefile.li64:
--------------------------------------------------------------------------------
1 | OSAbbr = li
2 | Bits = 64
3 | Platform = li64
4 |
5 | #
6 | # Configuration Default
7 | #
8 | ifeq ($(CFG),)
9 | CFG = Debug
10 | endif
11 |
12 | IncludeDir = -I../../../../tpl/include -I../../../../stdext/include
13 |
14 | #
15 | # Configuration Release
16 | #
17 | ifeq ($(CFG), Release)
18 | ProductDir = ../../bin/$(Platform)
19 | ObjectDir = Release
20 | Product = ../../bin/$(Platform)/prj2json
21 | CFlags = $(Defines) -fPIC -D__64BIT__ -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions -Wall
22 | CXXFlags = $(CFlags) -fno-rtti
23 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
24 | CompileCXX = @g++ -c $(IncludeDir) $(CXXFlags) -o $@ $<
25 | Link = @g++ $(LibDir) -o $(Product)
26 | CheckLink = @ldd -u -r $(Product); echo
27 | LD_LIBRARY_PATH += :$(ProductDir)
28 | endif
29 |
30 | #
31 | # Configuration Debug
32 | #
33 | ifeq ($(CFG), Debug)
34 | ProductDir = Debug
35 | ObjectDir = Debug
36 | Product = Debug/prj2json
37 | CFlags = $(Defines) -fPIC -D__64BIT__ -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions -Wall
38 | CXXFlags = $(CFlags) -fno-rtti
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @g++ -c $(IncludeDir) $(CXXFlags) -o $@ $<
41 | Link = @g++ $(LibDir) -o $(Product)
42 | CheckLink = @ldd -u -r $(Product); echo
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/ProjectJson.o : \
76 | ../ProjectJson.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 | Objects = $(ObjectDir)/ProjectJson.o
81 |
82 | $(Product) : $(Objects)
83 | @echo "---> Creating" $@ "..."
84 | @rm -f $@
85 | $(Link) $(Objects) $(Libraries)
86 | $(CheckLink)
87 |
88 |
--------------------------------------------------------------------------------
/JSPT/prj2json/build/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/JSPT/prj2json/build/build.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../../tpl/include
3 | ../../../../stdext/include
4 |
5 | [Config Release]
6 | Product Exe ../../bin/$(Platform)/prj2json
7 | Options Release; MultiThread; AnsiChar; NoRtti; Exception; WarningAll; MiniDepency
8 | ObjDir Release
9 | LibDir
10 | Libraries
11 |
12 | [Config Debug]
13 | Product Exe Debug/prj2json
14 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception; WarningAll
15 | ObjDir Debug
16 | LibDir
17 | Libraries
18 |
19 | [Source]
20 | ../*.cpp
21 |
22 |
--------------------------------------------------------------------------------
/examples/boost-lambda/calc/Calc.cpp:
--------------------------------------------------------------------------------
1 | #define TPL_USE_AUTO_ALLOC
2 | #include // std::cout
3 | #include
4 | #include
5 |
6 | using namespace tpl;
7 | using namespace boost::lambda;
8 |
9 | int main()
10 | {
11 | typedef SimpleImplementation impl;
12 |
13 | // ---- define rules ----
14 |
15 | impl::Allocator alloc;
16 |
17 | Lambda exec;
18 |
19 | TPL_LAMBDA_LOCAL(double, term);
20 | TPL_LAMBDA_LOCAL(double, factor);
21 |
22 | impl::Rule rTerm( alloc,
23 | real()/assign(factor) + *(
24 | '*' + real()/exec[factor *= _1] |
25 | '/' + real()/exec[factor /= _1] )
26 | );
27 |
28 | impl::Rule rExpr( alloc,
29 | rTerm/exec[term = factor] + *(
30 | '+' + rTerm/exec[term += factor] |
31 | '-' + rTerm/exec[term -= factor] )
32 | );
33 |
34 | // ---- do match ----
35 |
36 | for (;;)
37 | {
38 | std::string strExp;
39 | std::cout << "input an expression (q to quit): ";
40 | std::getline(std::cin, strExp);
41 |
42 | if (strExp == "q")
43 | break;
44 |
45 | if (!impl::match(strExp.c_str(), rExpr + eos()))
46 | std::cout << "invalid expression!\n";
47 | else
48 | std::cout << term() << "\n";
49 | }
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/examples/boost-lambda/calc/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../../tpl/include -I../../../../boost -I../../../../boostmm
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/calc
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__32BIT__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -o $(Product)
25 | CheckLink = @ldd -u -r $(Product); echo
26 |
27 | LD_LIBRARY_PATH += :$(ProductDir)
28 | endif
29 |
30 | #
31 | # Configuration Debug
32 | #
33 | ifeq ($(CFG), Debug)
34 | ProductDir = Debug
35 | ObjectDir = Debug
36 | MocFile = $(ObjectDir)/temp.moc.cpp
37 | Product = Debug/calc
38 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__32BIT__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
39 | CXXFlags = $(CFlags) -fno-rtti
40 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
41 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
42 | CompileCXX = @$(CXX) $<
43 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
44 | Link = @g++ $(LibDir) -o $(Product)
45 | CheckLink = @ldd -u -r $(Product); echo
46 |
47 | LD_LIBRARY_PATH += :$(ProductDir)
48 | endif
49 |
50 | #
51 | # Making...
52 | #
53 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
54 |
55 | $(ProductDir) :
56 | @mkdir -p $(ProductDir)
57 |
58 | ifneq ($(ProductDir),$(ObjectDir))
59 | $(ObjectDir) :
60 | @mkdir -p $(ObjectDir)
61 | endif
62 |
63 | clean :
64 | @rm -f $(ObjectDir)/*.o
65 | @rm -f $(Product)
66 |
67 | StartMake :
68 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
69 | ifeq ($(ForceLink),1)
70 | @rm -f $(Product)
71 | endif
72 |
73 | EndMake :
74 | @echo ">>> Success <<<"
75 |
76 | #
77 | # Source Files, Objects & Product
78 | #
79 | $(ObjectDir)/Calc.o : \
80 | Calc.cpp
81 | @echo "---> Compiling" $< "..."
82 | $(CompileCXX)
83 |
84 |
85 | Objects = \
86 | $(ObjectDir)/Calc.o
87 |
88 | $(Product) : $(Objects) $(Libs)
89 | @echo "---> Creating" $@ "..."
90 | @rm -f $@
91 | $(Link) $(Objects) $(Libraries)
92 | $(CheckLink)
93 |
94 |
--------------------------------------------------------------------------------
/examples/boost-lambda/calc/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/boost-lambda/calc/calc.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../../tpl/include
3 | ../../../../boost
4 | ../../../../boostmm
5 |
6 | [Config Release]
7 | Product Exe Release/calc
8 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
9 | ObjDir Release
10 | LibDir
11 | Libraries
12 |
13 | [Config Debug]
14 | Product Exe Debug/calc
15 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception
16 | ObjDir Debug
17 | LibDir
18 | Libraries
19 |
20 | [Source]
21 | Calc.cpp
22 |
23 |
--------------------------------------------------------------------------------
/examples/boost-lambda/print/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../../tpl/include -I../../../../boost -I../../../../boostmm
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/test
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__32BIT__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -o $(Product)
25 | CheckLink = @ldd -u -r $(Product); echo
26 |
27 | LD_LIBRARY_PATH += :$(ProductDir)
28 | endif
29 |
30 | #
31 | # Configuration Debug
32 | #
33 | ifeq ($(CFG), Debug)
34 | ProductDir = Debug
35 | ObjectDir = Debug
36 | MocFile = $(ObjectDir)/temp.moc.cpp
37 | Product = Debug/test
38 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__32BIT__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
39 | CXXFlags = $(CFlags) -fno-rtti
40 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
41 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
42 | CompileCXX = @$(CXX) $<
43 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
44 | Link = @g++ $(LibDir) -o $(Product)
45 | CheckLink = @ldd -u -r $(Product); echo
46 |
47 | LD_LIBRARY_PATH += :$(ProductDir)
48 | endif
49 |
50 | #
51 | # Making...
52 | #
53 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
54 |
55 | $(ProductDir) :
56 | @mkdir -p $(ProductDir)
57 |
58 | ifneq ($(ProductDir),$(ObjectDir))
59 | $(ObjectDir) :
60 | @mkdir -p $(ObjectDir)
61 | endif
62 |
63 | clean :
64 | @rm -f $(ObjectDir)/*.o
65 | @rm -f $(Product)
66 |
67 | StartMake :
68 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
69 | ifeq ($(ForceLink),1)
70 | @rm -f $(Product)
71 | endif
72 |
73 | EndMake :
74 | @echo ">>> Success <<<"
75 |
76 | #
77 | # Source Files, Objects & Product
78 | #
79 | $(ObjectDir)/Simplest.o : \
80 | ./Simplest.cpp
81 | @echo "---> Compiling" $< "..."
82 | $(CompileCXX)
83 |
84 |
85 | Objects = \
86 | $(ObjectDir)/Simplest.o
87 |
88 | $(Product) : $(Objects) $(Libs)
89 | @echo "---> Creating" $@ "..."
90 | @rm -f $@
91 | $(Link) $(Objects) $(Libraries)
92 | $(CheckLink)
93 |
94 |
--------------------------------------------------------------------------------
/examples/boost-lambda/print/Simplest.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | using namespace tpl;
6 | using namespace boost::lambda;
7 |
8 | int main()
9 | {
10 | Lambda exec;
11 | "-.1 -0.1 +32. -22323.2e+12" >> real()/exec[std::cout << _1 << constant('\n')] % ws();
12 | return 0;
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/examples/boost-lambda/print/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/boost-lambda/print/print.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../../tpl/include
3 | ../../../../boost
4 | ../../../../boostmm
5 |
6 | [Config Release]
7 | Product Exe Release/test
8 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
9 | ObjDir Release
10 | LibDir
11 | Libraries
12 |
13 | [Config Debug]
14 | Product Exe Debug/test
15 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception
16 | ObjDir Debug
17 | LibDir
18 | Libraries
19 |
20 | [Source]
21 | *.cpp
22 |
23 |
--------------------------------------------------------------------------------
/examples/boost-phoenix/calc/Calc.cpp:
--------------------------------------------------------------------------------
1 | #define TPL_USE_AUTO_ALLOC
2 | #include // std::cout
3 | #include
4 | #include
5 |
6 | using namespace tpl;
7 | using namespace phoenix;
8 |
9 | int main()
10 | {
11 | typedef SimpleImplementation impl;
12 |
13 | // ---- define rules ----
14 |
15 | impl::Allocator alloc;
16 |
17 | Phoenix calc;
18 | Phoenix<> exec;
19 |
20 | TPL_PHOENIX_LOCAL(double, term);
21 | TPL_PHOENIX_LOCAL(double, factor);
22 |
23 | impl::Rule rTerm( alloc,
24 | real()/assign(factor) + *(
25 | '*' + real()/calc[factor *= arg1] |
26 | '/' + real()/calc[factor /= arg1] )
27 | );
28 |
29 | impl::Rule rExpr( alloc,
30 | rTerm/exec[term = factor] + *(
31 | '+' + rTerm/exec[term += factor] |
32 | '-' + rTerm/exec[term -= factor] )
33 | );
34 |
35 | // ---- do match ----
36 |
37 | for (;;)
38 | {
39 | std::string strExp;
40 | std::cout << "input an expression (q to quit): ";
41 | std::getline(std::cin, strExp);
42 |
43 | if (strExp == "q")
44 | break;
45 |
46 | if (!impl::match(strExp.c_str(), rExpr + eos()))
47 | std::cout << "invalid expression!\n";
48 | else
49 | std::cout << term() << "\n";
50 | }
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/examples/boost-phoenix/calc/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../../tpl/include -I../../../../boost -I../../../../boostmm
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/calc
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__32BIT__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti -Wall
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -o $(Product)
25 | CheckLink = @ldd -u -r $(Product); echo
26 |
27 | LD_LIBRARY_PATH += :$(ProductDir)
28 | endif
29 |
30 | #
31 | # Configuration Debug
32 | #
33 | ifeq ($(CFG), Debug)
34 | ProductDir = Debug
35 | ObjectDir = Debug
36 | MocFile = $(ObjectDir)/temp.moc.cpp
37 | Product = Debug/calc
38 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__32BIT__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
39 | CXXFlags = $(CFlags) -fno-rtti -Wall
40 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
41 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
42 | CompileCXX = @$(CXX) $<
43 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
44 | Link = @g++ $(LibDir) -o $(Product)
45 | CheckLink = @ldd -u -r $(Product); echo
46 |
47 | LD_LIBRARY_PATH += :$(ProductDir)
48 | endif
49 |
50 | #
51 | # Making...
52 | #
53 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
54 |
55 | $(ProductDir) :
56 | @mkdir -p $(ProductDir)
57 |
58 | ifneq ($(ProductDir),$(ObjectDir))
59 | $(ObjectDir) :
60 | @mkdir -p $(ObjectDir)
61 | endif
62 |
63 | clean :
64 | @rm -f $(ObjectDir)/*.o
65 | @rm -f $(Product)
66 |
67 | StartMake :
68 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
69 | ifeq ($(ForceLink),1)
70 | @rm -f $(Product)
71 | endif
72 |
73 | EndMake :
74 | @echo ">>> Success <<<"
75 |
76 | #
77 | # Source Files, Objects & Product
78 | #
79 | $(ObjectDir)/Calc.o : \
80 | Calc.cpp
81 | @echo "---> Compiling" $< "..."
82 | $(CompileCXX)
83 |
84 |
85 | Objects = \
86 | $(ObjectDir)/Calc.o
87 |
88 | $(Product) : $(Objects) $(Libs)
89 | @echo "---> Creating" $@ "..."
90 | @rm -f $@
91 | $(Link) $(Objects) $(Libraries)
92 | $(CheckLink)
93 |
94 |
--------------------------------------------------------------------------------
/examples/boost-phoenix/calc/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/boost-phoenix/calc/calc.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../../tpl/include
3 | ../../../../boost
4 | ../../../../boostmm
5 |
6 | [Config Release]
7 | Product Exe Release/calc
8 | Options Release; MultiThread; AnsiChar; NoRtti; Exception; WarningAll
9 | ObjDir Release
10 | LibDir
11 | Libraries
12 |
13 | [Config Debug]
14 | Product Exe Debug/calc
15 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception; WarningAll
16 | ObjDir Debug
17 | LibDir
18 | Libraries
19 |
20 | [Source]
21 | Calc.cpp
22 |
23 |
--------------------------------------------------------------------------------
/examples/boost-phoenix/print/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../../tpl/include -I../../../../boost -I../../../../boostmm
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/test
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__32BIT__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -o $(Product)
25 | CheckLink = @ldd -u -r $(Product); echo
26 |
27 | LD_LIBRARY_PATH += :$(ProductDir)
28 | endif
29 |
30 | #
31 | # Configuration Debug
32 | #
33 | ifeq ($(CFG), Debug)
34 | ProductDir = Debug
35 | ObjectDir = Debug
36 | MocFile = $(ObjectDir)/temp.moc.cpp
37 | Product = Debug/test
38 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__32BIT__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
39 | CXXFlags = $(CFlags) -fno-rtti
40 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
41 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
42 | CompileCXX = @$(CXX) $<
43 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
44 | Link = @g++ $(LibDir) -o $(Product)
45 | CheckLink = @ldd -u -r $(Product); echo
46 |
47 | LD_LIBRARY_PATH += :$(ProductDir)
48 | endif
49 |
50 | #
51 | # Making...
52 | #
53 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
54 |
55 | $(ProductDir) :
56 | @mkdir -p $(ProductDir)
57 |
58 | ifneq ($(ProductDir),$(ObjectDir))
59 | $(ObjectDir) :
60 | @mkdir -p $(ObjectDir)
61 | endif
62 |
63 | clean :
64 | @rm -f $(ObjectDir)/*.o
65 | @rm -f $(Product)
66 |
67 | StartMake :
68 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
69 | ifeq ($(ForceLink),1)
70 | @rm -f $(Product)
71 | endif
72 |
73 | EndMake :
74 | @echo ">>> Success <<<"
75 |
76 | #
77 | # Source Files, Objects & Product
78 | #
79 | $(ObjectDir)/Simplest.o : \
80 | ./Simplest.cpp
81 | @echo "---> Compiling" $< "..."
82 | $(CompileCXX)
83 |
84 |
85 | Objects = \
86 | $(ObjectDir)/Simplest.o
87 |
88 | $(Product) : $(Objects) $(Libs)
89 | @echo "---> Creating" $@ "..."
90 | @rm -f $@
91 | $(Link) $(Objects) $(Libraries)
92 | $(CheckLink)
93 |
94 |
--------------------------------------------------------------------------------
/examples/boost-phoenix/print/Simplest.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | using namespace tpl;
6 | using namespace phoenix;
7 |
8 | int main()
9 | {
10 | Phoenix exec;
11 | "-.1 -0.1 +32. -22323.2e+12" >> real()/exec[std::cout << arg1 << const_('\n')] % ws();
12 | return 0;
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/examples/boost-phoenix/print/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/boost-phoenix/print/print.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../../tpl/include
3 | ../../../../boost
4 | ../../../../boostmm
5 |
6 | [Config Release]
7 | Product Exe Release/test
8 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
9 | ObjDir Release
10 | LibDir
11 | Libraries
12 |
13 | [Config Debug]
14 | Product Exe Debug/test
15 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception
16 | ObjDir Debug
17 | LibDir
18 | Libraries
19 |
20 | [Source]
21 | *.cpp
22 |
23 |
--------------------------------------------------------------------------------
/examples/calculator/Calc.cpp:
--------------------------------------------------------------------------------
1 | #define TPL_USE_AUTO_ALLOC
2 | #include // sin, cos, pow
3 | #include // std::deque
4 | #include // std::cout
5 | #include // std::plus, std::minus, etc
6 | #include // std::max_element
7 | #include
8 |
9 | using namespace tpl;
10 |
11 | double max_value(const double x[], int count)
12 | {
13 | return *std::max_element(x, x+count);
14 | }
15 |
16 | void calculator(const char* szExpr)
17 | {
18 | typedef SimpleImplementation impl;
19 |
20 | // ---- define rules ----
21 |
22 | std::deque stk;
23 |
24 | impl::Grammar::Var rFactor;
25 |
26 | impl::Grammar rTerm =
27 | rFactor + *(
28 | '*' + rFactor/calc(stk) |
29 | '/' + rFactor/calc(stk) );
30 |
31 | impl::Grammar rExpr =
32 | rTerm + *(
33 | '+' + rTerm/calc(stk) |
34 | '-' + rTerm/calc(stk) );
35 |
36 | int arity;
37 | impl::Rule rFun =
38 | "sin"/calc(stk, sin, arity) | "cos"/calc(stk, cos, arity) |
39 | "pow"/calc(stk, pow, arity) | "max"/calc(stk, max_value, arity);
40 |
41 | rFactor =
42 | real()/append(stk) |
43 | '-' + rFactor/calc(stk) |
44 | '(' + rExpr + ')' |
45 | (gr(c_symbol()) + '(' + rExpr % ','/assign(arity) + ')')/(gr(rFun) + '(') |
46 | '+' + rFactor;
47 |
48 | // ---- do match ----
49 |
50 | try {
51 | if ( szExpr != skipws_[rExpr] )
52 | std::cerr << ">>> ERROR: invalid expression!\n";
53 | else
54 | std::cout << stk.back() << '\n';
55 | }
56 | catch (const std::logic_error& e) {
57 | std::cerr << ">>> ERROR: " << e.what() << '\n';
58 | }
59 | }
60 |
61 | int main(int argc, const char* argv[])
62 | {
63 | if (argc == 2) {
64 | calculator(argv[1]);
65 | return 0;
66 | }
67 | else {
68 | for (;;)
69 | {
70 | std::string strExp;
71 | std::cout << "input an expression (q to quit): ";
72 | if (!std::getline(std::cin, strExp) || strExp == "q") {
73 | std::cout << '\n';
74 | return 0;
75 | }
76 | calculator(strExp.c_str());
77 | }
78 | }
79 | }
80 |
81 |
--------------------------------------------------------------------------------
/examples/calculator/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include -I../../../boost
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/calc
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -ldl -o $(Product)
25 | LD_LIBRARY_PATH += :$(ProductDir)
26 | endif
27 |
28 | #
29 | # Configuration Debug
30 | #
31 | ifeq ($(CFG), Debug)
32 | ProductDir = Debug
33 | ObjectDir = Debug
34 | MocFile = $(ObjectDir)/temp.moc.cpp
35 | Product = Debug/calc
36 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
37 | CXXFlags = $(CFlags) -fno-rtti
38 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @$(CXX) $<
41 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
42 | Link = @g++ $(LibDir) -ldl -o $(Product)
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/Calc.o : \
76 | Calc.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 |
81 | Objects = \
82 | $(ObjectDir)/Calc.o
83 |
84 | $(Product) : $(Objects) $(Libs)
85 | @echo "---> Creating" $@ "..."
86 | @rm -f $@
87 | $(Link) $(Objects) $(Libraries)
88 | $(CheckLink)
89 |
90 |
--------------------------------------------------------------------------------
/examples/calculator/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/calculator/calculator.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../tpl/include
3 | ../../../boost
4 | ../../../boostmm
5 |
6 | [Config Release]
7 | Product Exe Release/exp
8 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
9 | ObjDir Release
10 | LibDir
11 | Libraries
12 |
13 | [Config Debug]
14 | Product Exe Debug/exp
15 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception
16 | ObjDir Debug
17 | LibDir
18 | Libraries
19 |
20 | [Source]
21 | Calc.cpp
22 |
23 |
--------------------------------------------------------------------------------
/examples/calculator/readme.txt:
--------------------------------------------------------------------------------
1 | + Introduction
2 |
3 | This application is a simple calculator. It supports:
4 |
5 | ++ REAL REAL
6 |
7 | Here can be: operator+, operator-, operator*, operator/.
8 | And here REAL can be any expression that return a real number.
9 |
10 | ++ REAL
11 |
12 | Here can be unary operator+, unary operator-.
13 |
14 | ++ (REAL)
15 |
16 | Yes, the calculator supports ().
17 |
18 | ++ sin(REAL), cos(REAL), pow(REAL, REAL), max(REAL, ...)
19 |
20 | The calculator support sin, cos, pow, max functions.
21 | Note that max function has variable arity.
22 |
23 | + Examples
24 |
25 | Exp: 4 * -(3 + 2)
26 | Result: -20
27 |
28 | Exp: max(1, 2, pow(3,2), pow(2,3))
29 | Result: 9
30 |
31 |
--------------------------------------------------------------------------------
/examples/circuit/Circuit.cpp:
--------------------------------------------------------------------------------
1 | #define TPL_USE_AUTO_ALLOC
2 | #include // std::cout
3 | #include
4 |
5 | using namespace tpl;
6 |
7 | // -------------------------------------------------------------------------
8 | // circuit
9 |
10 | // Note:
11 | // if two rules A, B circularly refer to each other (or a rule A refer to itself),
12 | // we need use Rule::Var to break the circuit.
13 |
14 | int main()
15 | {
16 | typedef simple impl;
17 |
18 | // ---- define rules ----
19 |
20 | impl::Allocator alloc;
21 |
22 | std::vector values;
23 |
24 | impl::Rule::Var rDoc;
25 | rDoc.assign( alloc, integer()/append(values) + !(',' + rDoc) );
26 |
27 | // This is only an example. A better way to do the same thing is:
28 | // rDoc.assign( alloc, integer()/append(values) % ',' );
29 |
30 | // ---- do match ----
31 |
32 | if ("10,97,37" >> rDoc) {
33 | for (std::vector::const_iterator it = values.begin(); it != values.end(); ++it) {
34 | std::cout << *it << "\n";
35 | }
36 | }
37 | return 0;
38 | }
39 |
40 | // -------------------------------------------------------------------------
41 |
42 |
--------------------------------------------------------------------------------
/examples/circuit/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include -I../../../boost -I../../../boostmm
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/circuit
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__32BIT__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -ldl -o $(Product)
25 | LD_LIBRARY_PATH += :$(ProductDir)
26 | endif
27 |
28 | #
29 | # Configuration Debug
30 | #
31 | ifeq ($(CFG), Debug)
32 | ProductDir = Debug
33 | ObjectDir = Debug
34 | MocFile = $(ObjectDir)/temp.moc.cpp
35 | Product = Debug/circuit
36 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__32BIT__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
37 | CXXFlags = $(CFlags) -frtti
38 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @$(CXX) $<
41 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
42 | Link = @g++ $(LibDir) -ldl -o $(Product)
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/Circuit.o : \
76 | Circuit.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 |
81 | Objects = \
82 | $(ObjectDir)/Circuit.o
83 |
84 | $(Product) : $(Objects) $(Libs)
85 | @echo "---> Creating" $@ "..."
86 | @rm -f $@
87 | $(Link) $(Objects) $(Libraries)
88 | $(CheckLink)
89 |
90 |
--------------------------------------------------------------------------------
/examples/circuit/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/circuit/circuit.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../tpl/include
3 | ../../../boost
4 | ../../../boostmm
5 |
6 | [Config Release]
7 | Product Exe Release/circuit
8 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
9 | ObjDir Release
10 | LibDir
11 | Libraries
12 |
13 | [Config Debug]
14 | Product Exe Debug/circuit
15 | Options Debug; MultiThread; AnsiChar; Rtti; Exception
16 | ObjDir Debug
17 | LibDir
18 | Libraries
19 |
20 | [Source]
21 | Circuit.cpp
22 |
23 |
--------------------------------------------------------------------------------
/examples/emulator/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include -I../../../boost
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/emu
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -ldl -o $(Product)
25 | LD_LIBRARY_PATH += :$(ProductDir)
26 | endif
27 |
28 | #
29 | # Configuration Debug
30 | #
31 | ifeq ($(CFG), Debug)
32 | ProductDir = Debug
33 | ObjectDir = Debug
34 | MocFile = $(ObjectDir)/temp.moc.cpp
35 | Product = Debug/emu
36 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
37 | CXXFlags = $(CFlags) -fno-rtti
38 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @$(CXX) $<
41 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
42 | Link = @g++ $(LibDir) -ldl -o $(Product)
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/Emulator.o : \
76 | Emulator.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 |
81 | Objects = \
82 | $(ObjectDir)/Emulator.o
83 |
84 | $(Product) : $(Objects) $(Libs)
85 | @echo "---> Creating" $@ "..."
86 | @rm -f $@
87 | $(Link) $(Objects) $(Libraries)
88 | $(CheckLink)
89 |
90 |
--------------------------------------------------------------------------------
/examples/emulator/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/emulator/emulator.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../tpl/include
3 | ../../../boost
4 | ../../../boostmm
5 |
6 | [Config Release]
7 | Product Exe Release/emu
8 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
9 | ObjDir Release
10 | LibDir
11 | Libraries
12 |
13 | [Config Debug]
14 | Product Exe Debug/emu
15 | Options Debug; MultiThread; AnsiChar; Rtti; Exception
16 | ObjDir Debug
17 | LibDir
18 | Libraries
19 |
20 | [Source]
21 | Emulator.cpp
22 |
23 |
--------------------------------------------------------------------------------
/examples/grammar/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/grammar
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -ldl -o $(Product)
25 | LD_LIBRARY_PATH += :$(ProductDir)
26 | endif
27 |
28 | #
29 | # Configuration Debug
30 | #
31 | ifeq ($(CFG), Debug)
32 | ProductDir = Debug
33 | ObjectDir = Debug
34 | MocFile = $(ObjectDir)/temp.moc.cpp
35 | Product = Debug/grammar
36 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
37 | CXXFlags = $(CFlags) -fno-rtti
38 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @$(CXX) $<
41 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
42 | Link = @g++ $(LibDir) -ldl -o $(Product)
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/SimpleGrammar.o : \
76 | SimpleGrammar.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 |
81 | Objects = \
82 | $(ObjectDir)/SimpleGrammar.o
83 |
84 | $(Product) : $(Objects) $(Libs)
85 | @echo "---> Creating" $@ "..."
86 | @rm -f $@
87 | $(Link) $(Objects) $(Libraries)
88 | $(CheckLink)
89 |
90 |
--------------------------------------------------------------------------------
/examples/grammar/SimpleGrammar.cpp:
--------------------------------------------------------------------------------
1 | #include // std::vector
2 | #include // std::cout
3 | #include
4 |
5 | using namespace tpl;
6 |
7 | // -------------------------------------------------------------------------
8 | // simple_grammar
9 |
10 | // A simple grammar example.
11 |
12 | // What we use:
13 | // * Rules: /append(), %, real(), gr(','), skipws()
14 | // * Matching: tpl::simple::match()
15 |
16 | int main()
17 | {
18 | std::vector values; // you can change vector to other stl containers.
19 |
20 | if ( simple::match(" -.1 , -0.1 , +32. , -22323.2e+12 ", real()/append(values) % gr(','), skipws()) )
21 | {
22 | for (std::vector::iterator it = values.begin(); it != values.end(); ++it)
23 | {
24 | std::cout << *it << "\n";
25 | }
26 | }
27 | return 0;
28 | }
29 |
30 | // -------------------------------------------------------------------------
31 |
32 |
--------------------------------------------------------------------------------
/examples/grammar/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/grammar/grammar.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../tpl/include
3 |
4 | [Config Release]
5 | Product Exe Release/grammar
6 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
7 | ObjDir Release
8 | LibDir
9 | Libraries
10 |
11 | [Config Debug]
12 | Product Exe Debug/grammar
13 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception
14 | ObjDir Debug
15 | LibDir
16 | Libraries
17 |
18 | [Source]
19 | SimpleGrammar.cpp
20 |
21 |
--------------------------------------------------------------------------------
/examples/grammar2/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/grammar
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -ldl -o $(Product)
25 | LD_LIBRARY_PATH += :$(ProductDir)
26 | endif
27 |
28 | #
29 | # Configuration Debug
30 | #
31 | ifeq ($(CFG), Debug)
32 | ProductDir = Debug
33 | ObjectDir = Debug
34 | MocFile = $(ObjectDir)/temp.moc.cpp
35 | Product = Debug/grammar
36 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
37 | CXXFlags = $(CFlags) -fno-rtti
38 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @$(CXX) $<
41 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
42 | Link = @g++ $(LibDir) -ldl -o $(Product)
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/SimpleGrammar.o : \
76 | SimpleGrammar.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 |
81 | Objects = \
82 | $(ObjectDir)/SimpleGrammar.o
83 |
84 | $(Product) : $(Objects) $(Libs)
85 | @echo "---> Creating" $@ "..."
86 | @rm -f $@
87 | $(Link) $(Objects) $(Libraries)
88 | $(CheckLink)
89 |
90 |
--------------------------------------------------------------------------------
/examples/grammar2/SimpleGrammar.cpp:
--------------------------------------------------------------------------------
1 | #include // std::vector
2 | #include // std::cout
3 | #include
4 |
5 | using namespace tpl;
6 |
7 | // -------------------------------------------------------------------------
8 | // simple_grammar
9 |
10 | // A simple grammar example.
11 |
12 | // What we use:
13 | // * Rules: /append(), %, real(), gr(','), skipws()
14 | // * Matching: operator>>
15 |
16 | int main()
17 | {
18 | std::vector values; // you can change vector to other stl containers.
19 |
20 | if ( " -.1 , -0.1 , +32. , -22323.2e+12 " >> skipws_[real()/append(values) % gr(',')] )
21 | {
22 | for (std::vector::iterator it = values.begin(); it != values.end(); ++it)
23 | {
24 | std::cout << *it << "\n";
25 | }
26 | }
27 | return 0;
28 | }
29 |
30 | // -------------------------------------------------------------------------
31 |
32 |
--------------------------------------------------------------------------------
/examples/grammar2/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/grammar2/grammar2.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../tpl/include
3 |
4 | [Config Release]
5 | Product Exe Release/grammar
6 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
7 | ObjDir Release
8 | LibDir
9 | Libraries
10 |
11 | [Config Debug]
12 | Product Exe Debug/grammar
13 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception
14 | ObjDir Debug
15 | LibDir
16 | Libraries
17 |
18 | [Source]
19 | SimpleGrammar.cpp
20 |
21 |
--------------------------------------------------------------------------------
/examples/htmltext/HtmlText.cpp:
--------------------------------------------------------------------------------
1 | #include // std::vector
2 | #include // std::cout
3 | #include
4 | #include
5 |
6 | using namespace tpl;
7 |
8 | // -------------------------------------------------------------------------
9 | // htmltext
10 |
11 | int main()
12 | {
13 | int nPre = 0;
14 | std::vector text;
15 |
16 | const char html[] = " \tHello,\t\t world!\t\t!
abc !!";
17 |
18 | html >> *(
19 | '<' +
20 | (
21 | html_symbol() // $tag-start$
22 | [
23 | case_(eqICase("pre"))/inc(nPre),
24 | true
25 | ] + find('>') |
26 | (
27 | '/' +
28 | html_symbol() // $tag-end$
29 | [
30 | case_(eqICase("pre"))/dec(nPre),
31 | true
32 | ] +
33 | '>'
34 | ) |
35 | done() // invalid grammar!
36 | ) |
37 | switch_(nPre) // $text$
38 | [
39 | case_(0) // nPre == 0
40 | [
41 | html_skipws() +
42 | find('<' | html_space())/append(text) +
43 | !( html_ws()/append(text, " ") )
44 | ],
45 | default_() // nPre != 0
46 | [
47 | find('<')/append(text)
48 | ]
49 | ] );
50 |
51 | for (std::vector::iterator it = text.begin(); it != text.end(); ++it) {
52 | std::cout << *it;
53 | }
54 | std::cout << '\n';
55 | return 0;
56 | }
57 |
58 | // -------------------------------------------------------------------------
59 |
60 |
--------------------------------------------------------------------------------
/examples/htmltext/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/htmltext
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__32BIT__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -o $(Product)
25 | CheckLink = @ldd -u -r $(Product); echo
26 |
27 | LD_LIBRARY_PATH += :$(ProductDir)
28 | endif
29 |
30 | #
31 | # Configuration Debug
32 | #
33 | ifeq ($(CFG), Debug)
34 | ProductDir = Debug
35 | ObjectDir = Debug
36 | MocFile = $(ObjectDir)/temp.moc.cpp
37 | Product = Debug/htmltext
38 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__32BIT__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
39 | CXXFlags = $(CFlags) -fno-rtti
40 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
41 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
42 | CompileCXX = @$(CXX) $<
43 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
44 | Link = @g++ $(LibDir) -o $(Product)
45 | CheckLink = @ldd -u -r $(Product); echo
46 |
47 | LD_LIBRARY_PATH += :$(ProductDir)
48 | endif
49 |
50 | #
51 | # Making...
52 | #
53 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
54 |
55 | $(ProductDir) :
56 | @mkdir -p $(ProductDir)
57 |
58 | ifneq ($(ProductDir),$(ObjectDir))
59 | $(ObjectDir) :
60 | @mkdir -p $(ObjectDir)
61 | endif
62 |
63 | clean :
64 | @rm -f $(ObjectDir)/*.o
65 | @rm -f $(Product)
66 |
67 | StartMake :
68 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
69 | ifeq ($(ForceLink),1)
70 | @rm -f $(Product)
71 | endif
72 |
73 | EndMake :
74 | @echo ">>> Success <<<"
75 |
76 | #
77 | # Source Files, Objects & Product
78 | #
79 | $(ObjectDir)/HtmlText.o : \
80 | HtmlText.cpp
81 | @echo "---> Compiling" $< "..."
82 | $(CompileCXX)
83 |
84 |
85 | Objects = \
86 | $(ObjectDir)/HtmlText.o
87 |
88 | $(Product) : $(Objects) $(Libs)
89 | @echo "---> Creating" $@ "..."
90 | @rm -f $@
91 | $(Link) $(Objects) $(Libraries)
92 | $(CheckLink)
93 |
94 |
--------------------------------------------------------------------------------
/examples/htmltext/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/htmltext/htmltext.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../tpl/include
3 | ../../../boostmm
4 |
5 | [Config Release]
6 | Product Exe Release/htmltext
7 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
8 | ObjDir Release
9 | LibDir
10 | Libraries
11 |
12 | [Config Debug]
13 | Product Exe Debug/htmltext
14 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception
15 | ObjDir Debug
16 | LibDir
17 | Libraries
18 |
19 | [Source]
20 | HtmlText.cpp
21 |
22 |
--------------------------------------------------------------------------------
/examples/includefiles/IncludeFiles.cpp:
--------------------------------------------------------------------------------
1 | #include // std::vector
2 | #include // std::cout
3 | #include
4 | #include
5 | /* is */ # /* this */ include /* supported? *//*
6 | no problem! */ "stdext/FileBuf.h"
7 |
8 | using namespace tpl;
9 |
10 | // -------------------------------------------------------------------------
11 | // list include files
12 |
13 | #define LIST_INC_STDFILE \
14 | ('<' + find('>')/append(result) + '>')
15 |
16 | #define LIST_INC_FILE \
17 | ('\"' + find('\"')/append(result) + '\"')
18 |
19 | #define LIST_INC \
20 | gr(LIST_INC_STDFILE | LIST_INC_FILE)
21 |
22 | #define LIST_GRAMMAR \
23 | *(!(gr('#') + "include" + LIST_INC) + find_strict_eol())
24 |
25 | int main()
26 | {
27 | std::vector result;
28 |
29 | const std::FileBuf file(__FILE__);
30 | file >> c_skip_non_eol_[LIST_GRAMMAR];
31 |
32 | for (std::vector::iterator it = result.begin(); it != result.end(); ++it)
33 | std::cout << *it << '\n';
34 | return 0;
35 | }
36 |
37 | // -------------------------------------------------------------------------
38 |
39 |
--------------------------------------------------------------------------------
/examples/includefiles/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include -I../../../stdext/include
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/includefiles
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -ldl -o $(Product)
25 | LD_LIBRARY_PATH += :$(ProductDir)
26 | endif
27 |
28 | #
29 | # Configuration Debug
30 | #
31 | ifeq ($(CFG), Debug)
32 | ProductDir = Debug
33 | ObjectDir = Debug
34 | MocFile = $(ObjectDir)/temp.moc.cpp
35 | Product = Debug/includefiles
36 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
37 | CXXFlags = $(CFlags) -fno-rtti
38 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @$(CXX) $<
41 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
42 | Link = @g++ $(LibDir) -ldl -o $(Product)
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/IncludeFiles.o : \
76 | IncludeFiles.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 |
81 | Objects = \
82 | $(ObjectDir)/IncludeFiles.o
83 |
84 | $(Product) : $(Objects) $(Libs)
85 | @echo "---> Creating" $@ "..."
86 | @rm -f $@
87 | $(Link) $(Objects) $(Libraries)
88 | $(CheckLink)
89 |
90 |
--------------------------------------------------------------------------------
/examples/includefiles/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/includefiles/includefiles.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../tpl/include
3 | ../../../stdext/include
4 | ../../../boostmm
5 |
6 | [Config Release]
7 | Product Exe Release/includefiles
8 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
9 | ObjDir Release
10 | LibDir
11 | Libraries
12 |
13 | [Config Debug]
14 | Product Exe Debug/includefiles
15 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception
16 | ObjDir Debug
17 | LibDir
18 | Libraries
19 |
20 | [Source]
21 | IncludeFiles.cpp
22 |
23 |
--------------------------------------------------------------------------------
/examples/json-print/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/simplest
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -ldl -o $(Product)
25 | LD_LIBRARY_PATH += :$(ProductDir)
26 | endif
27 |
28 | #
29 | # Configuration Debug
30 | #
31 | ifeq ($(CFG), Debug)
32 | ProductDir = Debug
33 | ObjectDir = Debug
34 | MocFile = $(ObjectDir)/temp.moc.cpp
35 | Product = Debug/simplest
36 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
37 | CXXFlags = $(CFlags) -fno-rtti
38 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @$(CXX) $<
41 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
42 | Link = @g++ $(LibDir) -ldl -o $(Product)
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/Simplest.o : \
76 | Simplest.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 |
81 | Objects = \
82 | $(ObjectDir)/Simplest.o
83 |
84 | $(Product) : $(Objects) $(Libs)
85 | @echo "---> Creating" $@ "..."
86 | @rm -f $@
87 | $(Link) $(Objects) $(Libraries)
88 | $(CheckLink)
89 |
90 |
--------------------------------------------------------------------------------
/examples/json-print/Simplest.cpp:
--------------------------------------------------------------------------------
1 | #define TPL_USE_AUTO_ALLOC
2 | #include
3 | #include
4 |
5 | using namespace tpl;
6 |
7 | // -------------------------------------------------------------------------
8 | // json print
9 |
10 | // A json print example.
11 |
12 | int main()
13 | {
14 | typedef DOM<> dom;
15 |
16 | const char source[] = "class Foo : public Base1, Base2 {};";
17 |
18 | dom::Mark tagName("name");
19 | dom::NodeMark tagBase("base", true);
20 | dom::Mark tagAccess("access");
21 | //dom::Mark tagName("name");
22 |
23 | dom::Allocator alloc;
24 | dom::Document doc(alloc);
25 |
26 | if (
27 | source >> cpp_skip_
28 | [
29 | gr(c_symbol()/eq("class")) + c_symbol()/tagName + ':' +
30 | (
31 | !gr(c_symbol()/(eq("public")||eq("private"))/tagAccess) + c_symbol()/tagName
32 | )/tagBase % ',' +
33 | '{' + '}' + ';'
34 | ]/doc
35 | )
36 | {
37 | std::OutputLog log;
38 | json_print(alloc, log, doc);
39 | }
40 | return 0;
41 | }
42 |
43 | // -------------------------------------------------------------------------
44 |
45 |
--------------------------------------------------------------------------------
/examples/json-print/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/json-print/json-print.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../tpl/include
3 |
4 | [Config Release]
5 | Product Exe Release/simplest
6 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
7 | ObjDir Release
8 | LibDir
9 | Libraries
10 |
11 | [Config Debug]
12 | Product Exe Debug/simplest
13 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception
14 | ObjDir Debug
15 | LibDir
16 | Libraries
17 |
18 | [Source]
19 | Simplest.cpp
20 |
21 |
--------------------------------------------------------------------------------
/examples/json-print2/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/simplest
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -ldl -o $(Product)
25 | LD_LIBRARY_PATH += :$(ProductDir)
26 | endif
27 |
28 | #
29 | # Configuration Debug
30 | #
31 | ifeq ($(CFG), Debug)
32 | ProductDir = Debug
33 | ObjectDir = Debug
34 | MocFile = $(ObjectDir)/temp.moc.cpp
35 | Product = Debug/simplest
36 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
37 | CXXFlags = $(CFlags) -fno-rtti
38 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @$(CXX) $<
41 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
42 | Link = @g++ $(LibDir) -ldl -o $(Product)
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/Simplest.o : \
76 | Simplest.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 |
81 | Objects = \
82 | $(ObjectDir)/Simplest.o
83 |
84 | $(Product) : $(Objects) $(Libs)
85 | @echo "---> Creating" $@ "..."
86 | @rm -f $@
87 | $(Link) $(Objects) $(Libraries)
88 | $(CheckLink)
89 |
90 |
--------------------------------------------------------------------------------
/examples/json-print2/Simplest.cpp:
--------------------------------------------------------------------------------
1 | #define TPL_USE_AUTO_ALLOC
2 | #include
3 | #include
4 |
5 | using namespace tpl;
6 |
7 | // -------------------------------------------------------------------------
8 | // json print
9 |
10 | // A json print example.
11 |
12 | int main()
13 | {
14 | typedef DOM<> dom;
15 |
16 | const char source[] = "\
17 | class Foo // Foo comment\n\
18 | : public Base1, Base2\n\
19 | {};\
20 | ";
21 |
22 | dom::Mark tagName("name");
23 | dom::NodeMark tagBase("base", true);
24 | dom::Mark tagAccess("access");
25 | //dom::Mark tagName("name");
26 |
27 | dom::Allocator alloc;
28 | dom::Document doc(alloc);
29 |
30 | source >> cpp_skip_
31 | [
32 | gr(c_symbol()/eq("class")) + c_symbol()/tagName +
33 | !(':' +
34 | (
35 | !gr(c_symbol()/eq("public")/tagAccess) +
36 | c_symbol()/tagName
37 | )/tagBase % ','
38 | ) +
39 | '{' + '}' + ';'
40 | ]/doc;
41 |
42 | std::OutputLog log;
43 | json_print(alloc, log, doc);
44 | return 0;
45 | }
46 |
47 | // -------------------------------------------------------------------------
48 |
49 |
--------------------------------------------------------------------------------
/examples/json-print2/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/json-print2/json-print2.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../tpl/include
3 |
4 | [Config Release]
5 | Product Exe Release/simplest
6 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
7 | ObjDir Release
8 | LibDir
9 | Libraries
10 |
11 | [Config Debug]
12 | Product Exe Debug/simplest
13 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception
14 | ObjDir Debug
15 | LibDir
16 | Libraries
17 |
18 | [Source]
19 | Simplest.cpp
20 |
21 |
--------------------------------------------------------------------------------
/examples/lang/Lang.cpp:
--------------------------------------------------------------------------------
1 | #define TPL_USE_AUTO_ALLOC
2 | #include
3 | #include // std::cout
4 | #include
5 | #include
6 | #include
7 |
8 | using namespace tpl;
9 |
10 | template
11 | class IsNotKeywords
12 | {
13 | private:
14 | typedef std::basic_string key_t;
15 | typedef std::set set_t;
16 |
17 | set_t m_set;
18 |
19 | public:
20 | IsNotKeywords(const CharT* keywords[], size_t n) {
21 | while (n--) {
22 | m_set.insert(keywords[n]);
23 | }
24 | }
25 |
26 | typedef key_t value_type;
27 |
28 | template
29 | bool TPL_CALL operator()(const ValueT& val) const {
30 | key_t k(val.begin(), val.end());
31 | return m_set.find(k) == m_set.end();
32 | }
33 | };
34 |
35 | int main(int argc, const char* argv[])
36 | {
37 | if (argc < 2) {
38 | std::cout << "Usage: " << argv[0] << " LangFile\n";
39 | return -1;
40 | }
41 |
42 | typedef SimpleImplementation impl;
43 |
44 | const char* keywords[] = {
45 | "if", "elif", "else",
46 | "case", "of", "default",
47 | };
48 | IsNotKeywords not_keywords(keywords, countof(keywords));
49 |
50 | impl::Allocator alloc;
51 |
52 | impl::Grammar::Var rFactor;
53 |
54 | // ::= ('*' | '/' )*
55 | impl::Grammar rTerm2( alloc,
56 | rFactor + *(
57 | '*' + rFactor |
58 | '/' + rFactor)
59 | );
60 |
61 | // ::= ('+' | '-' )*
62 | impl::Grammar rTerm( alloc,
63 | rTerm2 + *(
64 | '+' + rTerm2 |
65 | '-' + rTerm2)
66 | );
67 |
68 | // ::= '<=' | '<' | '>=' | '>' | '==' | '!='
69 | impl::Grammar rCompare( alloc,
70 | "<=" + rTerm |
71 | '<' + rTerm |
72 | ">=" + rTerm |
73 | '>' + rTerm |
74 | "==" + rTerm |
75 | "!=" + rTerm
76 | );
77 |
78 | // ::= * ('&&' *)*
79 | impl::Grammar rAndExpr( alloc,
80 | rTerm + *rCompare + *(
81 | "&&" + rTerm + *rCompare)
82 | );
83 |
84 | // ::= ('||' )*
85 | impl::Grammar rExpr( alloc,
86 | rAndExpr + *(
87 | "||" + rAndExpr)
88 | );
89 |
90 | // ::=
91 | // c_symbol() (
92 | // '=' |
93 | // '(' c_symbol() % ',' ')' '=' ) |
94 | //
95 | impl::Grammar::Var rAssignment;
96 | rAssignment.assign( alloc,
97 | c_symbol() + (
98 | '=' + rAssignment |
99 | '(' + c_symbol() % gr(',') + ')' + '=' + rAssignment) |
100 | rExpr
101 | );
102 |
103 | // ::= ( ';')*
104 | impl::Grammar rLang( alloc,
105 | *(rAssignment + ';')
106 | );
107 |
108 | // ::=
109 | // real() |
110 | // c_string() |
111 | // '(' % ',' ')' |
112 | // '-' |
113 | // '+' |
114 | // 'if' '(' ')' ('elif' '(' ')' )* 'else' |
115 | // 'case' 'of'
116 | // (( | ) ':' )*
117 | // 'default' ':' |
118 | // c_symbol() ('(' % ',' ')')?
119 | rFactor.assign( alloc,
120 | real() |
121 | c_string() |
122 | '-' + rFactor |
123 | '+' + rFactor |
124 | '(' + rAssignment % ',' + ')' |
125 | c_symbol()
126 | [
127 | case_(not_keywords)
128 | [
129 | !('(' + rAssignment % ',' + ')')
130 | ],
131 | case_("if")
132 | [
133 | '(' + rExpr + ')' + rAssignment +
134 | *(gr("elif") + '(' + rExpr + ')' + rAssignment) +
135 | c_symbol()/eq("else") + rAssignment
136 | ],
137 | case_("case")
138 | [
139 | rExpr + "of" +
140 | *((rCompare | rExpr) + ':' + rAssignment + ',') +
141 | gr("default") + ':' + rAssignment
142 | ]
143 | ]);
144 |
145 | // ---- do match ----
146 |
147 | std::FileBuf file(argv[1]);
148 | if (!file.good()) {
149 | std::cout << ">>> ERROR: open file failed!\n";
150 | return -2;
151 | }
152 | try {
153 | if ( !impl::match(file.begin(), file.end(), rLang + eos(), skipws() % ("//" + find_eol())) )
154 | std::cout << ">>> ERROR: invalid grammar!\n";
155 | else
156 | std::cout << "passed!" << '\n';
157 | }
158 | catch (const std::logic_error& e) {
159 | std::cout << ">>> ERROR: " << e.what() << '\n';
160 | }
161 | }
162 |
163 | // -------------------------------------------------------------------------
164 |
165 |
--------------------------------------------------------------------------------
/examples/lang/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include -I../../../stdext/include -I../../../boost
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | Product = Release/lang
17 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
18 | CXXFlags = $(CFlags) -fno-rtti
19 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
20 | CompileCXX = @g++ -c $(IncludeDir) $(CXXFlags) -o $@ $<
21 | Link = @g++ $(LibDir) -o $(Product)
22 | CheckLink = @ldd -u -r $(Product); echo
23 | LD_LIBRARY_PATH += :$(ProductDir)
24 | endif
25 |
26 | #
27 | # Configuration Debug
28 | #
29 | ifeq ($(CFG), Debug)
30 | ProductDir = Debug
31 | ObjectDir = Debug
32 | Product = Debug/lang
33 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
34 | CXXFlags = $(CFlags) -fno-rtti
35 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
36 | CompileCXX = @g++ -c $(IncludeDir) $(CXXFlags) -o $@ $<
37 | Link = @g++ $(LibDir) -o $(Product)
38 | CheckLink = @ldd -u -r $(Product); echo
39 | LD_LIBRARY_PATH += :$(ProductDir)
40 | endif
41 |
42 | #
43 | # Making...
44 | #
45 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
46 |
47 | $(ProductDir) :
48 | @mkdir -p $(ProductDir)
49 |
50 | ifneq ($(ProductDir),$(ObjectDir))
51 | $(ObjectDir) :
52 | @mkdir -p $(ObjectDir)
53 | endif
54 |
55 | clean :
56 | @rm -f $(ObjectDir)/*.o
57 | @rm -f $(Product)
58 |
59 | StartMake :
60 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
61 | ifeq ($(ForceLink),1)
62 | @rm -f $(Product)
63 | endif
64 |
65 | EndMake :
66 | @echo ">>> Success <<<"
67 |
68 | #
69 | # Source Files, Objects & Product
70 | #
71 | $(ObjectDir)/Lang.o : \
72 | Lang.cpp
73 | @echo "---> Compiling" $< "..."
74 | $(CompileCXX)
75 |
76 | Objects = $(ObjectDir)/Lang.o
77 |
78 | $(Product) : $(Objects)
79 | @echo "---> Creating" $@ "..."
80 | @rm -f $@
81 | $(Link) $(Objects) $(Libraries)
82 | $(CheckLink)
83 |
84 |
--------------------------------------------------------------------------------
/examples/lang/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/lang/input.lang:
--------------------------------------------------------------------------------
1 | weekday(n) =
2 | case n of
3 | 1: "Mon",
4 | 2: "Tue",
5 | 3: "Wed",
6 | 4: "Thu",
7 | 5: "Fri",
8 | 6: "Sat",
9 | 7: "Sun",
10 | default: "Error";
11 |
12 | println("weekday(3) = ", weekday(3));
13 |
14 | abs(x) = if (x < 0) -x else x;
15 |
16 | abs2(x) =
17 | case x of
18 | < 0: -x,
19 | default: x;
20 |
21 | println("abs(-3) = ", abs(x), " = ", abs2(x));
22 |
23 | factal(n) = if (n <= 1) 1 else n * factal(n-1);
24 |
25 | println("10! = ", factal(10));
26 |
27 | pi = 3.1415926;
28 |
29 | x = abs(sin(-pi/4));
30 |
31 | println("x = ", x);
32 |
33 | times1(n) =
34 | (
35 | fun(y) =
36 | (
37 | val = n * y,
38 | val
39 | ),
40 | fun
41 | );
42 |
43 | times2(n) =
44 | fun(y) =
45 | (
46 | val = n * y,
47 | val
48 | );
49 |
50 | times(n) =
51 | fun(y) = n * y;
52 |
53 | twice = times(2);
54 |
55 | y = twice(3); // y = 6
56 |
57 | println("twice(3) = ", y);
58 |
59 |
--------------------------------------------------------------------------------
/examples/lang/lang.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../tpl/include
3 | ../../../stdext/include
4 | ../../../boost
5 |
6 | [Config Release]
7 | Product Exe Release/lang
8 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
9 | ObjDir Release
10 | LibDir
11 | Libraries
12 |
13 | [Config Debug]
14 | Product Exe Debug/lang
15 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception
16 | ObjDir Debug
17 | LibDir
18 | Libraries
19 |
20 | [Source]
21 | Lang.cpp
22 |
23 |
--------------------------------------------------------------------------------
/examples/lang/readme.txt:
--------------------------------------------------------------------------------
1 | + Introduction
2 |
3 | This application is a simple language interreptor.
4 |
5 | + Language Definition
6 |
7 | ::= ( ';')*
8 |
9 | ::=
10 | c_symbol() (
11 | '=' |
12 | '(' c_symbol() % ',' ')' '=' ) |
13 |
14 |
15 | ::= ('||' )*
16 |
17 | ::= ('&&' )*
18 |
19 | ::= '<=' | '<' | '>=' | '>' | '==' | '!='
20 |
21 | ::= ('+' | '-' )*
22 |
23 | ::= ('*' | '/' )*
24 |
25 | ::=
26 | real() |
27 | c_string() |
28 | '-' |
29 | '+' |
30 | '(' % ',' ')' |
31 | c_symbol() ('(' % ',' ')')? |
32 | 'if' '(' ')' ('elif' '(' ')' )* 'else' |
33 | 'case' 'of'
34 | (( | ) ':' )*
35 | 'default' ':'
36 |
37 | ::=
38 | skipws() % ('//' find_eol())
39 |
40 | + Example
41 |
42 | weekday(n) =
43 | case n of
44 | 1: "Mon",
45 | 2: "Tue",
46 | 3: "Wed",
47 | 4: "Thu",
48 | 5: "Fri",
49 | 6: "Sat",
50 | 7: "Sun",
51 | default: "Error";
52 |
53 | abs(x) =
54 | case x of
55 | < 0: -x,
56 | default: x;
57 |
58 | abs(x) = if (x < 0) -x else x;
59 |
60 | factal(n) = if (n <= 1) 1 else n * factal(n-1);
61 |
62 | pi = 3.1415926;
63 |
64 | x = abs(sin(-pi/4));
65 |
66 | print("x=", x);
67 |
68 | times(n) =
69 | (
70 | fun(y) =
71 | (
72 | val = n * y,
73 | val
74 | ),
75 | fun
76 | );
77 |
78 | times(n) =
79 | fun(y) =
80 | (
81 | val = n * y,
82 | val
83 | );
84 |
85 | times(n) =
86 | fun(y) = n * y;
87 |
88 | twice = times(2);
89 |
90 | y = twice(3); // y = 6
91 |
92 | print("y=", y);
93 |
94 |
--------------------------------------------------------------------------------
/examples/projects.plf:
--------------------------------------------------------------------------------
1 | simplest/simplest
2 | simplest2/simplest2
3 | grammar/grammar
4 | grammar2/grammar2
5 | urlparams/urlparams
6 | boost-lambda/print/print
7 | boost-lambda/calc/calc
8 | boost-phoenix/print/print
9 | boost-phoenix/calc/calc
10 | circuit/circuit
11 | calculator/calculator
12 | removecomments/removecomments
13 | removecomments2/removecomments2
14 | includefiles/includefiles
15 | htmltext/htmltext
16 | json-print/json-print
17 | json-print2/json-print2
18 | emulator/emulator
19 | variant/variant
20 | lang/lang
21 |
22 |
--------------------------------------------------------------------------------
/examples/removecomments/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include -I../../../stdext/include
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/removecomments
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -ldl -o $(Product)
25 | LD_LIBRARY_PATH += :$(ProductDir)
26 | endif
27 |
28 | #
29 | # Configuration Debug
30 | #
31 | ifeq ($(CFG), Debug)
32 | ProductDir = Debug
33 | ObjectDir = Debug
34 | MocFile = $(ObjectDir)/temp.moc.cpp
35 | Product = Debug/removecomments
36 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
37 | CXXFlags = $(CFlags) -fno-rtti
38 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @$(CXX) $<
41 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
42 | Link = @g++ $(LibDir) -ldl -o $(Product)
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/RemoveCppComments.o : \
76 | RemoveCppComments.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 |
81 | Objects = \
82 | $(ObjectDir)/RemoveCppComments.o
83 |
84 | $(Product) : $(Objects) $(Libs)
85 | @echo "---> Creating" $@ "..."
86 | @rm -f $@
87 | $(Link) $(Objects) $(Libraries)
88 | $(CheckLink)
89 |
90 |
--------------------------------------------------------------------------------
/examples/removecomments/RemoveCppComments.cpp:
--------------------------------------------------------------------------------
1 | #define TPL_USE_AUTO_ALLOC
2 | #include // std::vector
3 | #include // std::cout
4 | #include
5 | #include
6 | #pragma warning(disable:4010)
7 |
8 | using namespace tpl;
9 |
10 | // -------------------------------------------------------------------------
11 | // remove_cpp_comments()
12 |
13 | int main()
14 | {
15 | typedef SimpleImplementation impl;
16 |
17 | // ---- define rules ----
18 |
19 | std::vector result;
20 |
21 | impl::Allocator alloc;
22 |
23 | impl::Rule::Var rCppEol;
24 |
25 | rCppEol.assign( alloc,
26 | find_set<'\r', '\n', '\\'>() +
27 | (
28 | '\\' + !eol() + rCppEol | eol()/append(result)
29 | ));
30 |
31 | Var delim;
32 | impl::Rule rString( alloc, ch('\'', '\"')/assign(delim) + *('\\' + ch_any() | ~delim) + delim );
33 |
34 | impl::Rule rItem( alloc,
35 | find_set<'/', '\'', '\"'>()/append(result) +
36 | (
37 | "/*" + find("*/") | /* I will be removed haha~ */
38 | "//" + rCppEol | // Multiline \
39 | comments are also allowed. haha~
40 | ('/' | rString)/append(result)
41 | ));
42 |
43 | impl::Rule rDoc( alloc, *rItem + done()/append(result) );
44 |
45 | // ---- do match ----
46 |
47 | const std::FileBuf file(__FILE__);
48 | impl::match(file, rDoc);
49 |
50 | for (std::vector::iterator it = result.begin(); it != result.end(); ++it)
51 | std::cout << *it;
52 |
53 | return 0;
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/examples/removecomments/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/removecomments/removecomments.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../tpl/include
3 | ../../../stdext/include
4 |
5 | [Config Release]
6 | Product Exe Release/removecomments
7 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
8 | ObjDir Release
9 | LibDir
10 | Libraries
11 |
12 | [Config Debug]
13 | Product Exe Debug/removecomments
14 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception
15 | ObjDir Debug
16 | LibDir
17 | Libraries
18 |
19 | [Source]
20 | RemoveCppComments.cpp
21 |
22 |
--------------------------------------------------------------------------------
/examples/removecomments2/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include -I../../../stdext/include
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/removecomments
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -ldl -o $(Product)
25 | LD_LIBRARY_PATH += :$(ProductDir)
26 | endif
27 |
28 | #
29 | # Configuration Debug
30 | #
31 | ifeq ($(CFG), Debug)
32 | ProductDir = Debug
33 | ObjectDir = Debug
34 | MocFile = $(ObjectDir)/temp.moc.cpp
35 | Product = Debug/removecomments
36 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
37 | CXXFlags = $(CFlags) -fno-rtti
38 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @$(CXX) $<
41 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
42 | Link = @g++ $(LibDir) -ldl -o $(Product)
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/RemoveCppComments.o : \
76 | RemoveCppComments.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 |
81 | Objects = \
82 | $(ObjectDir)/RemoveCppComments.o
83 |
84 | $(Product) : $(Objects) $(Libs)
85 | @echo "---> Creating" $@ "..."
86 | @rm -f $@
87 | $(Link) $(Objects) $(Libraries)
88 | $(CheckLink)
89 |
90 |
--------------------------------------------------------------------------------
/examples/removecomments2/RemoveCppComments.cpp:
--------------------------------------------------------------------------------
1 | #define TPL_USE_AUTO_ALLOC
2 | #include // std::vector
3 | #include // std::cout
4 | #include // cpp_comment()
5 | #include
6 | #include
7 | #pragma warning(disable:4010)
8 |
9 | using namespace tpl;
10 |
11 | // -------------------------------------------------------------------------
12 | // remove_cpp_comments()
13 |
14 | int main()
15 | {
16 | typedef SimpleImplementation impl;
17 |
18 | // ---- define rules ----
19 |
20 | std::vector result;
21 |
22 | impl::Allocator alloc;
23 |
24 | impl::Rule rItem( alloc,
25 | find_set<'/', '\'', '\"'>()/append(result) +
26 | (
27 | cpp_comment() | /* I will be removed haha~ */
28 | // Multiline \
29 | comments are also allowed. haha~
30 | ('/' | c_string_or_char())/append(result)
31 | ));
32 |
33 | // ---- do match ----
34 |
35 | const std::FileBuf file(__FILE__);
36 | file >> *rItem + done()/append(result);
37 |
38 | for (std::vector::iterator it = result.begin(); it != result.end(); ++it)
39 | std::cout << *it;
40 |
41 | return 0;
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/examples/removecomments2/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/removecomments2/removecomments2.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../tpl/include
3 | ../../../stdext/include
4 |
5 | [Config Release]
6 | Product Exe Release/removecomments
7 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
8 | ObjDir Release
9 | LibDir
10 | Libraries
11 |
12 | [Config Debug]
13 | Product Exe Debug/removecomments
14 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception
15 | ObjDir Debug
16 | LibDir
17 | Libraries
18 |
19 | [Source]
20 | RemoveCppComments.cpp
21 |
22 |
--------------------------------------------------------------------------------
/examples/simplest/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/simplest
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -ldl -o $(Product)
25 | LD_LIBRARY_PATH += :$(ProductDir)
26 | endif
27 |
28 | #
29 | # Configuration Debug
30 | #
31 | ifeq ($(CFG), Debug)
32 | ProductDir = Debug
33 | ObjectDir = Debug
34 | MocFile = $(ObjectDir)/temp.moc.cpp
35 | Product = Debug/simplest
36 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
37 | CXXFlags = $(CFlags) -fno-rtti
38 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @$(CXX) $<
41 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
42 | Link = @g++ $(LibDir) -ldl -o $(Product)
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/Simplest.o : \
76 | Simplest.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 |
81 | Objects = \
82 | $(ObjectDir)/Simplest.o
83 |
84 | $(Product) : $(Objects) $(Libs)
85 | @echo "---> Creating" $@ "..."
86 | @rm -f $@
87 | $(Link) $(Objects) $(Libraries)
88 | $(CheckLink)
89 |
90 |
--------------------------------------------------------------------------------
/examples/simplest/Simplest.cpp:
--------------------------------------------------------------------------------
1 | #include // std::vector
2 | #include // std::cout
3 | #include
4 |
5 | using namespace tpl;
6 |
7 | // -------------------------------------------------------------------------
8 | // simplest
9 |
10 | // A simplest example.
11 |
12 | // What we use:
13 | // * Rules: /append(), %, real(), ws()
14 | // * Matching: tpl::simple::match()
15 |
16 | int main()
17 | {
18 | std::vector values; // you can change vector to other stl containers.
19 |
20 | if ( simple::match("-.1 -0.1 +32. -22323.2e+12", real()/append(values) % ws()) )
21 | {
22 | for (std::vector::iterator it = values.begin(); it != values.end(); ++it)
23 | {
24 | std::cout << *it << "\n";
25 | }
26 | }
27 | return 0;
28 | }
29 |
30 | // -------------------------------------------------------------------------
31 |
32 |
--------------------------------------------------------------------------------
/examples/simplest/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/simplest/simplest.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../tpl/include
3 |
4 | [Config Release]
5 | Product Exe Release/simplest
6 | Options Release; MultiThread; AnsiChar; NoRtti; Exception; WarningAll
7 | ObjDir Release
8 | LibDir
9 | Libraries
10 |
11 | [Config Debug]
12 | Product Exe Debug/simplest
13 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception; WarningAll
14 | ObjDir Debug
15 | LibDir
16 | Libraries
17 |
18 | [Source]
19 | Simplest.cpp
20 |
21 |
--------------------------------------------------------------------------------
/examples/simplest2/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/simplest
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -ldl -o $(Product)
25 | LD_LIBRARY_PATH += :$(ProductDir)
26 | endif
27 |
28 | #
29 | # Configuration Debug
30 | #
31 | ifeq ($(CFG), Debug)
32 | ProductDir = Debug
33 | ObjectDir = Debug
34 | MocFile = $(ObjectDir)/temp.moc.cpp
35 | Product = Debug/simplest
36 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
37 | CXXFlags = $(CFlags) -fno-rtti
38 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @$(CXX) $<
41 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
42 | Link = @g++ $(LibDir) -ldl -o $(Product)
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/Simplest.o : \
76 | Simplest.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 |
81 | Objects = \
82 | $(ObjectDir)/Simplest.o
83 |
84 | $(Product) : $(Objects) $(Libs)
85 | @echo "---> Creating" $@ "..."
86 | @rm -f $@
87 | $(Link) $(Objects) $(Libraries)
88 | $(CheckLink)
89 |
90 |
--------------------------------------------------------------------------------
/examples/simplest2/Simplest.cpp:
--------------------------------------------------------------------------------
1 | #include // std::vector
2 | #include // std::cout
3 | #include // minimization of including tpl
4 |
5 | using namespace tpl;
6 |
7 | // -------------------------------------------------------------------------
8 | // simplest
9 |
10 | // A simplest example.
11 |
12 | // What we use:
13 | // * Rules: /append(), %, real(), ws()
14 | // * Matching: operator>>
15 |
16 | int main()
17 | {
18 | std::vector values; // you can change vector to other stl containers.
19 |
20 | if ( "-.1 -0.1 +32. -22323.2e+12" >> real()/append(values) % ws() )
21 | {
22 | for (std::vector::iterator it = values.begin(); it != values.end(); ++it)
23 | {
24 | std::cout << *it << "\n";
25 | }
26 | }
27 | return 0;
28 | }
29 |
30 | // -------------------------------------------------------------------------
31 |
32 |
--------------------------------------------------------------------------------
/examples/simplest2/build:
--------------------------------------------------------------------------------
1 | make CFG=Release
2 |
3 |
--------------------------------------------------------------------------------
/examples/simplest2/simplest2.prj:
--------------------------------------------------------------------------------
1 | [Include]
2 | ../../../tpl/include
3 |
4 | [Config Release]
5 | Product Exe Release/simplest
6 | Options Release; MultiThread; AnsiChar; NoRtti; Exception
7 | ObjDir Release
8 | LibDir
9 | Libraries
10 |
11 | [Config Debug]
12 | Product Exe Debug/simplest
13 | Options Debug; MultiThread; AnsiChar; NoRtti; Exception
14 | ObjDir Debug
15 | LibDir
16 | Libraries
17 |
18 | [Source]
19 | Simplest.cpp
20 |
21 |
--------------------------------------------------------------------------------
/examples/token/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace tpl;
4 |
5 | // -------------------------------------------------------------------------
6 |
7 | int main()
8 | {
9 | const char source[] = "\
10 | class Foo // Foo comment\n\
11 | : public Base1, Base2\n\
12 | {};\
13 | ";
14 |
15 | source >> cpp_skip_[
16 | *gr(c_token()/TPL_INFO("TOKEN"))
17 | ];
18 | }
19 |
20 | // -------------------------------------------------------------------------
21 |
--------------------------------------------------------------------------------
/examples/urlparams/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Configuration Default
3 | #
4 | ifeq ($(CFG),)
5 | CFG = Debug
6 | endif
7 |
8 | IncludeDir = -I../../../tpl/include
9 |
10 | #
11 | # Configuration Release
12 | #
13 | ifeq ($(CFG), Release)
14 | ProductDir = Release
15 | ObjectDir = Release
16 | MocFile = $(ObjectDir)/temp.moc.cpp
17 | Product = Release/urlparams
18 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -DNDEBUG -O2 -D_MT -fexceptions
19 | CXXFlags = $(CFlags) -fno-rtti
20 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
21 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
22 | CompileCXX = @$(CXX) $<
23 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
24 | Link = @g++ $(LibDir) -ldl -o $(Product)
25 | LD_LIBRARY_PATH += :$(ProductDir)
26 | endif
27 |
28 | #
29 | # Configuration Debug
30 | #
31 | ifeq ($(CFG), Debug)
32 | ProductDir = Debug
33 | ObjectDir = Debug
34 | MocFile = $(ObjectDir)/temp.moc.cpp
35 | Product = Debug/urlparams
36 | CFlags = $(Defines) -fPIC -D__INTEL__ -D__LINUX__ -DLINUX -D_DEBUG -g3 -D_MT -fexceptions
37 | CXXFlags = $(CFlags) -fno-rtti
38 | CXX = g++ -c $(IncludeDir) $(CXXFlags) -o $@
39 | CompileC = @gcc -c $(IncludeDir) $(CFlags) -o $@ $<
40 | CompileCXX = @$(CXX) $<
41 | CompileMoc = @moc $< -o $(MocFile) && $(CXX) $(MocFile) && rm -f $(MocFile)
42 | Link = @g++ $(LibDir) -ldl -o $(Product)
43 | LD_LIBRARY_PATH += :$(ProductDir)
44 | endif
45 |
46 | #
47 | # Making...
48 | #
49 | all : $(ProductDir) $(ObjectDir) StartMake $(Product) EndMake
50 |
51 | $(ProductDir) :
52 | @mkdir -p $(ProductDir)
53 |
54 | ifneq ($(ProductDir),$(ObjectDir))
55 | $(ObjectDir) :
56 | @mkdir -p $(ObjectDir)
57 | endif
58 |
59 | clean :
60 | @rm -f $(ObjectDir)/*.o
61 | @rm -f $(Product)
62 |
63 | StartMake :
64 | @echo "-------------- Configuration:" $(PROJ) $(CFG) "--------------"
65 | ifeq ($(ForceLink),1)
66 | @rm -f $(Product)
67 | endif
68 |
69 | EndMake :
70 | @echo ">>> Success <<<"
71 |
72 | #
73 | # Source Files, Objects & Product
74 | #
75 | $(ObjectDir)/ParseUrlParams.o : \
76 | ParseUrlParams.cpp
77 | @echo "---> Compiling" $< "..."
78 | $(CompileCXX)
79 |
80 |
81 | Objects = \
82 | $(ObjectDir)/ParseUrlParams.o
83 |
84 | $(Product) : $(Objects) $(Libs)
85 | @echo "---> Creating" $@ "..."
86 | @rm -f $@
87 | $(Link) $(Objects) $(Libraries)
88 | $(CheckLink)
89 |
90 |
--------------------------------------------------------------------------------
/examples/urlparams/ParseUrlParams.cpp:
--------------------------------------------------------------------------------
1 | #include