Making it work but it doesnt
This commit is contained in:
parent
31cca91873
commit
bb7be37fd6
BIN
Expression.o
Normal file
BIN
Expression.o
Normal file
Binary file not shown.
14
Global.cpp
Normal file
14
Global.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include "Global.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace jet {
|
||||
|
||||
Global::Global() {
|
||||
|
||||
}
|
||||
|
||||
Global::~Global() {
|
||||
|
||||
}
|
||||
|
||||
}
|
21
Global.h
Normal file
21
Global.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef __Global_h__
|
||||
#define __Global_h__
|
||||
|
||||
#include "MString.h"
|
||||
#include <map>
|
||||
|
||||
namespace jet {
|
||||
|
||||
class Global {
|
||||
|
||||
public:
|
||||
Global();
|
||||
virtual ~Global();
|
||||
|
||||
std::map<coreutils::MString, coreutils::MString> variables;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
10
JetCore.txt
Normal file
10
JetCore.txt
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JET will pass through the untagged areas to the output without any
|
||||
modifications. Data contained within the tags may modify their
|
||||
containers before placing any output. The space taken by the tag
|
||||
itself is not passwed to the output and will not appear in the output.
|
||||
|
86
Tag.cpp
86
Tag.cpp
@ -12,8 +12,8 @@
|
||||
|
||||
namespace jet {
|
||||
|
||||
Tag::Tag(coreutils::ZString &in, coreutils::MString &parent)
|
||||
: ZString(in), parent(parent) {
|
||||
Tag::Tag(coreutils::ZString &in, coreutils::MString &parent, Global &global)
|
||||
: ZString(in), parent(parent), global(global) {
|
||||
if(in.ifNext("<")) {
|
||||
name = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_!");
|
||||
if(in.startsWith(" ") || in.startsWith("/") || in.startsWith(">")) {
|
||||
@ -62,41 +62,41 @@ namespace jet {
|
||||
|
||||
Tag::~Tag() {
|
||||
if(evaluate) {
|
||||
copyContainer(out, parent);
|
||||
copyContainer(out, parent);
|
||||
} else {
|
||||
copyContainer(container, parent);
|
||||
copyContainer(container, parent);
|
||||
}
|
||||
}
|
||||
|
||||
void Tag::parseContainer(coreutils::ZString &in) {
|
||||
char *start = in.getCursor();
|
||||
char *start = in.getCursor();
|
||||
while(!in.eod()) {
|
||||
if(in.startsWith("<")) {
|
||||
if(ifTagName(in, "mysql")) {
|
||||
__mysql _mysql(in, out);
|
||||
continue;
|
||||
} else if(ifTagName(in, "for")) {
|
||||
__for _for(in, out);
|
||||
continue;
|
||||
} else if(ifTagName(in, "if")) {
|
||||
__if _if(in, out);
|
||||
continue;
|
||||
} else if(ifTagName(in, "jet")) {
|
||||
__jet _jet(in, out);
|
||||
continue;
|
||||
} else if(ifTagName(in, "read")) {
|
||||
__read _read(in, out);
|
||||
continue;
|
||||
} else if(ifTagName(in, "set")) {
|
||||
__set _set(in, out);
|
||||
continue;
|
||||
} else if(ifTagName(in, "while")) {
|
||||
__while _while(in, out);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
out.write(in.charAt(0));
|
||||
in.nextChar();
|
||||
if(in.startsWith("<")) {
|
||||
if(ifTagName(in, "mysql")) {
|
||||
__mysql _mysql(in, out, global);
|
||||
continue;
|
||||
} else if(ifTagName(in, "for")) {
|
||||
__for _for(in, out, global);
|
||||
continue;
|
||||
} else if(ifTagName(in, "if")) {
|
||||
__if _if(in, out, global);
|
||||
continue;
|
||||
} else if(ifTagName(in, "jet")) {
|
||||
__jet _jet(in, out, global);
|
||||
continue;
|
||||
} else if(ifTagName(in, "read")) {
|
||||
__read _read(in, out, global);
|
||||
continue;
|
||||
} else if(ifTagName(in, "set")) {
|
||||
__set _set(in, out, global);
|
||||
continue;
|
||||
} else if(ifTagName(in, "while")) {
|
||||
__while _while(in, out, global);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
out.write(in.charAt(0));
|
||||
in.nextChar();
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,19 +170,19 @@ namespace jet {
|
||||
void Tag::copyContainer(coreutils::ZString &in, coreutils::MString &out) {
|
||||
while(!in.eod()) {
|
||||
if(filterBlankLines) {
|
||||
in.push();
|
||||
if(!in.eod()) {
|
||||
in.getTokenInclude(" \t");
|
||||
if(!in.ifNext("\n")) {
|
||||
in.pop();
|
||||
// TODO: shouod be safe to output line here.
|
||||
}
|
||||
}
|
||||
}
|
||||
in.push();
|
||||
if(!in.eod()) {
|
||||
in.getTokenInclude(" \t");
|
||||
if(!in.ifNext("\n")) {
|
||||
in.pop();
|
||||
// TODO: shouod be safe to output line here.
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
out.write(in.charAt(0));
|
||||
in.nextChar();
|
||||
}
|
||||
out.write(in.charAt(0));
|
||||
in.nextChar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
6
Tag.h
6
Tag.h
@ -3,6 +3,7 @@
|
||||
|
||||
#include "ZString.h"
|
||||
#include "MString.h"
|
||||
#include "Global.h"
|
||||
#include <map>
|
||||
|
||||
namespace jet {
|
||||
@ -10,8 +11,8 @@ namespace jet {
|
||||
class Tag : public coreutils::ZString {
|
||||
|
||||
public:
|
||||
Tag(coreutils::ZString &in, coreutils::MString &parent);
|
||||
~Tag();
|
||||
Tag(coreutils::ZString &in, coreutils::MString &parent, Global &global);
|
||||
virtual ~Tag();
|
||||
coreutils::ZString name;
|
||||
coreutils::ZString container;
|
||||
|
||||
@ -23,6 +24,7 @@ namespace jet {
|
||||
void copyContainer(coreutils::ZString &in, coreutils::MString &out);
|
||||
|
||||
private:
|
||||
Global &global;
|
||||
coreutils::MString &parent;
|
||||
coreutils::MString out;
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
namespace jet {
|
||||
|
||||
__for::__for(coreutils::ZString &in, coreutils::MString &out) : Tag(in, out) {
|
||||
__for::__for(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) {
|
||||
if(!keywordExists(coreutils::ZString("begin")))
|
||||
throw coreutils::Exception("begin keyword must be specified.");
|
||||
if(!keywordExists(coreutils::ZString("end")))
|
||||
|
2
__for.h
2
__for.h
@ -9,7 +9,7 @@ namespace jet {
|
||||
class __for : public Tag {
|
||||
|
||||
public:
|
||||
__for(coreutils::ZString &in, coreutils::MString &out);
|
||||
__for(coreutils::ZString &in, coreutils::MString &out, Global &global);
|
||||
|
||||
};
|
||||
|
||||
|
2
__if.cpp
2
__if.cpp
@ -5,7 +5,7 @@
|
||||
|
||||
namespace jet {
|
||||
|
||||
__if::__if(coreutils::ZString &in, coreutils::MString &out) : Tag(in, out) {
|
||||
__if::__if(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) {
|
||||
|
||||
coreutils::MString result;
|
||||
|
||||
|
2
__if.h
2
__if.h
@ -11,7 +11,7 @@ namespace jet {
|
||||
class __if : public Tag {
|
||||
|
||||
public:
|
||||
__if(coreutils::ZString &in, coreutils::MString &out);
|
||||
__if(coreutils::ZString &in, coreutils::MString &out, Global &global);
|
||||
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
namespace jet {
|
||||
|
||||
__jet::__jet(coreutils::ZString &in, coreutils::MString &out) : Tag(in, out) {
|
||||
__jet::__jet(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) {
|
||||
parseContainer(container);
|
||||
}
|
||||
|
||||
|
2
__jet.h
2
__jet.h
@ -10,7 +10,7 @@ namespace jet {
|
||||
class __jet : public Tag {
|
||||
|
||||
public:
|
||||
__jet(coreutils::ZString &in, coreutils::MString &out);
|
||||
__jet(coreutils::ZString &in, coreutils::MString &out, Global &global);
|
||||
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
namespace jet {
|
||||
|
||||
__mysql::__mysql(coreutils::ZString &in, coreutils::MString &out) : Tag(in, out) {
|
||||
__mysql::__mysql(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) {
|
||||
parseContainer(container);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ namespace jet {
|
||||
class __mysql : public Tag {
|
||||
|
||||
public:
|
||||
__mysql(coreutils::ZString &in, coreutils::MString &out);
|
||||
__mysql(coreutils::ZString &in, coreutils::MString &out, Global &global);
|
||||
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
namespace jet {
|
||||
|
||||
__read::__read(coreutils::ZString &in, coreutils::MString &out) : Tag(in, out) {
|
||||
__read::__read(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) {
|
||||
if(!keywordExists(coreutils::ZString("file")))
|
||||
throw coreutils::Exception("file keyword must be specified.");
|
||||
|
||||
|
2
__read.h
2
__read.h
@ -8,7 +8,7 @@ namespace jet {
|
||||
class __read : public Tag {
|
||||
|
||||
public:
|
||||
__read(coreutils::ZString &in, coreutils::MString &out);
|
||||
__read(coreutils::ZString &in, coreutils::MString &out, Global &global);
|
||||
|
||||
};
|
||||
|
||||
|
@ -4,8 +4,13 @@
|
||||
|
||||
namespace jet {
|
||||
|
||||
__set::__set(coreutils::ZString &in, coreutils::MString &out) : Tag(in, out) {
|
||||
|
||||
__set::__set(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) {
|
||||
std::cout << "name: [" << keywords["name"] << "]" << std::endl;
|
||||
std::cout << "value: [" << keywords["value"] << "]" << std::endl;
|
||||
std::cout << "container: [" << container << "]" << std::endl;
|
||||
std::cout << "scope: [" << keywords["scope"] << "]" << std::endl;
|
||||
global.variables[name] = container;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
16
__set.cpp~
Normal file
16
__set.cpp~
Normal file
@ -0,0 +1,16 @@
|
||||
#include "__set.h"
|
||||
#include "Exception.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace jet {
|
||||
|
||||
__set::__set(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) {
|
||||
std::cout << "name: [" << keywords["name"] << "]" << std::endl;
|
||||
std::cout << "value: [" << keywords["value"] << "]" << std::endl;
|
||||
std::cout << "container: [" << container << "]" << std::endl;
|
||||
std::cout << "scope: [" << keywords["scope"] << "]" << std::endl;
|
||||
global.variables[name] = coreutils::MString(container);
|
||||
|
||||
}
|
||||
|
||||
}
|
2
__set.h
2
__set.h
@ -11,7 +11,7 @@ namespace jet {
|
||||
class __set : public Tag {
|
||||
|
||||
public:
|
||||
__set(coreutils::ZString &in, coreutils::MString &out);
|
||||
__set(coreutils::ZString &in, coreutils::MString &out, Global &global);
|
||||
|
||||
};
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
namespace jet {
|
||||
|
||||
__while::__while(coreutils::ZString &in, coreutils::MString &out) : Tag(in, out) {
|
||||
__while::__while(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) {
|
||||
|
||||
if(keywordExists(coreutils::ZString("value1"))) {
|
||||
if(keywordExists(coreutils::ZString("expr")))
|
||||
|
@ -9,7 +9,7 @@ namespace jet {
|
||||
class __while : public Tag {
|
||||
|
||||
public:
|
||||
__while(coreutils::ZString &in, coreutils::MString &out);
|
||||
__while(coreutils::ZString &in, coreutils::MString &out, Global &global);
|
||||
|
||||
};
|
||||
|
||||
|
1
gitignore~
Normal file
1
gitignore~
Normal file
@ -0,0 +1 @@
|
||||
*.o
|
@ -1,11 +1,12 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include "Global.h"
|
||||
#include "__jet.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
coreutils::ZString data("<jet>\n"
|
||||
" <set name=\"varname\" value=\"vardata\" scope=\"local\"/>\n"
|
||||
" <set name=\"varname\" value=\"vardata\" scope=\"local\" />\n"
|
||||
" <set name=\"thename\" scope=\"global\">this is the value</set>\n"
|
||||
" <mysql key=\"uu\">\n"
|
||||
" <if value1=\"X\" value2=\"Y\" type=\"eq\">\n"
|
||||
@ -21,8 +22,9 @@ int main(int argc, char **argv) {
|
||||
|
||||
std::cout << "---------\n" << data << "----------\n" << std::endl;
|
||||
|
||||
jet::Global global;
|
||||
coreutils::MString out;
|
||||
jet::__jet *jet = new jet::__jet(data, out);
|
||||
jet::__jet *jet = new jet::__jet(data, out, global);
|
||||
delete jet;
|
||||
std::cout << ">>-------" << std::endl << out << std::endl << "<<------";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user