Making it work but it doesnt

This commit is contained in:
Brad Arant 2024-02-16 11:13:10 -08:00
parent 31cca91873
commit bb7be37fd6
34 changed files with 135 additions and 62 deletions

BIN
Expression.o Normal file

Binary file not shown.

14
Global.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "Global.h"
#include <iostream>
namespace jet {
Global::Global() {
}
Global::~Global() {
}
}

21
Global.h Normal file
View 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

BIN
Global.o Normal file

Binary file not shown.

10
JetCore.txt Normal file
View 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
View File

@ -12,8 +12,8 @@
namespace jet { namespace jet {
Tag::Tag(coreutils::ZString &in, coreutils::MString &parent) Tag::Tag(coreutils::ZString &in, coreutils::MString &parent, Global &global)
: ZString(in), parent(parent) { : ZString(in), parent(parent), global(global) {
if(in.ifNext("<")) { if(in.ifNext("<")) {
name = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_!"); name = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_!");
if(in.startsWith(" ") || in.startsWith("/") || in.startsWith(">")) { if(in.startsWith(" ") || in.startsWith("/") || in.startsWith(">")) {
@ -62,41 +62,41 @@ namespace jet {
Tag::~Tag() { Tag::~Tag() {
if(evaluate) { if(evaluate) {
copyContainer(out, parent); copyContainer(out, parent);
} else { } else {
copyContainer(container, parent); copyContainer(container, parent);
} }
} }
void Tag::parseContainer(coreutils::ZString &in) { void Tag::parseContainer(coreutils::ZString &in) {
char *start = in.getCursor(); char *start = in.getCursor();
while(!in.eod()) { while(!in.eod()) {
if(in.startsWith("<")) { if(in.startsWith("<")) {
if(ifTagName(in, "mysql")) { if(ifTagName(in, "mysql")) {
__mysql _mysql(in, out); __mysql _mysql(in, out, global);
continue; continue;
} else if(ifTagName(in, "for")) { } else if(ifTagName(in, "for")) {
__for _for(in, out); __for _for(in, out, global);
continue; continue;
} else if(ifTagName(in, "if")) { } else if(ifTagName(in, "if")) {
__if _if(in, out); __if _if(in, out, global);
continue; continue;
} else if(ifTagName(in, "jet")) { } else if(ifTagName(in, "jet")) {
__jet _jet(in, out); __jet _jet(in, out, global);
continue; continue;
} else if(ifTagName(in, "read")) { } else if(ifTagName(in, "read")) {
__read _read(in, out); __read _read(in, out, global);
continue; continue;
} else if(ifTagName(in, "set")) { } else if(ifTagName(in, "set")) {
__set _set(in, out); __set _set(in, out, global);
continue; continue;
} else if(ifTagName(in, "while")) { } else if(ifTagName(in, "while")) {
__while _while(in, out); __while _while(in, out, global);
continue; continue;
} }
} }
out.write(in.charAt(0)); out.write(in.charAt(0));
in.nextChar(); in.nextChar();
} }
} }
@ -170,19 +170,19 @@ namespace jet {
void Tag::copyContainer(coreutils::ZString &in, coreutils::MString &out) { void Tag::copyContainer(coreutils::ZString &in, coreutils::MString &out) {
while(!in.eod()) { while(!in.eod()) {
if(filterBlankLines) { if(filterBlankLines) {
in.push(); in.push();
if(!in.eod()) { if(!in.eod()) {
in.getTokenInclude(" \t"); in.getTokenInclude(" \t");
if(!in.ifNext("\n")) { if(!in.ifNext("\n")) {
in.pop(); in.pop();
// TODO: shouod be safe to output line here. // TODO: shouod be safe to output line here.
} }
} }
} }
else { else {
out.write(in.charAt(0)); out.write(in.charAt(0));
in.nextChar(); in.nextChar();
} }
} }
} }

6
Tag.h
View File

@ -3,6 +3,7 @@
#include "ZString.h" #include "ZString.h"
#include "MString.h" #include "MString.h"
#include "Global.h"
#include <map> #include <map>
namespace jet { namespace jet {
@ -10,8 +11,8 @@ namespace jet {
class Tag : public coreutils::ZString { class Tag : public coreutils::ZString {
public: public:
Tag(coreutils::ZString &in, coreutils::MString &parent); Tag(coreutils::ZString &in, coreutils::MString &parent, Global &global);
~Tag(); virtual ~Tag();
coreutils::ZString name; coreutils::ZString name;
coreutils::ZString container; coreutils::ZString container;
@ -23,6 +24,7 @@ namespace jet {
void copyContainer(coreutils::ZString &in, coreutils::MString &out); void copyContainer(coreutils::ZString &in, coreutils::MString &out);
private: private:
Global &global;
coreutils::MString &parent; coreutils::MString &parent;
coreutils::MString out; coreutils::MString out;

BIN
Tag.o Normal file

Binary file not shown.

View File

@ -4,7 +4,7 @@
namespace jet { 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"))) if(!keywordExists(coreutils::ZString("begin")))
throw coreutils::Exception("begin keyword must be specified."); throw coreutils::Exception("begin keyword must be specified.");
if(!keywordExists(coreutils::ZString("end"))) if(!keywordExists(coreutils::ZString("end")))

View File

@ -9,7 +9,7 @@ namespace jet {
class __for : public Tag { class __for : public Tag {
public: public:
__for(coreutils::ZString &in, coreutils::MString &out); __for(coreutils::ZString &in, coreutils::MString &out, Global &global);
}; };

BIN
__for.o Normal file

Binary file not shown.

View File

@ -5,7 +5,7 @@
namespace jet { 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; coreutils::MString result;

2
__if.h
View File

@ -11,7 +11,7 @@ namespace jet {
class __if : public Tag { class __if : public Tag {
public: public:
__if(coreutils::ZString &in, coreutils::MString &out); __if(coreutils::ZString &in, coreutils::MString &out, Global &global);
}; };

BIN
__if.o Normal file

Binary file not shown.

View File

@ -3,7 +3,7 @@
namespace jet { 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); parseContainer(container);
} }

View File

@ -10,7 +10,7 @@ namespace jet {
class __jet : public Tag { class __jet : public Tag {
public: public:
__jet(coreutils::ZString &in, coreutils::MString &out); __jet(coreutils::ZString &in, coreutils::MString &out, Global &global);
}; };

BIN
__jet.o Normal file

Binary file not shown.

View File

@ -3,7 +3,7 @@
namespace jet { 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); parseContainer(container);
} }

View File

@ -11,7 +11,7 @@ namespace jet {
class __mysql : public Tag { class __mysql : public Tag {
public: public:
__mysql(coreutils::ZString &in, coreutils::MString &out); __mysql(coreutils::ZString &in, coreutils::MString &out, Global &global);
}; };

BIN
__mysql.o Normal file

Binary file not shown.

View File

@ -3,7 +3,7 @@
namespace jet { 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"))) if(!keywordExists(coreutils::ZString("file")))
throw coreutils::Exception("file keyword must be specified."); throw coreutils::Exception("file keyword must be specified.");

View File

@ -8,7 +8,7 @@ namespace jet {
class __read : public Tag { class __read : public Tag {
public: public:
__read(coreutils::ZString &in, coreutils::MString &out); __read(coreutils::ZString &in, coreutils::MString &out, Global &global);
}; };

BIN
__read.o Normal file

Binary file not shown.

View File

@ -4,7 +4,12 @@
namespace jet { 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
View 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);
}
}

View File

@ -11,7 +11,7 @@ namespace jet {
class __set : public Tag { class __set : public Tag {
public: public:
__set(coreutils::ZString &in, coreutils::MString &out); __set(coreutils::ZString &in, coreutils::MString &out, Global &global);
}; };

View File

@ -4,7 +4,7 @@
namespace jet { 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("value1"))) {
if(keywordExists(coreutils::ZString("expr"))) if(keywordExists(coreutils::ZString("expr")))

View File

@ -9,7 +9,7 @@ namespace jet {
class __while : public Tag { class __while : public Tag {
public: public:
__while(coreutils::ZString &in, coreutils::MString &out); __while(coreutils::ZString &in, coreutils::MString &out, Global &global);
}; };

BIN
__while.o Normal file

Binary file not shown.

2
gitignore Normal file
View File

@ -0,0 +1,2 @@
*.o
*~

1
gitignore~ Normal file
View File

@ -0,0 +1 @@
*.o

BIN
testjet

Binary file not shown.

View File

@ -1,11 +1,12 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include "Global.h"
#include "__jet.h" #include "__jet.h"
int main(int argc, char **argv) { int main(int argc, char **argv) {
coreutils::ZString data("<jet>\n" 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" " <set name=\"thename\" scope=\"global\">this is the value</set>\n"
" <mysql key=\"uu\">\n" " <mysql key=\"uu\">\n"
" <if value1=\"X\" value2=\"Y\" type=\"eq\">\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; std::cout << "---------\n" << data << "----------\n" << std::endl;
jet::Global global;
coreutils::MString out; coreutils::MString out;
jet::__jet *jet = new jet::__jet(data, out); jet::__jet *jet = new jet::__jet(data, out, global);
delete jet; delete jet;
std::cout << ">>-------" << std::endl << out << std::endl << "<<------"; std::cout << ">>-------" << std::endl << out << std::endl << "<<------";

BIN
testjet.o Normal file

Binary file not shown.