diff options
| author | Bob Jamison <ishmalius@gmail.com> | 2006-04-27 15:26:43 +0000 |
|---|---|---|
| committer | ishmal <ishmal@users.sourceforge.net> | 2006-04-27 15:26:43 +0000 |
| commit | d57cb6ab204be89a53083e9d1638391e38250a52 (patch) | |
| tree | 2ddc806b53d27c8137b974a18606a2f118bd82ed /src | |
| parent | interim cleanup commit (diff) | |
| download | inkscape-d57cb6ab204be89a53083e9d1638391e38250a52.tar.gz inkscape-d57cb6ab204be89a53083e9d1638391e38250a52.zip | |
Add axis and function token stubs to token set
(bzr r598)
Diffstat (limited to 'src')
| -rw-r--r-- | src/dom/xpathparser.cpp | 93 | ||||
| -rw-r--r-- | src/dom/xpathtoken.h | 611 |
2 files changed, 697 insertions, 7 deletions
diff --git a/src/dom/xpathparser.cpp b/src/dom/xpathparser.cpp index 18d62d40a..47a9a146a 100644 --- a/src/dom/xpathparser.cpp +++ b/src/dom/xpathparser.cpp @@ -817,6 +817,8 @@ int XPathParser::getAxisSpecifier(int p0, int depth) int p = p0;
if (lexTokType(p) == AXIS_NAME)
{
+ LexTok t = lexTok(p);
+ int axisType = t.getIntValue();
p++;
if (lexTokType(p) != DOUBLE_COLON)
{
@@ -824,6 +826,40 @@ int XPathParser::getAxisSpecifier(int p0, int depth) return -1;
}
p++;
+ switch (axisType)
+ {
+ case ANCESTOR_OR_SELF:
+ tokAdd(new TokAxisAncestorOrSelf());
+ case ANCESTOR:
+ tokAdd(new TokAxisAncestor());
+ case ATTRIBUTE:
+ tokAdd(new TokAxisAttribute());
+ case CHILD:
+ tokAdd(new TokAxisChild());
+ case DESCENDANT_OR_SELF:
+ tokAdd(new TokAxisDescendantOrSelf());
+ case DESCENDANT:
+ tokAdd(new TokAxisDescendant());
+ case FOLLOWING_SIBLING:
+ tokAdd(new TokAxisFollowingSibling());
+ case FOLLOWING:
+ tokAdd(new TokAxisFollowing());
+ case NAMESPACE:
+ tokAdd(new TokAxisNamespace());
+ case PARENT:
+ tokAdd(new TokAxisParent());
+ case PRECEDING_SIBLING:
+ tokAdd(new TokAxisPrecedingSibling());
+ case PRECEDING:
+ tokAdd(new TokAxisPreceding());
+ case SELF:
+ tokAdd(new TokAxisSelf());
+ default:
+ {
+ error("unknown axis type %d", axisType);
+ return -1;
+ }
+ }
return p;
}
@@ -1155,8 +1191,61 @@ int XPathParser::getFunctionCall(int p0, int depth) }
p++;
- if (name == "position")
- tokens.add(new TokPosition());
+ // Function names from http://www.w3.org/TR/xpath#NT-FunctionName
+ if (name == "last")
+ tokens.add(new TokFuncLast());
+ else if (name == "position")
+ tokens.add(new TokFuncPosition());
+ else if (name == "count")
+ tokens.add(new TokFuncCount());
+ else if (name == "id")
+ tokens.add(new TokFuncId());
+ else if (name == "local-name")
+ tokens.add(new TokFuncLocalName());
+ else if (name == "namespace-uri")
+ tokens.add(new TokFuncNamespaceUri());
+ else if (name == "name")
+ tokens.add(new TokFuncName());
+ else if (name == "string")
+ tokens.add(new TokFuncString());
+ else if (name == "concat")
+ tokens.add(new TokFuncConcat());
+ else if (name == "starts-with")
+ tokens.add(new TokFuncStartsWith());
+ else if (name == "contains")
+ tokens.add(new TokFuncContains());
+ else if (name == "substring-before")
+ tokens.add(new TokFuncSubstringBefore());
+ else if (name == "substring-after")
+ tokens.add(new TokFuncSubstringAfter());
+ else if (name == "substring")
+ tokens.add(new TokFuncSubstring());
+ else if (name == "string-length")
+ tokens.add(new TokFuncStringLength());
+ else if (name == "normalize-space")
+ tokens.add(new TokFuncNormalizeSpace());
+ else if (name == "translate")
+ tokens.add(new TokFuncTranslate());
+ else if (name == "boolean")
+ tokens.add(new TokFuncBoolean());
+ else if (name == "not")
+ tokens.add(new TokFuncNot());
+ else if (name == "true")
+ tokens.add(new TokFuncTrue());
+ else if (name == "false")
+ tokens.add(new TokFuncFalse());
+ else if (name == "lang")
+ tokens.add(new TokFuncLang());
+ else if (name == "number")
+ tokens.add(new TokFuncNumber());
+ else if (name == "sum")
+ tokens.add(new TokFuncSum());
+ else if (name == "floor")
+ tokens.add(new TokFuncFloor());
+ else if (name == "ceiling")
+ tokens.add(new TokFuncCeiling());
+ else if (name == "round")
+ tokens.add(new TokFuncRound());
else
{
error("unknown function name:'%s'", name.c_str());
diff --git a/src/dom/xpathtoken.h b/src/dom/xpathtoken.h index f551bee3c..f81a59cc2 100644 --- a/src/dom/xpathtoken.h +++ b/src/dom/xpathtoken.h @@ -214,9 +214,53 @@ public: TOK_NAME_TEST,
TOK_EXPR,
TOK_UNION,
+ //axis types
+ TOK_AXIS_ANCESTOR_OR_SELF,
+ TOK_AXIS_ANCESTOR,
+ TOK_AXIS_ATTRIBUTE,
+ TOK_AXIS_CHILD,
+ TOK_AXIS_DESCENDANT_OR_SELF,
+ TOK_AXIS_DESCENDANT,
+ TOK_AXIS_FOLLOWING_SIBLING,
+ TOK_AXIS_FOLLOWING,
+ TOK_AXIS_NAMESPACE,
+ TOK_AXIS_PARENT,
+ TOK_AXIS_PRECEDING_SIBLING,
+ TOK_AXIS_PRECEDING,
+ TOK_AXIS_SELF,
//function types
- TOK_POSITION
+ TOK_FUNC_LAST,
+ TOK_FUNC_POSITION,
+ TOK_FUNC_COUNT,
+ TOK_FUNC_ID,
+ TOK_FUNC_LOCAL_NAME,
+ TOK_FUNC_NAMESPACE_URI,
+ TOK_FUNC_NAME,
+ TOK_FUNC_STRING,
+ TOK_FUNC_CONCAT,
+ TOK_FUNC_STARTS_WITH,
+ TOK_FUNC_CONTAINS,
+ TOK_FUNC_SUBSTRING_BEFORE,
+ TOK_FUNC_SUBSTRING_AFTER,
+ TOK_FUNC_SUBSTRING,
+ TOK_FUNC_STRING_LENGTH,
+ TOK_FUNC_NORMALIZE_SPACE,
+ TOK_FUNC_TRANSLATE,
+ TOK_FUNC_BOOLEAN,
+ TOK_FUNC_NOT,
+ TOK_FUNC_TRUE,
+ TOK_FUNC_FALSE,
+ TOK_FUNC_LANG,
+ TOK_FUNC_NUMBER,
+ TOK_FUNC_SUM,
+ TOK_FUNC_FLOOR,
+ TOK_FUNC_CEILING,
+ TOK_FUNC_ROUND,
} TokenType;
+
+
+
+
/**
* Constructor with a NOP default type
*/
@@ -710,17 +754,459 @@ public: +
+//###########################
+//# A X I S
+//###########################
+
+
+class TokAxisAncestorOrSelf : public Token
+{
+public:
+ TokAxisAncestorOrSelf()
+ {
+ type = TOK_AXIS_ANCESTOR_OR_SELF;
+ stype = "axis-ancestor-or-self";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokAxisAncestor : public Token
+{
+public:
+ TokAxisAncestor()
+ {
+ type = TOK_AXIS_ANCESTOR;
+ stype = "axis-ancestor";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokAxisAttribute : public Token
+{
+public:
+ TokAxisAttribute()
+ {
+ type = TOK_AXIS_ATTRIBUTE;
+ stype = "axis-attribute";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokAxisChild : public Token
+{
+public:
+ TokAxisChild()
+ {
+ type = TOK_AXIS_CHILD;
+ stype = "axis-child";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokAxisDescendantOrSelf : public Token
+{
+public:
+ TokAxisDescendantOrSelf()
+ {
+ type = TOK_AXIS_DESCENDANT_OR_SELF;
+ stype = "axis-descendant-or-self";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokAxisDescendant : public Token
+{
+public:
+ TokAxisDescendant()
+ {
+ type = TOK_AXIS_DESCENDANT;
+ stype = "axis-descendant";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokAxisFollowingSibling : public Token
+{
+public:
+ TokAxisFollowingSibling()
+ {
+ type = TOK_AXIS_FOLLOWING_SIBLING;
+ stype = "axis-following-sibling";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokAxisFollowing : public Token
+{
+public:
+ TokAxisFollowing()
+ {
+ type = TOK_AXIS_FOLLOWING;
+ stype = "axis-following";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokAxisNamespace : public Token
+{
+public:
+ TokAxisNamespace()
+ {
+ type = TOK_AXIS_NAMESPACE;
+ stype = "axis-namespace";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokAxisParent : public Token
+{
+public:
+ TokAxisParent()
+ {
+ type = TOK_AXIS_PARENT;
+ stype = "axis-parent";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokAxisPrecedingSibling : public Token
+{
+public:
+ TokAxisPrecedingSibling()
+ {
+ type = TOK_AXIS_PRECEDING_SIBLING;
+ stype = "axis-preceding-sibling";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokAxisPreceding : public Token
+{
+public:
+ TokAxisPreceding()
+ {
+ type = TOK_AXIS_PRECEDING;
+ stype = "axis-preceding";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokAxisSelf : public Token
+{
+public:
+ TokAxisSelf()
+ {
+ type = TOK_AXIS_SELF;
+ stype = "axis-self";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+
+
//###########################
//# F U N C T I O N S
//###########################
-class TokPosition : public Token
+class TokFuncLast : public Token
+{
+public:
+ TokFuncLast()
+ {
+ type = TOK_FUNC_LAST;
+ stype = "func-last";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncPosition : public Token
+{
+public:
+ TokFuncPosition()
+ {
+ type = TOK_FUNC_POSITION;
+ stype = "func-position";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncCount : public Token
+{
+public:
+ TokFuncCount()
+ {
+ type = TOK_FUNC_COUNT;
+ stype = "func-count";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncId : public Token
+{
+public:
+ TokFuncId()
+ {
+ type = TOK_FUNC_ID;
+ stype = "func-id";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncLocalName : public Token
+{
+public:
+ TokFuncLocalName()
+ {
+ type = TOK_FUNC_LOCAL_NAME;
+ stype = "func-local-name";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncNamespaceUri : public Token
+{
+public:
+ TokFuncNamespaceUri()
+ {
+ type = TOK_FUNC_NAMESPACE_URI;
+ stype = "func-namespace-uri";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncName : public Token
+{
+public:
+ TokFuncName()
+ {
+ type = TOK_FUNC_NAME;
+ stype = "func-name";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncString : public Token
+{
+public:
+ TokFuncString()
+ {
+ type = TOK_FUNC_STRING;
+ stype = "func-string";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncConcat : public Token
+{
+public:
+ TokFuncConcat()
+ {
+ type = TOK_FUNC_CONCAT;
+ stype = "func-concat";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncStartsWith : public Token
+{
+public:
+ TokFuncStartsWith()
+ {
+ type = TOK_FUNC_STARTS_WITH;
+ stype = "func-starts-with";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncContains : public Token
+{
+public:
+ TokFuncContains()
+ {
+ type = TOK_FUNC_CONTAINS;
+ stype = "func-contains";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncSubstringBefore : public Token
+{
+public:
+ TokFuncSubstringBefore()
+ {
+ type = TOK_FUNC_SUBSTRING_BEFORE;
+ stype = "func-substring-before";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncSubstringAfter : public Token
+{
+public:
+ TokFuncSubstringAfter()
+ {
+ type = TOK_FUNC_SUBSTRING_AFTER;
+ stype = "func-substring-after";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncSubstring : public Token
+{
+public:
+ TokFuncSubstring()
+ {
+ type = TOK_FUNC_SUBSTRING;
+ stype = "func-substring";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncStringLength : public Token
+{
+public:
+ TokFuncStringLength()
+ {
+ type = TOK_FUNC_STRING_LENGTH;
+ stype = "func-string-length";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncNormalizeSpace : public Token
+{
+public:
+ TokFuncNormalizeSpace()
+ {
+ type = TOK_FUNC_NORMALIZE_SPACE;
+ stype = "func-normalize-space";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncTranslate : public Token
+{
+public:
+ TokFuncTranslate()
+ {
+ type = TOK_FUNC_TRANSLATE;
+ stype = "func-translate";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncBoolean : public Token
+{
+public:
+ TokFuncBoolean()
+ {
+ type = TOK_FUNC_BOOLEAN;
+ stype = "func-boolean";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncNot : public Token
{
public:
- TokPosition()
+ TokFuncNot()
{
- type = TOK_POSITION;
- stype = "position";
+ type = TOK_FUNC_NOT;
+ stype = "func-string-length";
}
virtual bool execute(Stack &stack)
{
@@ -728,6 +1214,121 @@ public: }
};
+class TokFuncTrue : public Token
+{
+public:
+ TokFuncTrue()
+ {
+ type = TOK_FUNC_TRUE;
+ stype = "func-true";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncFalse : public Token
+{
+public:
+ TokFuncFalse()
+ {
+ type = TOK_FUNC_FALSE;
+ stype = "func-false";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncLang : public Token
+{
+public:
+ TokFuncLang()
+ {
+ type = TOK_FUNC_LANG;
+ stype = "func-lang";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncNumber : public Token
+{
+public:
+ TokFuncNumber()
+ {
+ type = TOK_FUNC_NUMBER;
+ stype = "func-number";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncSum : public Token
+{
+public:
+ TokFuncSum()
+ {
+ type = TOK_FUNC_SUM;
+ stype = "func-sum";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncFloor : public Token
+{
+public:
+ TokFuncFloor()
+ {
+ type = TOK_FUNC_FLOOR;
+ stype = "func-floor";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncCeiling : public Token
+{
+public:
+ TokFuncCeiling()
+ {
+ type = TOK_FUNC_CEILING;
+ stype = "func-ceiling";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+class TokFuncRound : public Token
+{
+public:
+ TokFuncRound()
+ {
+ type = TOK_FUNC_ROUND;
+ stype = "func-round";
+ }
+ virtual bool execute(Stack &stack)
+ {
+ return true;
+ }
+};
+
+
+
+
//########################################################################
|
