diff --git a/Tag.cpp b/Tag.cpp index 4c03f9d..16b3a28 100644 --- a/Tag.cpp +++ b/Tag.cpp @@ -21,6 +21,8 @@ #include "__header.h" #include "__whiledir.h" #include "__tag.h" +#include "__dotag.h" +#include "__stream.h" #include namespace jet { @@ -105,12 +107,13 @@ namespace jet { copyContainer(container, parent); } - void Tag::processContainer(coreutils::ZString &container) { + void Tag::processContainer(coreutils::ZString &container, coreutils::ZString container2) { if(hasContainer && evaluate) - parseContainer(container); + parseContainer(container, container2); } - void Tag::parseContainer(coreutils::ZString &in) { + void Tag::parseContainer(coreutils::ZString &in, coreutils::ZString container2) { + coreutils::ZString tag; char *start = in.getCursor(); while(!in.eod()) { if(in.startsWith("<")) { @@ -165,12 +168,17 @@ namespace jet { } else if(ifTagName(in, "whiledir")) { __whiledir _whiledir(in, out, global); continue; + } else if(ifTagName(in, "stream")) { + __stream _stream(in, out, global); + continue; } else if(ifTagName(in, "tag")) { __tag _tag(in, out, global); continue; - } else if(global.tags.contains(in)) { - std::cout << "finding tag" << std::endl; - __tag _tag(in, out, global); + } else if(ifTagDefined(in, tag)) { + __dotag _dotag(in, out, global); + continue; + } else if(ifTagName(in, "container")) { + processContainer(container2); continue; } else { out.write(in.charAt(0)); @@ -233,6 +241,28 @@ namespace jet { in.pop(); return false; } + + bool Tag::ifTagDefined(coreutils::ZString &in, coreutils::ZString &tag) { + in.push(); + if(in.ifNext("<")) { + tag = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"); + if(global.tags.count(tag)) { + if(in.ifNext(" ")) { + in.pop(); + return true; + } else if(in.ifNext("/>")) { + in.pop(); + return true; + } else if(in.ifNext(">")) { + in.pop(); + return true; + } + in.pop(); + } + } + in.pop(); + return false; + } bool Tag::ifEndTagName(coreutils::ZString &in) { in.push(); diff --git a/Tag.h b/Tag.h index 09c0ea4..4bc24cd 100644 --- a/Tag.h +++ b/Tag.h @@ -22,8 +22,8 @@ namespace jet { bool hasContainer2; std::map variables; bool variableDefined(coreutils::ZString variable); - void parseContainer(coreutils::ZString &in); - void processContainer(coreutils::ZString &container); + void parseContainer(coreutils::ZString &in, coreutils::ZString container2 = NULL); + void processContainer(coreutils::ZString &container, coreutils::ZString container2 = NULL); void copyContainer(coreutils::ZString &in, coreutils::MString &out); Global &global; @@ -46,6 +46,7 @@ namespace jet { bool ifNested(coreutils::ZString &in); bool ifTagName(coreutils::ZString &in, const char *tag); bool ifTagName(coreutils::ZString &in); + bool ifTagDefined(coreutils::ZString &in, coreutils::ZString &tag); bool ifEndTagName(coreutils::ZString &in); bool ifSplitTagName(coreutils::ZString &in); diff --git a/__dotag.cpp b/__dotag.cpp new file mode 100644 index 0000000..b7e8258 --- /dev/null +++ b/__dotag.cpp @@ -0,0 +1,12 @@ +#include "__dotag.h" +#include "Exception.h" + +namespace jet { + + __dotag::__dotag(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) { + hasContainer = true; + coreutils::ZString container3 = global.tags[name]; + processContainer(container3, container); + } +} + diff --git a/__dotag.h b/__dotag.h new file mode 100644 index 0000000..44b9754 --- /dev/null +++ b/__dotag.h @@ -0,0 +1,18 @@ +#ifndef ____dotag_h__ +#define ____dotag_h__ + +#include "Tag.h" +#include "ZString.h" + +namespace jet { + + class __dotag : public Tag { + + public: + __dotag(coreutils::ZString &in, coreutils::MString &parent, Global &global); + + }; + +} + +#endif diff --git a/__tag.cpp b/__tag.cpp index 195a641..243698f 100644 --- a/__tag.cpp +++ b/__tag.cpp @@ -4,6 +4,8 @@ namespace jet { __tag::__tag(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) { + evaluate = false; + output = false; if(!variableDefined("name")) throw coreutils::Exception("tag must have a name."); if(!hasContainer) diff --git a/testtag.jet b/testtag.jet index 05b9fed..489a6b8 100755 --- a/testtag.jet +++ b/testtag.jet @@ -1,8 +1,13 @@ #!./jet-2.0 - - - $[ix] - - - + +--> + >< + <--++> + >>>$[ix]<<< +<++ +== + + >><< + + \ No newline at end of file