diff --git a/Expression.o b/Expression.o new file mode 100644 index 0000000..24c1d8b Binary files /dev/null and b/Expression.o differ diff --git a/Global.cpp b/Global.cpp new file mode 100644 index 0000000..5c00fb8 --- /dev/null +++ b/Global.cpp @@ -0,0 +1,14 @@ +#include "Global.h" +#include + +namespace jet { + + Global::Global() { + + } + + Global::~Global() { + + } + +} diff --git a/Global.h b/Global.h new file mode 100644 index 0000000..146a4f9 --- /dev/null +++ b/Global.h @@ -0,0 +1,21 @@ +#ifndef __Global_h__ +#define __Global_h__ + +#include "MString.h" +#include + +namespace jet { + + class Global { + + public: + Global(); + virtual ~Global(); + + std::map variables; + + }; + +} + +#endif diff --git a/Global.o b/Global.o new file mode 100644 index 0000000..4840528 Binary files /dev/null and b/Global.o differ diff --git a/JetCore.txt b/JetCore.txt new file mode 100644 index 0000000..e6ec235 --- /dev/null +++ b/JetCore.txt @@ -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. + diff --git a/Tag.cpp b/Tag.cpp index 1837d0c..035c372 100644 --- a/Tag.cpp +++ b/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(); + } } } diff --git a/Tag.h b/Tag.h index 4500f72..719ee74 100644 --- a/Tag.h +++ b/Tag.h @@ -3,6 +3,7 @@ #include "ZString.h" #include "MString.h" +#include "Global.h" #include 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; diff --git a/Tag.o b/Tag.o new file mode 100644 index 0000000..973401c Binary files /dev/null and b/Tag.o differ diff --git a/__for.cpp b/__for.cpp index 19b9a8f..9f08809 100644 --- a/__for.cpp +++ b/__for.cpp @@ -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"))) diff --git a/__for.h b/__for.h index fee99d3..3fa23e7 100644 --- a/__for.h +++ b/__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); }; diff --git a/__for.o b/__for.o new file mode 100644 index 0000000..c7f7ee4 Binary files /dev/null and b/__for.o differ diff --git a/__if.cpp b/__if.cpp index 6c15e22..0407d03 100644 --- a/__if.cpp +++ b/__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; diff --git a/__if.h b/__if.h index cd688f3..8d844d4 100644 --- a/__if.h +++ b/__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); }; diff --git a/__if.o b/__if.o new file mode 100644 index 0000000..a98e4e4 Binary files /dev/null and b/__if.o differ diff --git a/__jet.cpp b/__jet.cpp index c830cca..b6ca688 100644 --- a/__jet.cpp +++ b/__jet.cpp @@ -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); } diff --git a/__jet.h b/__jet.h index 922b193..87f6e37 100644 --- a/__jet.h +++ b/__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); }; diff --git a/__jet.o b/__jet.o new file mode 100644 index 0000000..f0d7f2d Binary files /dev/null and b/__jet.o differ diff --git a/__mysql.cpp b/__mysql.cpp index 0c37f48..2ad9c38 100644 --- a/__mysql.cpp +++ b/__mysql.cpp @@ -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); } diff --git a/__mysql.h b/__mysql.h index 176a7f0..086a922 100644 --- a/__mysql.h +++ b/__mysql.h @@ -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); }; diff --git a/__mysql.o b/__mysql.o new file mode 100644 index 0000000..99fc29b Binary files /dev/null and b/__mysql.o differ diff --git a/__read.cpp b/__read.cpp index bdb1f3d..cacadc5 100644 --- a/__read.cpp +++ b/__read.cpp @@ -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."); diff --git a/__read.h b/__read.h index 23b06d6..39a0ced 100644 --- a/__read.h +++ b/__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); }; diff --git a/__read.o b/__read.o new file mode 100644 index 0000000..565dd4b Binary files /dev/null and b/__read.o differ diff --git a/__set.cpp b/__set.cpp index c84acfc..d6f58a6 100644 --- a/__set.cpp +++ b/__set.cpp @@ -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; + } } diff --git a/__set.cpp~ b/__set.cpp~ new file mode 100644 index 0000000..e2d6688 --- /dev/null +++ b/__set.cpp~ @@ -0,0 +1,16 @@ +#include "__set.h" +#include "Exception.h" +#include + +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); + + } + +} diff --git a/__set.h b/__set.h index 41623c4..4536505 100644 --- a/__set.h +++ b/__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); }; diff --git a/__while.cpp b/__while.cpp index d502524..5f21393 100644 --- a/__while.cpp +++ b/__while.cpp @@ -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"))) diff --git a/__while.h b/__while.h index 7230cf8..7c3d643 100644 --- a/__while.h +++ b/__while.h @@ -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); }; diff --git a/__while.o b/__while.o new file mode 100644 index 0000000..4a33ff0 Binary files /dev/null and b/__while.o differ diff --git a/gitignore b/gitignore new file mode 100644 index 0000000..a70237a --- /dev/null +++ b/gitignore @@ -0,0 +1,2 @@ +*.o +*~ diff --git a/gitignore~ b/gitignore~ new file mode 100644 index 0000000..5761abc --- /dev/null +++ b/gitignore~ @@ -0,0 +1 @@ +*.o diff --git a/testjet b/testjet deleted file mode 100755 index a7eb98a..0000000 Binary files a/testjet and /dev/null differ diff --git a/testjet.cpp b/testjet.cpp index 4a28fa5..7a57b9e 100644 --- a/testjet.cpp +++ b/testjet.cpp @@ -1,11 +1,12 @@ #include #include +#include "Global.h" #include "__jet.h" int main(int argc, char **argv) { coreutils::ZString data("\n" - " \n" + " \n" " this is the value\n" " \n" " \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 << "<<------"; diff --git a/testjet.o b/testjet.o new file mode 100644 index 0000000..7a938ff Binary files /dev/null and b/testjet.o differ