summaryrefslogtreecommitdiffstats
path: root/src/dom/xpathtoken.cpp
diff options
context:
space:
mode:
authorBob Jamison <ishmalius@gmail.com>2006-07-07 01:26:05 +0000
committerishmal <ishmal@users.sourceforge.net>2006-07-07 01:26:05 +0000
commit4096e01820ce6b46d2eb56b7a395faf4d3980354 (patch)
tree7b4e83be5be2f1214da9ab3103b501d252e2a4ef /src/dom/xpathtoken.cpp
parentAdjust to account for removal of svglsimpl (diff)
downloadinkscape-4096e01820ce6b46d2eb56b7a395faf4d3980354.tar.gz
inkscape-4096e01820ce6b46d2eb56b7a395faf4d3980354.zip
rearrange axis/context structure. make tokens more robust
(bzr r1370)
Diffstat (limited to 'src/dom/xpathtoken.cpp')
-rw-r--r--src/dom/xpathtoken.cpp1040
1 files changed, 778 insertions, 262 deletions
diff --git a/src/dom/xpathtoken.cpp b/src/dom/xpathtoken.cpp
index 41b7ad39d..cf51bf9ba 100644
--- a/src/dom/xpathtoken.cpp
+++ b/src/dom/xpathtoken.cpp
@@ -42,354 +42,883 @@ namespace dom
namespace xpath
{
+
+
//########################################################################
//# X P A T H T O K E N
//########################################################################
-typedef struct
+//########################################################################
+//# X P A T H T O K E N T Y P E S
+//########################################################################
+
+
+
+//###########################
+//# V A L U E S
+//###########################
+
+static bool tokStr(Token &tok, TokenExecutor &exec)
{
- int ival;
- char *sval;
-} TokenStringPair;
-
-static TokenStringPair tokenStrings[] =
-{
- //primitives
- { Token::TOK_NOP, "nop" },
- { Token::TOK_STR, "str" },
- { Token::TOK_INT, "int" },
- { Token::TOK_FLOAT, "float" },
- //operators
- { Token::TOK_AND, "and" },
- { Token::TOK_OR, "or" },
- { Token::TOK_MOD, "mod" },
- { Token::TOK_DIV, "div" },
- { Token::TOK_MULTIPLY, "multiply" },
- { Token::TOK_DOUBLE_SLASH, "double-slash" },
- { Token::TOK_SLASH, "slash" },
- { Token::TOK_PIPE, "pipe" },
- { Token::TOK_PLUS, "plus" },
- { Token::TOK_MINUS, "minus" },
- { Token::TOK_NEG, "neg" },
- { Token::TOK_EQUALS, "equals" },
- { Token::TOK_NOT_EQUALS, "not-equals" },
- { Token::TOK_LESS_THAN_EQUALS, "less-than-equals" },
- { Token::TOK_LESS_THAN, "less-than" },
- { Token::TOK_GREATER_THAN_EQUALS, "greater-than-equals" },
- { Token::TOK_GREATER_THAN, "greater-than" },
- //path types
- { Token::TOK_ABSOLUTE, "absolute" },
- { Token::TOK_RELATIVE, "relative" },
- { Token::TOK_STEP, "step" },
- { Token::TOK_NAME_TEST, "name-test" },
- { Token::TOK_EXPR, "expr" },
- { Token::TOK_UNION, "union" },
- //axis types
- { Token::TOK_AXIS_ANCESTOR_OR_SELF, "axis-ancestor-or-self" },
- { Token::TOK_AXIS_ANCESTOR, "axis-ancestor" },
- { Token::TOK_AXIS_ATTRIBUTE, "axis-attribute" },
- { Token::TOK_AXIS_CHILD, "axis-child" },
- { Token::TOK_AXIS_DESCENDANT_OR_SELF, "axis-descendant-or-self" },
- { Token::TOK_AXIS_DESCENDANT, "axis-descendant" },
- { Token::TOK_AXIS_FOLLOWING_SIBLING, "axis-following-sibling" },
- { Token::TOK_AXIS_FOLLOWING, "axis-following" },
- { Token::TOK_AXIS_NAMESPACE, "axis-namespace" },
- { Token::TOK_AXIS_PARENT, "axis-parent" },
- { Token::TOK_AXIS_PRECEDING_SIBLING, "axis-preceding-sibling" },
- { Token::TOK_AXIS_PRECEDING, "axis-preceding" },
- { Token::TOK_AXIS_SELF, "axis-self" },
- //function types
- { Token::TOK_FUNC_LAST, "func-last" },
- { Token::TOK_FUNC_POSITION, "func-position" },
- { Token::TOK_FUNC_COUNT, "func-count" },
- { Token::TOK_FUNC_ID, "func-id" },
- { Token::TOK_FUNC_LOCAL_NAME, "func-local-name" },
- { Token::TOK_FUNC_NAMESPACE_URI, "func-namespace-uri" },
- { Token::TOK_FUNC_NAME, "func-name" },
- { Token::TOK_FUNC_STRING, "func-string" },
- { Token::TOK_FUNC_CONCAT, "func-concat" },
- { Token::TOK_FUNC_STARTS_WITH, "func-starts-with" },
- { Token::TOK_FUNC_CONTAINS, "func-contains" },
- { Token::TOK_FUNC_SUBSTRING_BEFORE, "func-substring-before" },
- { Token::TOK_FUNC_SUBSTRING_AFTER, "func-substring-after" },
- { Token::TOK_FUNC_SUBSTRING, "func-substring" },
- { Token::TOK_FUNC_STRING_LENGTH, "func-string-length" },
- { Token::TOK_FUNC_NORMALIZE_SPACE, "func-normalize-space" },
- { Token::TOK_FUNC_TRANSLATE, "func-translate" },
- { Token::TOK_FUNC_BOOLEAN, "func-boolean" },
- { Token::TOK_FUNC_NOT, "func-not" },
- { Token::TOK_FUNC_TRUE, "func-true" },
- { Token::TOK_FUNC_FALSE, "func-false" },
- { Token::TOK_FUNC_LANG, "func-lang" },
- { Token::TOK_FUNC_NUMBER, "func-number" },
- { Token::TOK_FUNC_SUM, "func-sum" },
- { Token::TOK_FUNC_FLOOR, "func-floor" },
- { Token::TOK_FUNC_CEILING, "func-ceiling" },
- { Token::TOK_FUNC_ROUND, "func-round" },
- { -1, (char *)0 }
-};
+ StackItem item;
+ item.sval = tok.sval;
+ exec.push(item);
+ return true;
+}
+static bool tokFloat(Token &tok, TokenExecutor &exec)
+{
+ StackItem item;
+ item.dval = tok.dval;
+ exec.push(item);
+ return true;
+}
-/**
- * Return the string TokenType of this token
- * (in the .cpp file)
- */
-DOMString Token::getTypeString()
+static bool tokInt(Token &tok, TokenExecutor &exec)
{
- DOMString ret = "unknown";
- for (TokenStringPair *pair = tokenStrings ; pair->sval ; pair++)
- {
- if (pair->ival == type)
- {
- ret = pair->sval;
- break;
- }
- }
- return ret;
+ StackItem item;
+ item.ival = tok.ival;
+ exec.push(item);
+ return true;
}
+static bool tokAnd(Token &tok, TokenExecutor &exec)
+{
+ StackItem item1 = exec.pop();
+ StackItem item2 = exec.pop();
+ item1.ival = item1.ival && item2.ival;
+ exec.push(item1);
+ return true;
+}
+static bool tokOr(Token &tok, TokenExecutor &exec)
+{
+ StackItem item1 = exec.pop();
+ StackItem item2 = exec.pop();
+ item1.ival = item1.ival || item2.ival;
+ exec.push(item1);
+ return true;
+}
-//########################################################################
-//# X P A T H A X I S
-//########################################################################
+static bool tokMod(Token &tok, TokenExecutor &exec)
+{
+ StackItem item1 = exec.pop();
+ StackItem item2 = exec.pop();
+ item1.dval = fmod(item1.dval, item2.dval);
+ exec.push(item1);
+ return true;
+}
-/**
- *
- */
-Axis::Axis()
+
+static bool tokDiv(Token &tok, TokenExecutor &exec)
{
- init();
+ StackItem item1 = exec.pop();
+ StackItem item2 = exec.pop();
+ item1.dval /= item2.dval;
+ exec.push(item1);
+ return true;
}
+static bool tokMul(Token &tok, TokenExecutor &exec)
+{
+ StackItem item1 = exec.pop();
+ StackItem item2 = exec.pop();
+ item1.dval *= item2.dval;
+ exec.push(item1);
+ return true;
+}
-/**
- *
- */
-Axis::Axis(int tokPos)
+static bool tokPlus(Token &tok, TokenExecutor &exec)
{
- init();
- tokenPosition = tokPos;
+ StackItem item1 = exec.pop();
+ StackItem item2 = exec.pop();
+ item1.dval += item2.dval;
+ exec.push(item1);
+ return true;
}
+static bool tokMinus(Token &tok, TokenExecutor &exec)
+{
+ StackItem item1 = exec.pop();
+ StackItem item2 = exec.pop();
+ item1.dval -= item2.dval;
+ exec.push(item1);
+ return true;
+}
-/**
- *
- */
-Axis::Axis(const Axis &other)
+
+static bool tokNeg(Token &tok, TokenExecutor &exec)
{
- init();
- assign(other);
+ StackItem item = exec.pop();
+ item.dval = -item.dval;
+ item.ival = -item.ival;
+ exec.push(item);
+ return true;
}
-/**
- *
- */
-Axis::~Axis()
+static bool tokEquals(Token &tok, TokenExecutor &exec)
{
+ StackItem item1 = exec.pop();
+ StackItem item2 = exec.pop();
+ item1.ival = (item1.dval == item2.dval);
+ exec.push(item1);
+ return true;
}
-/**
- *
- */
-Axis &Axis::operator=(const Axis &other)
+static bool tokNotEquals(Token &tok, TokenExecutor &exec)
{
- assign(other);
- return *this;
+ StackItem item1 = exec.pop();
+ StackItem item2 = exec.pop();
+ item1.ival = (item1.dval != item2.dval);
+ exec.push(item1);
+ return true;
}
-/**
- *
- */
-void Axis::init()
+
+static bool tokLessThan(Token &tok, TokenExecutor &exec)
{
- tokenPosition = 0;
+ StackItem item1 = exec.pop();
+ StackItem item2 = exec.pop();
+ item1.ival = (item1.dval < item2.dval);
+ exec.push(item1);
+ return true;
}
-/**
- *
- */
-void Axis::assign(const Axis &other)
+
+static bool tokLessThanEquals(Token &tok, TokenExecutor &exec)
{
- tokenPosition = other.tokenPosition;
+ StackItem item1 = exec.pop();
+ StackItem item2 = exec.pop();
+ item1.ival = (item1.dval <= item2.dval);
+ exec.push(item1);
+ return true;
}
-/**
- *
- */
-void Axis::setPosition(unsigned int val)
+
+static bool tokGreaterThanEquals(Token &tok, TokenExecutor &exec)
{
- tokenPosition = val;
+ StackItem item1 = exec.pop();
+ StackItem item2 = exec.pop();
+ item1.ival = (item1.dval >= item2.dval);
+ exec.push(item1);
+ return true;
}
-/**
- *
- */
-unsigned int Axis::getPosition()
+
+static bool tokGreaterThan(Token &tok, TokenExecutor &exec)
{
- return tokenPosition;
+ StackItem item1 = exec.pop();
+ StackItem item2 = exec.pop();
+ item1.ival = (item1.dval > item2.dval);
+ exec.push(item1);
+ return true;
}
-/**
- *
- */
-void Axis::setNode(const Node *val)
+
+
+
+
+
+//###########################
+//# X P A T H I T E M S
+//###########################
+
+static bool tokAbsolute(Token &tok, TokenExecutor &exec)
{
- node = (Node *)val;
+ return true;
}
-/**
- *
- */
-Node *Axis::getNode()
+static bool tokRelative(Token &tok, TokenExecutor &exec)
{
- return node;
+ return true;
}
-//########################################################################
-//# X P A T H S T A C K I T E M
-//########################################################################
+static bool tokStep(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
-/**
- *
- */
-StackItem::StackItem()
+static bool tokNameTest(Token &tok, TokenExecutor &exec)
{
- ival = 0L;
- dval = 0.0;
+ return true;
}
+static bool tokExpr(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
-/**
- *
- */
-StackItem::StackItem(const StackItem &other)
+static bool tokUnion(Token &tok, TokenExecutor &exec)
{
- assign(other);
+ return true;
}
-/**
- *
- */
-StackItem::~StackItem()
+
+
+//###########################
+//# A X I S
+//###########################
+
+
+static bool tokAxisAncestorOrSelf(Token &tok, TokenExecutor &exec)
{
+ return true;
}
-/**
- *
- */
-StackItem &StackItem::operator=(const StackItem &other)
+static bool tokAxisAncestor(Token &tok, TokenExecutor &exec)
{
- assign(other);
- return *this;
+ return true;
}
-/**
- *
- */
-void StackItem::assign(const StackItem &other)
+
+static bool tokAxisAttribute(Token &tok, TokenExecutor &exec)
{
- sval = other.sval;
- ival = other.ival;
- dval = other.dval;
+ return true;
}
-//########################################################################
-//# T O K E N L I S T
-//########################################################################
+static bool tokAxisChild(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
-/**
- *
- */
-TokenList::TokenList()
+
+static bool tokAxisDescendantOrSelf(Token &tok, TokenExecutor &exec)
{
+ return true;
}
-/**
- *
- */
-TokenList::TokenList(const TokenList &other)
+static bool tokAxisDescendant(Token &tok, TokenExecutor &exec)
{
- assign(other);
+ return true;
}
-/**
- *
- */
-TokenList &TokenList::operator=(const TokenList &other)
+
+static bool tokAxisFollowingSibling(Token &tok, TokenExecutor &exec)
{
- assign(other);
- return *this;
+ return true;
}
-/**
- *
- */
-void TokenList::assign(const TokenList &other)
+
+static bool tokAxisFollowing(Token &tok, TokenExecutor &exec)
{
- tokens = other.tokens;
+ return true;
}
-/**
- *
- */
-TokenList::~TokenList()
+
+static bool tokAxisNamespace(Token &tok, TokenExecutor &exec)
{
- clear();
+ return true;
}
-/**
- *
- */
-void TokenList::clear()
+
+static bool tokAxisParent(Token &tok, TokenExecutor &exec)
{
- std::vector<Token *>::iterator iter;
- for (iter = tokens.begin() ; iter!= tokens.end() ; iter++)
- {
- delete (*iter);
- }
- tokens.clear();
+ return true;
}
-/**
- *
- */
-void TokenList::add(Token *tok)
+
+static bool tokAxisPrecedingSibling(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokAxisPreceding(Token &tok, TokenExecutor &exec)
{
- tokens.push_back(tok);
+ return true;
}
+static bool tokAxisSelf(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+
+//###########################
+//# F U N C T I O N S
+//###########################
+
+
+static bool tokFuncLast(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncPosition(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncCount(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncId(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncLocalName(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncNamespaceUri(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncName(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncString(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncConcat(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncStartsWith(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncContains(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncSubstringBefore(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncSubstringAfter(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncSubstring(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncStringLength(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncNormalizeSpace(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncTranslate(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncBoolean(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncNot(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncTrue(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncFalse(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncLang(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncNumber(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncSum(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncFloor(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncCeiling(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+static bool tokFuncRound(Token &tok, TokenExecutor &exec)
+{
+ return true;
+}
+
+
+
+
+
+typedef struct
+{
+ int ival;
+ char *sval;
+ TokenFunc tokenFunc;
+} TokenTableEntry;
+
+static TokenTableEntry tokenTable[] =
+{
+ //### primitives
+ {
+ Token::TOK_NOP,
+ "nop",
+ NULL
+ },
+ {
+ Token::TOK_STR,
+ "str",
+ tokStr
+ },
+ {
+ Token::TOK_INT,
+ "int",
+ tokInt
+ },
+ {
+ Token::TOK_FLOAT,
+ "float",
+ tokFloat
+ },
+
+ //### operators
+ {
+ Token::TOK_AND,
+ "and",
+ tokAnd
+ },
+ {
+ Token::TOK_OR,
+ "or",
+ tokOr
+ },
+ {
+ Token::TOK_MOD,
+ "mod",
+ tokMod
+ },
+ {
+ Token::TOK_DIV,
+ "div",
+ tokDiv
+ },
+ {
+ Token::TOK_MUL,
+ "multiply",
+ tokMul
+ },
+ {
+ Token::TOK_DOUBLE_SLASH,
+ "double-slash",
+ NULL
+ },
+ {
+ Token::TOK_SLASH,
+ "slash",
+ NULL
+ },
+ {
+ Token::TOK_PIPE,
+ "pipe",
+ NULL
+ },
+ {
+ Token::TOK_PLUS,
+ "plus",
+ tokPlus
+ },
+ {
+ Token::TOK_MINUS,
+ "minus",
+ tokMinus
+ },
+ {
+ Token::TOK_NEG,
+ "neg",
+ tokNeg
+ },
+ {
+ Token::TOK_EQUALS,
+ "equals",
+ tokEquals
+ },
+ {
+ Token::TOK_NOT_EQUALS,
+ "not-equals",
+ tokNotEquals
+ },
+ {
+ Token::TOK_LESS_THAN_EQUALS,
+ "less-than-equals",
+ tokLessThanEquals
+ },
+ {
+ Token::TOK_LESS_THAN,
+ "less-than",
+ tokLessThan
+ },
+ {
+ Token::TOK_GREATER_THAN_EQUALS,
+ "greater-than-equals",
+ tokGreaterThanEquals
+ },
+ {
+ Token::TOK_GREATER_THAN,
+ "greater-than",
+ tokGreaterThan
+ },
+
+ //### path types
+ {
+ Token::TOK_ABSOLUTE,
+ "absolute",
+ tokAbsolute
+ },
+ {
+ Token::TOK_RELATIVE,
+ "relative",
+ tokRelative
+ },
+ {
+ Token::TOK_STEP,
+ "step",
+ tokStep
+ },
+ {
+ Token::TOK_NAME_TEST,
+ "name-test",
+ tokNameTest
+ },
+ {
+ Token::TOK_EXPR,
+ "expr",
+ tokExpr
+ },
+ {
+ Token::TOK_UNION,
+ "union",
+ tokUnion
+ },
+
+ //### axis types
+ {
+ Token::TOK_AXIS_ANCESTOR_OR_SELF,
+ "axis-ancestor-or-self",
+ tokAxisAncestorOrSelf
+ },
+ {
+ Token::TOK_AXIS_ANCESTOR,
+ "axis-ancestor",
+ tokAxisAncestor
+ },
+ {
+ Token::TOK_AXIS_ATTRIBUTE,
+ "axis-attribute",
+ tokAxisAttribute
+ },
+ {
+ Token::TOK_AXIS_CHILD,
+ "axis-child",
+ tokAxisChild
+ },
+ {
+ Token::TOK_AXIS_DESCENDANT_OR_SELF,
+ "axis-descendant-or-self",
+ tokAxisDescendantOrSelf
+ },
+ {
+ Token::TOK_AXIS_DESCENDANT,
+ "axis-descendant",
+ tokAxisDescendant
+ },
+ {
+ Token::TOK_AXIS_FOLLOWING_SIBLING,
+ "axis-following-sibling",
+ tokAxisFollowingSibling
+ },
+ {
+ Token::TOK_AXIS_FOLLOWING,
+ "axis-following",
+ tokAxisFollowing
+ },
+ {
+ Token::TOK_AXIS_NAMESPACE,
+ "axis-namespace",
+ tokAxisNamespace
+ },
+ {
+ Token::TOK_AXIS_PARENT,
+ "axis-parent",
+ tokAxisParent
+ },
+ {
+ Token::TOK_AXIS_PRECEDING_SIBLING,
+ "axis-preceding-sibling",
+ tokAxisPrecedingSibling
+ },
+ {
+ Token::TOK_AXIS_PRECEDING,
+ "axis-preceding",
+ tokAxisPreceding
+ },
+ {
+ Token::TOK_AXIS_SELF,
+ "axis-self",
+ tokAxisSelf
+ },
+
+ //### function types
+ {
+ Token::TOK_FUNC_LAST,
+ "func-last",
+ tokFuncLast
+ },
+ {
+ Token::TOK_FUNC_POSITION,
+ "func-position",
+ tokFuncPosition
+ },
+ {
+ Token::TOK_FUNC_COUNT,
+ "func-count",
+ tokFuncCount
+ },
+ {
+ Token::TOK_FUNC_ID,
+ "func-id",
+ tokFuncId
+ },
+ {
+ Token::TOK_FUNC_LOCAL_NAME,
+ "func-local-name",
+ tokFuncLocalName
+ },
+ {
+ Token::TOK_FUNC_NAMESPACE_URI,
+ "func-namespace-uri",
+ tokFuncNamespaceUri
+ },
+ {
+ Token::TOK_FUNC_NAME,
+ "func-name",
+ tokFuncName
+ },
+ {
+ Token::TOK_FUNC_STRING,
+ "func-string",
+ tokFuncString
+ },
+ {
+ Token::TOK_FUNC_CONCAT,
+ "func-concat",
+ tokFuncConcat
+ },
+ {
+ Token::TOK_FUNC_STARTS_WITH,
+ "func-starts-with",
+ tokFuncStartsWith
+ },
+ {
+ Token::TOK_FUNC_CONTAINS,
+ "func-contains",
+ tokFuncContains
+ },
+ {
+ Token::TOK_FUNC_SUBSTRING_BEFORE,
+ "func-substring-before",
+ tokFuncSubstringBefore
+ },
+ {
+ Token::TOK_FUNC_SUBSTRING_AFTER,
+ "func-substring-after",
+ tokFuncSubstringAfter
+ },
+ {
+ Token::TOK_FUNC_SUBSTRING,
+ "func-substring",
+ tokFuncSubstring
+ },
+ {
+ Token::TOK_FUNC_STRING_LENGTH,
+ "func-string-length",
+ tokFuncStringLength
+ },
+ {
+ Token::TOK_FUNC_NORMALIZE_SPACE,
+ "func-normalize-space",
+ tokFuncNormalizeSpace
+ },
+ {
+ Token::TOK_FUNC_TRANSLATE,
+ "func-translate",
+ tokFuncTranslate
+ },
+ {
+ Token::TOK_FUNC_BOOLEAN,
+ "func-boolean",
+ tokFuncBoolean
+ },
+ {
+ Token::TOK_FUNC_NOT,
+ "func-not",
+ tokFuncNot
+ },
+ {
+ Token::TOK_FUNC_TRUE,
+ "func-true",
+ tokFuncTrue
+ },
+ {
+ Token::TOK_FUNC_FALSE,
+ "func-false",
+ tokFuncFalse
+ },
+ {
+ Token::TOK_FUNC_LANG,
+ "func-lang",
+ tokFuncLang
+ },
+ {
+ Token::TOK_FUNC_NUMBER,
+ "func-number",
+ tokFuncNumber
+ },
+ {
+ Token::TOK_FUNC_SUM,
+ "func-sum",
+ tokFuncSum
+ },
+ {
+ Token::TOK_FUNC_FLOOR,
+ "func-floor",
+ tokFuncFloor
+ },
+ {
+ Token::TOK_FUNC_CEILING,
+ "func-ceiling",
+ tokFuncCeiling
+ },
+ {
+ Token::TOK_FUNC_ROUND,
+ "func-round",
+ tokFuncRound
+ },
+
+ { -1,
+ (char *)0,
+ NULL
+ }
+};
+
+
/**
- *
+ * Return the string TokenType of this token
+ * (in the .cpp file)
*/
-unsigned int TokenList::size() const
+DOMString Token::getTypeString()
{
- return (unsigned int)tokens.size();
+ DOMString ret = "unknown";
+ for (TokenTableEntry *entry = tokenTable ; entry->sval ; entry++)
+ {
+ if (entry->ival == type)
+ {
+ ret = entry->sval;
+ break;
+ }
+ }
+ return ret;
}
/**
- *
+ * Create a token of the given type, giving it
+ * the data and personalities it needs
*/
-void TokenList::dump()
+Token Token::create(int type, long ival,
+ double dval, const DOMString &sval)
{
- std::vector<Token *>::iterator iter;
- printf("############# TOKENS\n");
- for (iter = tokens.begin() ; iter != tokens.end() ; iter++)
+ Token tok(type, ival, dval, sval);
+ for (TokenTableEntry *entry = tokenTable ; entry->sval ; entry++)
{
- Token *tok = *iter;
- tok->dump();
+ if (entry->ival == type)
+ {
+ tok.tokenFunc = entry->tokenFunc;
+ break;
+ }
}
+
+ return tok;
}
+
+
+
+
+
+
//########################################################################
//# X P A T H E X E C U T O R
//########################################################################
@@ -426,11 +955,8 @@ TokenExecutor::~TokenExecutor()
*/
void TokenExecutor::assign(const TokenExecutor &other)
{
- axis = other.axis;
- axisStack = other.axisStack;
- stackSize = other.stackSize;
- for (int i=0 ; i<stackSize ; i++)
- stack[i] = other.stack[i];
+ tokenList = other.tokenList;
+ stack = other.stack;
}
@@ -439,9 +965,7 @@ void TokenExecutor::assign(const TokenExecutor &other)
*/
void TokenExecutor::reset()
{
- axis.setPosition(0);
- axis.setNode(NULL);
- stackSize = 0;
+ stack.clear();
}
@@ -453,15 +977,8 @@ void TokenExecutor::reset()
NodeList TokenExecutor::execute(const TokenList &tokens, const Node *node)
{
- axis.setPosition(0);
- axis.setNode(node);
-
nodeList.clear();
- while (axis.getPosition() < tokens.size())
- {
- }
-
return nodeList;
}
@@ -474,11 +991,7 @@ NodeList TokenExecutor::execute(const TokenList &tokens, const Node *node)
*/
void TokenExecutor::push(StackItem &item)
{
- if (stackSize>=STACK_SIZE)
- {
- return;
- }
- stack[stackSize++] = item;
+ stack.push_back(item);
}
/**
@@ -486,12 +999,15 @@ void TokenExecutor::push(StackItem &item)
*/
StackItem TokenExecutor::pop()
{
- if (stackSize<1)
+ if (stack.size()<1)
{
StackItem item;
return item;
}
- return stack[--stackSize];
+ std::vector<StackItem>::iterator iter = stack.end()-1;
+ StackItem item = *iter;
+ stack.erase(iter);
+ return item;
}