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 "__header.h"
|
||||||
#include "__whiledir.h"
|
#include "__whiledir.h"
|
||||||
#include "__tag.h"
|
#include "__tag.h"
|
||||||
|
#include "__dotag.h"
|
||||||
|
#include "__stream.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace jet {
|
namespace jet {
|
||||||
@ -105,12 +107,13 @@ namespace jet {
|
|||||||
copyContainer(container, parent);
|
copyContainer(container, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tag::processContainer(coreutils::ZString &container) {
|
void Tag::processContainer(coreutils::ZString &container, coreutils::ZString container2) {
|
||||||
if(hasContainer && evaluate)
|
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();
|
char *start = in.getCursor();
|
||||||
while(!in.eod()) {
|
while(!in.eod()) {
|
||||||
if(in.startsWith("<")) {
|
if(in.startsWith("<")) {
|
||||||
@ -165,12 +168,17 @@ namespace jet {
|
|||||||
} else if(ifTagName(in, "whiledir")) {
|
} else if(ifTagName(in, "whiledir")) {
|
||||||
__whiledir _whiledir(in, out, global);
|
__whiledir _whiledir(in, out, global);
|
||||||
continue;
|
continue;
|
||||||
|
} else if(ifTagName(in, "stream")) {
|
||||||
|
__stream _stream(in, out, global);
|
||||||
|
continue;
|
||||||
} else if(ifTagName(in, "tag")) {
|
} else if(ifTagName(in, "tag")) {
|
||||||
__tag _tag(in, out, global);
|
__tag _tag(in, out, global);
|
||||||
continue;
|
continue;
|
||||||
} else if(global.tags.contains(in)) {
|
} else if(ifTagDefined(in, tag)) {
|
||||||
std::cout << "finding tag" << std::endl;
|
__dotag _dotag(in, out, global);
|
||||||
__tag _tag(in, out, global);
|
continue;
|
||||||
|
} else if(ifTagName(in, "container")) {
|
||||||
|
processContainer(container2);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
out.write(in.charAt(0));
|
out.write(in.charAt(0));
|
||||||
@ -234,6 +242,28 @@ namespace jet {
|
|||||||
return false;
|
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) {
|
bool Tag::ifEndTagName(coreutils::ZString &in) {
|
||||||
in.push();
|
in.push();
|
||||||
if(in.ifNext("</"))
|
if(in.ifNext("</"))
|
||||||
|
5
Tag.h
5
Tag.h
@ -22,8 +22,8 @@ namespace jet {
|
|||||||
bool hasContainer2;
|
bool hasContainer2;
|
||||||
std::map<coreutils::ZString, coreutils::MString> variables;
|
std::map<coreutils::ZString, coreutils::MString> variables;
|
||||||
bool variableDefined(coreutils::ZString variable);
|
bool variableDefined(coreutils::ZString variable);
|
||||||
void parseContainer(coreutils::ZString &in);
|
void parseContainer(coreutils::ZString &in, coreutils::ZString container2 = NULL);
|
||||||
void processContainer(coreutils::ZString &container);
|
void processContainer(coreutils::ZString &container, coreutils::ZString container2 = NULL);
|
||||||
void copyContainer(coreutils::ZString &in, coreutils::MString &out);
|
void copyContainer(coreutils::ZString &in, coreutils::MString &out);
|
||||||
|
|
||||||
Global &global;
|
Global &global;
|
||||||
@ -46,6 +46,7 @@ namespace jet {
|
|||||||
bool ifNested(coreutils::ZString &in);
|
bool ifNested(coreutils::ZString &in);
|
||||||
bool ifTagName(coreutils::ZString &in, const char *tag);
|
bool ifTagName(coreutils::ZString &in, const char *tag);
|
||||||
bool ifTagName(coreutils::ZString &in);
|
bool ifTagName(coreutils::ZString &in);
|
||||||
|
bool ifTagDefined(coreutils::ZString &in, coreutils::ZString &tag);
|
||||||
bool ifEndTagName(coreutils::ZString &in);
|
bool ifEndTagName(coreutils::ZString &in);
|
||||||
bool ifSplitTagName(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 {
|
namespace jet {
|
||||||
|
|
||||||
__tag::__tag(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) {
|
__tag::__tag(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) {
|
||||||
|
evaluate = false;
|
||||||
|
output = false;
|
||||||
if(!variableDefined("name"))
|
if(!variableDefined("name"))
|
||||||
throw coreutils::Exception("tag must have a name.");
|
throw coreutils::Exception("tag must have a name.");
|
||||||
if(!hasContainer)
|
if(!hasContainer)
|
||||||
|
17
testtag.jet
17
testtag.jet
@ -1,8 +1,13 @@
|
|||||||
#!./jet-2.0
|
#!./jet-2.0
|
||||||
<tag named="test">
|
<jet filterblanklines="true" trimlines="true">
|
||||||
<set name="ix" expr="$[ix]+1" />
|
<tag name="test">-->
|
||||||
$[ix]
|
><set name="ix" expr="$[ix]+1" /><
|
||||||
</tag>
|
<--<container />++>
|
||||||
<set name="ix" value="1" />
|
>>>$[ix]<<<
|
||||||
<test />
|
<++</tag>
|
||||||
|
=<set name="ix" value="1" />=
|
||||||
|
<test>
|
||||||
|
>><set name="ix" expr="$[ix]+1" /><<
|
||||||
|
</test>
|
||||||
<test />
|
<test />
|
||||||
|
</jet>
|
Loading…
x
Reference in New Issue
Block a user