]> git.tokkee.org Git - inkscape.git/commitdiff

Code

Add axis and function token stubs to token set
authorishmal <ishmal@users.sourceforge.net>
Thu, 27 Apr 2006 15:26:43 +0000 (15:26 +0000)
committerishmal <ishmal@users.sourceforge.net>
Thu, 27 Apr 2006 15:26:43 +0000 (15:26 +0000)
src/dom/xpathparser.cpp
src/dom/xpathtoken.h

index 18d62d40a36bcd345d9b184ebbdfc20a021cefbf..47a9a146af80c3f7fe875ef2c2d05d7f77d3f20b 100644 (file)
@@ -817,6 +817,8 @@ int XPathParser::getAxisSpecifier(int p0, int depth)
     int p = p0;\r
     if (lexTokType(p) == AXIS_NAME)\r
         {\r
+        LexTok t = lexTok(p);\r
+        int axisType = t.getIntValue();\r
         p++;\r
         if (lexTokType(p) != DOUBLE_COLON)\r
             {\r
@@ -824,6 +826,40 @@ int XPathParser::getAxisSpecifier(int p0, int depth)
             return -1;\r
             }\r
         p++;\r
+        switch (axisType)\r
+            {\r
+            case ANCESTOR_OR_SELF:\r
+                tokAdd(new TokAxisAncestorOrSelf());\r
+            case ANCESTOR:\r
+                tokAdd(new TokAxisAncestor());\r
+            case ATTRIBUTE:\r
+                tokAdd(new TokAxisAttribute());\r
+            case CHILD:\r
+                tokAdd(new TokAxisChild());\r
+            case DESCENDANT_OR_SELF:\r
+                tokAdd(new TokAxisDescendantOrSelf());\r
+            case DESCENDANT:\r
+                tokAdd(new TokAxisDescendant());\r
+            case FOLLOWING_SIBLING:\r
+                tokAdd(new TokAxisFollowingSibling());\r
+            case FOLLOWING:\r
+                tokAdd(new TokAxisFollowing());\r
+            case NAMESPACE:\r
+                tokAdd(new TokAxisNamespace());\r
+            case PARENT:\r
+                tokAdd(new TokAxisParent());\r
+            case PRECEDING_SIBLING:\r
+                tokAdd(new TokAxisPrecedingSibling());\r
+            case PRECEDING:\r
+                tokAdd(new TokAxisPreceding());\r
+            case SELF:\r
+                tokAdd(new TokAxisSelf());\r
+            default:\r
+                {\r
+                error("unknown axis type %d", axisType);\r
+                return -1;\r
+                }\r
+            }\r
         return p;\r
         }\r
 \r
@@ -1155,8 +1191,61 @@ int XPathParser::getFunctionCall(int p0, int depth)
         }\r
     p++;\r
 \r
-    if (name == "position")\r
-        tokens.add(new TokPosition());\r
+    // Function names from http://www.w3.org/TR/xpath#NT-FunctionName\r
+    if (name == "last")\r
+        tokens.add(new TokFuncLast());\r
+    else if (name == "position")\r
+        tokens.add(new TokFuncPosition());\r
+    else if (name == "count")\r
+        tokens.add(new TokFuncCount());\r
+    else if (name == "id")\r
+        tokens.add(new TokFuncId());\r
+    else if (name == "local-name")\r
+        tokens.add(new TokFuncLocalName());\r
+    else if (name == "namespace-uri")\r
+        tokens.add(new TokFuncNamespaceUri());\r
+    else if (name == "name")\r
+        tokens.add(new TokFuncName());\r
+    else if (name == "string")\r
+        tokens.add(new TokFuncString());\r
+    else if (name == "concat")\r
+        tokens.add(new TokFuncConcat());\r
+    else if (name == "starts-with")\r
+        tokens.add(new TokFuncStartsWith());\r
+    else if (name == "contains")\r
+        tokens.add(new TokFuncContains());\r
+    else if (name == "substring-before")\r
+        tokens.add(new TokFuncSubstringBefore());\r
+    else if (name == "substring-after")\r
+        tokens.add(new TokFuncSubstringAfter());\r
+    else if (name == "substring")\r
+        tokens.add(new TokFuncSubstring());\r
+    else if (name == "string-length")\r
+        tokens.add(new TokFuncStringLength());\r
+    else if (name == "normalize-space")\r
+        tokens.add(new TokFuncNormalizeSpace());\r
+    else if (name == "translate")\r
+        tokens.add(new TokFuncTranslate());\r
+    else if (name == "boolean")\r
+        tokens.add(new TokFuncBoolean());\r
+    else if (name == "not")\r
+        tokens.add(new TokFuncNot());\r
+    else if (name == "true")\r
+        tokens.add(new TokFuncTrue());\r
+    else if (name == "false")\r
+        tokens.add(new TokFuncFalse());\r
+    else if (name == "lang")\r
+        tokens.add(new TokFuncLang());\r
+    else if (name == "number")\r
+        tokens.add(new TokFuncNumber());\r
+    else if (name == "sum")\r
+        tokens.add(new TokFuncSum());\r
+    else if (name == "floor")\r
+        tokens.add(new TokFuncFloor());\r
+    else if (name == "ceiling")\r
+        tokens.add(new TokFuncCeiling());\r
+    else if (name == "round")\r
+        tokens.add(new TokFuncRound());\r
     else\r
         {\r
         error("unknown function name:'%s'", name.c_str());\r
index f551bee3c193ff81d864c52841a4be6e169512f5..f81a59cc268d62438e0e5c3b9f3cb863512a65c0 100644 (file)
@@ -214,9 +214,53 @@ public:
         TOK_NAME_TEST,\r
         TOK_EXPR,\r
         TOK_UNION,\r
+        //axis types\r
+        TOK_AXIS_ANCESTOR_OR_SELF,\r
+        TOK_AXIS_ANCESTOR,\r
+        TOK_AXIS_ATTRIBUTE,\r
+        TOK_AXIS_CHILD,\r
+        TOK_AXIS_DESCENDANT_OR_SELF,\r
+        TOK_AXIS_DESCENDANT,\r
+        TOK_AXIS_FOLLOWING_SIBLING,\r
+        TOK_AXIS_FOLLOWING,\r
+        TOK_AXIS_NAMESPACE,\r
+        TOK_AXIS_PARENT,\r
+        TOK_AXIS_PRECEDING_SIBLING,\r
+        TOK_AXIS_PRECEDING,\r
+        TOK_AXIS_SELF,\r
         //function types\r
-        TOK_POSITION\r
+        TOK_FUNC_LAST,\r
+        TOK_FUNC_POSITION,\r
+        TOK_FUNC_COUNT,\r
+        TOK_FUNC_ID,\r
+        TOK_FUNC_LOCAL_NAME,\r
+        TOK_FUNC_NAMESPACE_URI,\r
+        TOK_FUNC_NAME,\r
+        TOK_FUNC_STRING,\r
+        TOK_FUNC_CONCAT,\r
+        TOK_FUNC_STARTS_WITH,\r
+        TOK_FUNC_CONTAINS,\r
+        TOK_FUNC_SUBSTRING_BEFORE,\r
+        TOK_FUNC_SUBSTRING_AFTER,\r
+        TOK_FUNC_SUBSTRING,\r
+        TOK_FUNC_STRING_LENGTH,\r
+        TOK_FUNC_NORMALIZE_SPACE,\r
+        TOK_FUNC_TRANSLATE,\r
+        TOK_FUNC_BOOLEAN,\r
+        TOK_FUNC_NOT,\r
+        TOK_FUNC_TRUE,\r
+        TOK_FUNC_FALSE,\r
+        TOK_FUNC_LANG,\r
+        TOK_FUNC_NUMBER,\r
+        TOK_FUNC_SUM,\r
+        TOK_FUNC_FLOOR,\r
+        TOK_FUNC_CEILING,\r
+        TOK_FUNC_ROUND,\r
         } TokenType;\r
+\r
+\r
+\r
+\r
     /**\r
      *  Constructor with a NOP default type\r
      */\r
@@ -710,17 +754,459 @@ public:
 \r
 \r
 \r
+\r
+//###########################\r
+//# A X I S\r
+//###########################\r
+\r
+\r
+class TokAxisAncestorOrSelf : public Token\r
+{\r
+public:\r
+    TokAxisAncestorOrSelf()\r
+        {\r
+        type = TOK_AXIS_ANCESTOR_OR_SELF;\r
+        stype = "axis-ancestor-or-self";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokAxisAncestor : public Token\r
+{\r
+public:\r
+    TokAxisAncestor()\r
+        {\r
+        type = TOK_AXIS_ANCESTOR;\r
+        stype = "axis-ancestor";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokAxisAttribute : public Token\r
+{\r
+public:\r
+    TokAxisAttribute()\r
+        {\r
+        type = TOK_AXIS_ATTRIBUTE;\r
+        stype = "axis-attribute";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokAxisChild : public Token\r
+{\r
+public:\r
+    TokAxisChild()\r
+        {\r
+        type = TOK_AXIS_CHILD;\r
+        stype = "axis-child";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokAxisDescendantOrSelf : public Token\r
+{\r
+public:\r
+    TokAxisDescendantOrSelf()\r
+        {\r
+        type = TOK_AXIS_DESCENDANT_OR_SELF;\r
+        stype = "axis-descendant-or-self";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokAxisDescendant : public Token\r
+{\r
+public:\r
+    TokAxisDescendant()\r
+        {\r
+        type = TOK_AXIS_DESCENDANT;\r
+        stype = "axis-descendant";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokAxisFollowingSibling : public Token\r
+{\r
+public:\r
+    TokAxisFollowingSibling()\r
+        {\r
+        type = TOK_AXIS_FOLLOWING_SIBLING;\r
+        stype = "axis-following-sibling";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokAxisFollowing : public Token\r
+{\r
+public:\r
+    TokAxisFollowing()\r
+        {\r
+        type = TOK_AXIS_FOLLOWING;\r
+        stype = "axis-following";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokAxisNamespace : public Token\r
+{\r
+public:\r
+    TokAxisNamespace()\r
+        {\r
+        type = TOK_AXIS_NAMESPACE;\r
+        stype = "axis-namespace";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokAxisParent : public Token\r
+{\r
+public:\r
+    TokAxisParent()\r
+        {\r
+        type = TOK_AXIS_PARENT;\r
+        stype = "axis-parent";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokAxisPrecedingSibling : public Token\r
+{\r
+public:\r
+    TokAxisPrecedingSibling()\r
+        {\r
+        type = TOK_AXIS_PRECEDING_SIBLING;\r
+        stype = "axis-preceding-sibling";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokAxisPreceding : public Token\r
+{\r
+public:\r
+    TokAxisPreceding()\r
+        {\r
+        type = TOK_AXIS_PRECEDING;\r
+        stype = "axis-preceding";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokAxisSelf : public Token\r
+{\r
+public:\r
+    TokAxisSelf()\r
+        {\r
+        type = TOK_AXIS_SELF;\r
+        stype = "axis-self";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+\r
+\r
 //###########################\r
 //# F U N C T I O N S\r
 //###########################\r
 \r
-class TokPosition : public Token\r
+class TokFuncLast : public Token\r
+{\r
+public:\r
+    TokFuncLast()\r
+        {\r
+        type = TOK_FUNC_LAST;\r
+        stype = "func-last";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncPosition : public Token\r
+{\r
+public:\r
+    TokFuncPosition()\r
+        {\r
+        type = TOK_FUNC_POSITION;\r
+        stype = "func-position";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncCount : public Token\r
+{\r
+public:\r
+    TokFuncCount()\r
+        {\r
+        type = TOK_FUNC_COUNT;\r
+        stype = "func-count";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncId : public Token\r
+{\r
+public:\r
+    TokFuncId()\r
+        {\r
+        type = TOK_FUNC_ID;\r
+        stype = "func-id";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncLocalName : public Token\r
+{\r
+public:\r
+    TokFuncLocalName()\r
+        {\r
+        type = TOK_FUNC_LOCAL_NAME;\r
+        stype = "func-local-name";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncNamespaceUri : public Token\r
+{\r
+public:\r
+    TokFuncNamespaceUri()\r
+        {\r
+        type = TOK_FUNC_NAMESPACE_URI;\r
+        stype = "func-namespace-uri";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncName : public Token\r
+{\r
+public:\r
+    TokFuncName()\r
+        {\r
+        type = TOK_FUNC_NAME;\r
+        stype = "func-name";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncString : public Token\r
+{\r
+public:\r
+    TokFuncString()\r
+        {\r
+        type = TOK_FUNC_STRING;\r
+        stype = "func-string";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncConcat : public Token\r
+{\r
+public:\r
+    TokFuncConcat()\r
+        {\r
+        type = TOK_FUNC_CONCAT;\r
+        stype = "func-concat";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncStartsWith : public Token\r
+{\r
+public:\r
+    TokFuncStartsWith()\r
+        {\r
+        type = TOK_FUNC_STARTS_WITH;\r
+        stype = "func-starts-with";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncContains : public Token\r
+{\r
+public:\r
+    TokFuncContains()\r
+        {\r
+        type = TOK_FUNC_CONTAINS;\r
+        stype = "func-contains";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncSubstringBefore : public Token\r
+{\r
+public:\r
+    TokFuncSubstringBefore()\r
+        {\r
+        type = TOK_FUNC_SUBSTRING_BEFORE;\r
+        stype = "func-substring-before";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncSubstringAfter : public Token\r
+{\r
+public:\r
+    TokFuncSubstringAfter()\r
+        {\r
+        type = TOK_FUNC_SUBSTRING_AFTER;\r
+        stype = "func-substring-after";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncSubstring : public Token\r
+{\r
+public:\r
+    TokFuncSubstring()\r
+        {\r
+        type = TOK_FUNC_SUBSTRING;\r
+        stype = "func-substring";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncStringLength : public Token\r
+{\r
+public:\r
+    TokFuncStringLength()\r
+        {\r
+        type = TOK_FUNC_STRING_LENGTH;\r
+        stype = "func-string-length";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncNormalizeSpace : public Token\r
+{\r
+public:\r
+    TokFuncNormalizeSpace()\r
+        {\r
+        type = TOK_FUNC_NORMALIZE_SPACE;\r
+        stype = "func-normalize-space";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncTranslate : public Token\r
+{\r
+public:\r
+    TokFuncTranslate()\r
+        {\r
+        type = TOK_FUNC_TRANSLATE;\r
+        stype = "func-translate";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncBoolean : public Token\r
+{\r
+public:\r
+    TokFuncBoolean()\r
+        {\r
+        type = TOK_FUNC_BOOLEAN;\r
+        stype = "func-boolean";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncNot : public Token\r
 {\r
 public:\r
-    TokPosition()\r
+    TokFuncNot()\r
         {\r
-        type = TOK_POSITION;\r
-        stype = "position";\r
+        type = TOK_FUNC_NOT;\r
+        stype = "func-string-length";\r
         }\r
     virtual bool execute(Stack &stack)\r
         {\r
@@ -728,6 +1214,121 @@ public:
         }\r
 };\r
 \r
+class TokFuncTrue : public Token\r
+{\r
+public:\r
+    TokFuncTrue()\r
+        {\r
+        type = TOK_FUNC_TRUE;\r
+        stype = "func-true";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncFalse : public Token\r
+{\r
+public:\r
+    TokFuncFalse()\r
+        {\r
+        type = TOK_FUNC_FALSE;\r
+        stype = "func-false";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncLang : public Token\r
+{\r
+public:\r
+    TokFuncLang()\r
+        {\r
+        type = TOK_FUNC_LANG;\r
+        stype = "func-lang";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncNumber : public Token\r
+{\r
+public:\r
+    TokFuncNumber()\r
+        {\r
+        type = TOK_FUNC_NUMBER;\r
+        stype = "func-number";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncSum : public Token\r
+{\r
+public:\r
+    TokFuncSum()\r
+        {\r
+        type = TOK_FUNC_SUM;\r
+        stype = "func-sum";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncFloor : public Token\r
+{\r
+public:\r
+    TokFuncFloor()\r
+        {\r
+        type = TOK_FUNC_FLOOR;\r
+        stype = "func-floor";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncCeiling : public Token\r
+{\r
+public:\r
+    TokFuncCeiling()\r
+        {\r
+        type = TOK_FUNC_CEILING;\r
+        stype = "func-ceiling";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+class TokFuncRound : public Token\r
+{\r
+public:\r
+    TokFuncRound()\r
+        {\r
+        type = TOK_FUNC_ROUND;\r
+        stype = "func-round";\r
+        }\r
+    virtual bool execute(Stack &stack)\r
+        {\r
+        return true;\r
+        }\r
+};\r
+\r
+\r
+\r
+\r
 \r
 \r
 //########################################################################\r