significant work on the tag tag.
This commit is contained in:
parent
fef8f7080c
commit
9277b456da
42
Tag.cpp
42
Tag.cpp
@ -21,6 +21,8 @@
|
||||
#include "__header.h"
|
||||
#include "__whiledir.h"
|
||||
#include "__tag.h"
|
||||
#include "__dotag.h"
|
||||
#include "__stream.h"
|
||||
#include <iostream>
|
||||
|
||||
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();
|
||||
|
5
Tag.h
5
Tag.h
@ -22,8 +22,8 @@ namespace jet {
|
||||
bool hasContainer2;
|
||||
std::map<coreutils::ZString, coreutils::MString> 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);
|
||||
|
||||
|
12
__dotag.cpp
Normal file
12
__dotag.cpp
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
|
18
__dotag.h
Normal file
18
__dotag.h
Normal file
@ -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
|
@ -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)
|
||||
|
17
testtag.jet
17
testtag.jet
@ -1,8 +1,13 @@
|
||||
#!./jet-2.0
|
||||
<tag named="test">
|
||||
<set name="ix" expr="$[ix]+1" />
|
||||
$[ix]
|
||||
</tag>
|
||||
<set name="ix" value="1" />
|
||||
<test />
|
||||
<jet filterblanklines="true" trimlines="true">
|
||||
<tag name="test">-->
|
||||
><set name="ix" expr="$[ix]+1" /><
|
||||
<--<container />++>
|
||||
>>>$[ix]<<<
|
||||
<++</tag>
|
||||
=<set name="ix" value="1" />=
|
||||
<test>
|
||||
>><set name="ix" expr="$[ix]+1" /><<
|
||||
</test>
|
||||
<test />
|
||||
</jet>
|
Loading…
x
Reference in New Issue
Block a user