2005-11-02 10:42:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2005-11-02 10:34:13 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Lexical analyzer for XPath expressions
|
2005-11-02 10:41:11 +03:00
|
|
|
*/
|
2005-11-02 10:34:13 +03:00
|
|
|
|
2005-11-02 20:34:14 +03:00
|
|
|
#include "txExprLexer.h"
|
2011-09-20 00:07:17 +04:00
|
|
|
#include "nsGkAtoms.h"
|
2005-11-02 10:41:11 +03:00
|
|
|
#include "nsString.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2005-11-02 20:34:14 +03:00
|
|
|
#include "txXMLUtils.h"
|
2005-11-02 10:34:13 +03:00
|
|
|
|
|
|
|
/**
|
2005-11-02 10:41:11 +03:00
|
|
|
* Creates a new ExprLexer
|
|
|
|
*/
|
|
|
|
txExprLexer::txExprLexer()
|
2018-04-13 16:01:28 +03:00
|
|
|
: mCurrentItem(nullptr),
|
|
|
|
mFirstItem(nullptr),
|
|
|
|
mLastItem(nullptr),
|
|
|
|
mTokenCount(0)
|
2005-11-02 10:36:37 +03:00
|
|
|
{
|
2005-11-02 10:41:11 +03:00
|
|
|
}
|
2005-11-02 10:34:13 +03:00
|
|
|
|
|
|
|
/**
|
2005-11-02 10:41:11 +03:00
|
|
|
* Destroys this instance of an txExprLexer
|
|
|
|
*/
|
|
|
|
txExprLexer::~txExprLexer()
|
2005-11-02 10:36:37 +03:00
|
|
|
{
|
|
|
|
//-- delete tokens
|
2005-11-02 10:41:11 +03:00
|
|
|
Token* tok = mFirstItem;
|
|
|
|
while (tok) {
|
|
|
|
Token* temp = tok->mNext;
|
|
|
|
delete tok;
|
|
|
|
tok = temp;
|
2005-11-02 10:36:37 +03:00
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
mCurrentItem = nullptr;
|
2005-11-02 10:41:11 +03:00
|
|
|
}
|
2005-11-02 10:34:13 +03:00
|
|
|
|
2005-11-02 10:41:11 +03:00
|
|
|
Token*
|
|
|
|
txExprLexer::nextToken()
|
2005-11-02 10:36:37 +03:00
|
|
|
{
|
2012-04-27 01:46:44 +04:00
|
|
|
if (!mCurrentItem) {
|
|
|
|
NS_NOTREACHED("nextToken called on uninitialized lexer");
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2012-04-27 01:46:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mCurrentItem->mType == Token::END) {
|
|
|
|
// Do not progress beyond the end token
|
|
|
|
return mCurrentItem;
|
|
|
|
}
|
|
|
|
|
2005-11-02 10:41:11 +03:00
|
|
|
Token* token = mCurrentItem;
|
|
|
|
mCurrentItem = mCurrentItem->mNext;
|
|
|
|
return token;
|
|
|
|
}
|
2005-11-02 10:34:13 +03:00
|
|
|
|
2005-11-02 10:41:11 +03:00
|
|
|
void
|
|
|
|
txExprLexer::addToken(Token* aToken)
|
2005-11-02 10:36:37 +03:00
|
|
|
{
|
2005-11-02 10:41:11 +03:00
|
|
|
if (mLastItem) {
|
|
|
|
mLastItem->mNext = aToken;
|
2005-11-02 10:36:37 +03:00
|
|
|
}
|
2005-11-02 10:41:11 +03:00
|
|
|
if (!mFirstItem) {
|
|
|
|
mFirstItem = aToken;
|
|
|
|
mCurrentItem = aToken;
|
|
|
|
}
|
|
|
|
mLastItem = aToken;
|
|
|
|
++mTokenCount;
|
|
|
|
}
|
2005-11-02 10:34:13 +03:00
|
|
|
|
|
|
|
/**
|
2005-11-02 10:36:37 +03:00
|
|
|
* Returns true if the following Token should be an operator.
|
|
|
|
* This is a helper for the first bullet of [XPath 3.7]
|
|
|
|
* Lexical Structure
|
2005-11-02 10:41:11 +03:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2005-11-02 10:41:11 +03:00
|
|
|
txExprLexer::nextIsOperatorToken(Token* aToken)
|
2005-11-02 10:36:37 +03:00
|
|
|
{
|
2005-11-02 10:41:11 +03:00
|
|
|
if (!aToken || aToken->mType == Token::NULL_TOKEN) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2005-11-02 10:41:11 +03:00
|
|
|
}
|
2005-11-02 20:34:14 +03:00
|
|
|
/* This relies on the tokens having the right order in txExprLexer.h */
|
2005-11-02 10:41:11 +03:00
|
|
|
return aToken->mType < Token::COMMA ||
|
|
|
|
aToken->mType > Token::UNION_OP;
|
|
|
|
|
|
|
|
}
|
2005-11-02 10:34:13 +03:00
|
|
|
|
|
|
|
/**
|
2005-11-02 10:41:11 +03:00
|
|
|
* Parses the given string into a sequence of Tokens
|
|
|
|
*/
|
|
|
|
nsresult
|
2017-06-20 12:18:17 +03:00
|
|
|
txExprLexer::parse(const nsAString& aPattern)
|
2005-11-02 10:36:37 +03:00
|
|
|
{
|
2018-02-27 16:37:19 +03:00
|
|
|
iterator end;
|
|
|
|
aPattern.BeginReading(mPosition);
|
2005-11-02 10:41:11 +03:00
|
|
|
aPattern.EndReading(end);
|
2005-11-02 10:36:37 +03:00
|
|
|
|
|
|
|
//-- initialize previous token, this will automatically get
|
|
|
|
//-- deleted when it goes out of scope
|
2012-07-30 18:20:58 +04:00
|
|
|
Token nullToken(nullptr, nullptr, Token::NULL_TOKEN);
|
2005-11-02 10:36:37 +03:00
|
|
|
|
2005-11-02 10:41:11 +03:00
|
|
|
Token::Type defType;
|
2012-07-30 18:20:58 +04:00
|
|
|
Token* newToken = nullptr;
|
2005-11-02 10:41:11 +03:00
|
|
|
Token* prevToken = &nullToken;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isToken;
|
2005-11-02 10:36:37 +03:00
|
|
|
|
2005-11-02 10:41:11 +03:00
|
|
|
while (mPosition < end) {
|
2005-11-02 10:36:37 +03:00
|
|
|
|
|
|
|
defType = Token::CNAME;
|
2011-10-17 18:59:28 +04:00
|
|
|
isToken = true;
|
2005-11-02 10:36:37 +03:00
|
|
|
|
2005-11-02 10:41:11 +03:00
|
|
|
if (*mPosition == DOLLAR_SIGN) {
|
|
|
|
if (++mPosition == end || !XMLUtils::isLetter(*mPosition)) {
|
|
|
|
return NS_ERROR_XPATH_INVALID_VAR_NAME;
|
2005-11-02 10:36:37 +03:00
|
|
|
}
|
2005-11-02 10:41:11 +03:00
|
|
|
defType = Token::VAR_REFERENCE;
|
2017-07-06 15:00:35 +03:00
|
|
|
}
|
|
|
|
// just reuse the QName parsing, which will use defType
|
2005-11-02 10:36:37 +03:00
|
|
|
// the token to construct
|
|
|
|
|
2005-11-02 10:41:11 +03:00
|
|
|
if (XMLUtils::isLetter(*mPosition)) {
|
2005-11-02 10:36:37 +03:00
|
|
|
// NCName, can get QName or OperatorName;
|
|
|
|
// FunctionName, NodeName, and AxisSpecifier may want whitespace,
|
|
|
|
// and are dealt with below
|
2018-02-27 16:37:19 +03:00
|
|
|
iterator start = mPosition;
|
2005-11-02 10:41:11 +03:00
|
|
|
while (++mPosition < end && XMLUtils::isNCNameChar(*mPosition)) {
|
|
|
|
/* just go */
|
|
|
|
}
|
|
|
|
if (mPosition < end && *mPosition == COLON) {
|
2005-11-02 10:36:37 +03:00
|
|
|
// try QName or wildcard, might need to step back for axis
|
2005-11-02 10:41:11 +03:00
|
|
|
if (++mPosition == end) {
|
|
|
|
return NS_ERROR_XPATH_UNEXPECTED_END;
|
|
|
|
}
|
|
|
|
if (XMLUtils::isLetter(*mPosition)) {
|
|
|
|
while (++mPosition < end && XMLUtils::isNCNameChar(*mPosition)) {
|
|
|
|
/* just go */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (*mPosition == '*' && defType != Token::VAR_REFERENCE) {
|
|
|
|
// eat wildcard for NameTest, bail for var ref at COLON
|
|
|
|
++mPosition;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
--mPosition; // step back
|
|
|
|
}
|
2005-11-02 10:36:37 +03:00
|
|
|
}
|
|
|
|
if (nextIsOperatorToken(prevToken)) {
|
2010-03-08 18:45:00 +03:00
|
|
|
nsDependentSubstring op(Substring(start, mPosition));
|
2011-09-20 00:07:17 +04:00
|
|
|
if (nsGkAtoms::_and->Equals(op)) {
|
2005-11-02 10:36:37 +03:00
|
|
|
defType = Token::AND_OP;
|
2005-11-02 10:41:11 +03:00
|
|
|
}
|
2011-09-20 00:07:17 +04:00
|
|
|
else if (nsGkAtoms::_or->Equals(op)) {
|
2005-11-02 10:36:37 +03:00
|
|
|
defType = Token::OR_OP;
|
2005-11-02 10:41:11 +03:00
|
|
|
}
|
2011-09-20 00:07:17 +04:00
|
|
|
else if (nsGkAtoms::mod->Equals(op)) {
|
2005-11-02 10:36:37 +03:00
|
|
|
defType = Token::MODULUS_OP;
|
2005-11-02 10:41:11 +03:00
|
|
|
}
|
2011-09-20 00:07:17 +04:00
|
|
|
else if (nsGkAtoms::div->Equals(op)) {
|
2005-11-02 10:36:37 +03:00
|
|
|
defType = Token::DIVIDE_OP;
|
2005-11-02 10:41:11 +03:00
|
|
|
}
|
2005-11-02 10:36:37 +03:00
|
|
|
else {
|
|
|
|
// XXX QUESTION: spec is not too precise
|
|
|
|
// badops is sure an error, but is bad:ops, too? We say yes!
|
2005-11-02 10:41:11 +03:00
|
|
|
return NS_ERROR_XPATH_OPERATOR_EXPECTED;
|
2005-11-02 10:34:13 +03:00
|
|
|
}
|
2005-11-02 10:36:37 +03:00
|
|
|
}
|
2005-11-02 10:41:11 +03:00
|
|
|
newToken = new Token(start, mPosition, defType);
|
2005-11-02 10:34:13 +03:00
|
|
|
}
|
2005-11-02 10:41:11 +03:00
|
|
|
else if (isXPathDigit(*mPosition)) {
|
2018-02-27 16:37:19 +03:00
|
|
|
iterator start = mPosition;
|
2005-11-02 10:41:11 +03:00
|
|
|
while (++mPosition < end && isXPathDigit(*mPosition)) {
|
|
|
|
/* just go */
|
|
|
|
}
|
|
|
|
if (mPosition < end && *mPosition == '.') {
|
|
|
|
while (++mPosition < end && isXPathDigit(*mPosition)) {
|
|
|
|
/* just go */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
newToken = new Token(start, mPosition, Token::NUMBER);
|
2005-11-02 10:34:13 +03:00
|
|
|
}
|
2005-11-02 10:36:37 +03:00
|
|
|
else {
|
2005-11-02 10:41:11 +03:00
|
|
|
switch (*mPosition) {
|
2005-11-02 10:36:37 +03:00
|
|
|
//-- ignore whitespace
|
|
|
|
case SPACE:
|
|
|
|
case TX_TAB:
|
|
|
|
case TX_CR:
|
|
|
|
case TX_LF:
|
2005-11-02 10:41:11 +03:00
|
|
|
++mPosition;
|
2011-10-17 18:59:28 +04:00
|
|
|
isToken = false;
|
2005-11-02 10:36:37 +03:00
|
|
|
break;
|
|
|
|
case S_QUOTE :
|
|
|
|
case D_QUOTE :
|
2018-02-27 16:37:19 +03:00
|
|
|
{
|
|
|
|
iterator start = mPosition;
|
2005-11-02 10:41:11 +03:00
|
|
|
while (++mPosition < end && *mPosition != *start) {
|
|
|
|
// eat literal
|
2005-11-02 10:34:13 +03:00
|
|
|
}
|
2005-11-02 10:41:11 +03:00
|
|
|
if (mPosition == end) {
|
|
|
|
mPosition = start;
|
|
|
|
return NS_ERROR_XPATH_UNCLOSED_LITERAL;
|
2005-11-02 10:34:13 +03:00
|
|
|
}
|
2005-11-02 10:41:11 +03:00
|
|
|
newToken = new Token(start + 1, mPosition, Token::LITERAL);
|
|
|
|
++mPosition;
|
2018-02-27 16:37:19 +03:00
|
|
|
}
|
|
|
|
break;
|
2005-11-02 10:36:37 +03:00
|
|
|
case PERIOD:
|
|
|
|
// period can be .., .(DIGITS)+ or ., check next
|
2005-11-02 10:41:11 +03:00
|
|
|
if (++mPosition == end) {
|
|
|
|
newToken = new Token(mPosition - 1, Token::SELF_NODE);
|
|
|
|
}
|
|
|
|
else if (isXPathDigit(*mPosition)) {
|
2018-02-27 16:37:19 +03:00
|
|
|
iterator start = mPosition - 1;
|
2005-11-02 10:41:11 +03:00
|
|
|
while (++mPosition < end && isXPathDigit(*mPosition)) {
|
|
|
|
/* just go */
|
2005-11-02 10:36:37 +03:00
|
|
|
}
|
2005-11-02 10:41:11 +03:00
|
|
|
newToken = new Token(start, mPosition, Token::NUMBER);
|
2005-11-02 10:34:13 +03:00
|
|
|
}
|
2005-11-02 10:41:11 +03:00
|
|
|
else if (*mPosition == PERIOD) {
|
|
|
|
++mPosition;
|
|
|
|
newToken = new Token(mPosition - 2, mPosition, Token::PARENT_NODE);
|
2005-11-02 10:34:13 +03:00
|
|
|
}
|
|
|
|
else {
|
2005-11-02 10:41:11 +03:00
|
|
|
newToken = new Token(mPosition - 1, Token::SELF_NODE);
|
2005-11-02 10:34:13 +03:00
|
|
|
}
|
2005-11-02 10:36:37 +03:00
|
|
|
break;
|
2005-11-02 10:41:11 +03:00
|
|
|
case COLON: // QNames are dealt above, must be axis ident
|
|
|
|
if (++mPosition >= end || *mPosition != COLON ||
|
|
|
|
prevToken->mType != Token::CNAME) {
|
|
|
|
return NS_ERROR_XPATH_BAD_COLON;
|
|
|
|
}
|
|
|
|
prevToken->mType = Token::AXIS_IDENTIFIER;
|
|
|
|
++mPosition;
|
2011-10-17 18:59:28 +04:00
|
|
|
isToken = false;
|
2005-11-02 10:41:11 +03:00
|
|
|
break;
|
2005-11-02 10:36:37 +03:00
|
|
|
case FORWARD_SLASH :
|
2005-11-02 10:41:11 +03:00
|
|
|
if (++mPosition < end && *mPosition == FORWARD_SLASH) {
|
|
|
|
++mPosition;
|
|
|
|
newToken = new Token(mPosition - 2, mPosition, Token::ANCESTOR_OP);
|
2005-11-02 10:36:37 +03:00
|
|
|
}
|
|
|
|
else {
|
2005-11-02 10:41:11 +03:00
|
|
|
newToken = new Token(mPosition - 1, Token::PARENT_OP);
|
2005-11-02 10:36:37 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BANG : // can only be !=
|
2005-11-02 10:41:11 +03:00
|
|
|
if (++mPosition < end && *mPosition == EQUAL) {
|
|
|
|
++mPosition;
|
|
|
|
newToken = new Token(mPosition - 2, mPosition, Token::NOT_EQUAL_OP);
|
|
|
|
break;
|
2005-11-02 10:36:37 +03:00
|
|
|
}
|
2005-11-02 10:41:11 +03:00
|
|
|
// Error ! is not not()
|
|
|
|
return NS_ERROR_XPATH_BAD_BANG;
|
2005-11-02 10:36:37 +03:00
|
|
|
case EQUAL:
|
2005-11-02 10:41:11 +03:00
|
|
|
newToken = new Token(mPosition, Token::EQUAL_OP);
|
|
|
|
++mPosition;
|
2005-11-02 10:36:37 +03:00
|
|
|
break;
|
|
|
|
case L_ANGLE:
|
2005-11-02 10:41:11 +03:00
|
|
|
if (++mPosition == end) {
|
|
|
|
return NS_ERROR_XPATH_UNEXPECTED_END;
|
|
|
|
}
|
|
|
|
if (*mPosition == EQUAL) {
|
|
|
|
++mPosition;
|
|
|
|
newToken = new Token(mPosition - 2, mPosition,
|
|
|
|
Token::LESS_OR_EQUAL_OP);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newToken = new Token(mPosition - 1, Token::LESS_THAN_OP);
|
2005-11-02 10:36:37 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case R_ANGLE:
|
2005-11-02 10:41:11 +03:00
|
|
|
if (++mPosition == end) {
|
|
|
|
return NS_ERROR_XPATH_UNEXPECTED_END;
|
|
|
|
}
|
|
|
|
if (*mPosition == EQUAL) {
|
|
|
|
++mPosition;
|
|
|
|
newToken = new Token(mPosition - 2, mPosition,
|
|
|
|
Token::GREATER_OR_EQUAL_OP);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newToken = new Token(mPosition - 1, Token::GREATER_THAN_OP);
|
2005-11-02 10:36:37 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case HYPHEN :
|
2005-11-02 10:41:11 +03:00
|
|
|
newToken = new Token(mPosition, Token::SUBTRACTION_OP);
|
|
|
|
++mPosition;
|
2005-11-02 10:36:37 +03:00
|
|
|
break;
|
2015-04-17 04:09:58 +03:00
|
|
|
case ASTERISK:
|
2005-11-02 10:41:11 +03:00
|
|
|
if (nextIsOperatorToken(prevToken)) {
|
|
|
|
newToken = new Token(mPosition, Token::MULTIPLY_OP);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newToken = new Token(mPosition, Token::CNAME);
|
|
|
|
}
|
|
|
|
++mPosition;
|
2005-11-02 10:36:37 +03:00
|
|
|
break;
|
|
|
|
case L_PAREN:
|
2005-11-02 10:41:11 +03:00
|
|
|
if (prevToken->mType == Token::CNAME) {
|
2010-06-09 03:25:27 +04:00
|
|
|
const nsDependentSubstring& val = prevToken->Value();
|
|
|
|
if (val.EqualsLiteral("comment")) {
|
2006-01-09 22:38:53 +03:00
|
|
|
prevToken->mType = Token::COMMENT_AND_PAREN;
|
2005-11-02 10:41:11 +03:00
|
|
|
}
|
2010-06-09 03:25:27 +04:00
|
|
|
else if (val.EqualsLiteral("node")) {
|
2006-01-09 22:38:53 +03:00
|
|
|
prevToken->mType = Token::NODE_AND_PAREN;
|
2005-11-02 10:41:11 +03:00
|
|
|
}
|
2010-06-09 03:25:27 +04:00
|
|
|
else if (val.EqualsLiteral("processing-instruction")) {
|
2006-01-09 22:38:53 +03:00
|
|
|
prevToken->mType = Token::PROC_INST_AND_PAREN;
|
2005-11-02 10:41:11 +03:00
|
|
|
}
|
2010-06-09 03:25:27 +04:00
|
|
|
else if (val.EqualsLiteral("text")) {
|
2006-01-09 22:38:53 +03:00
|
|
|
prevToken->mType = Token::TEXT_AND_PAREN;
|
2005-11-02 10:41:11 +03:00
|
|
|
}
|
|
|
|
else {
|
2006-01-09 22:38:53 +03:00
|
|
|
prevToken->mType = Token::FUNCTION_NAME_AND_PAREN;
|
2005-11-02 10:41:11 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
isToken = false;
|
2006-01-09 22:38:53 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
newToken = new Token(mPosition, Token::L_PAREN);
|
2005-11-02 10:36:37 +03:00
|
|
|
}
|
2005-11-02 10:41:11 +03:00
|
|
|
++mPosition;
|
2005-11-02 10:36:37 +03:00
|
|
|
break;
|
|
|
|
case R_PAREN:
|
2005-11-02 10:41:11 +03:00
|
|
|
newToken = new Token(mPosition, Token::R_PAREN);
|
|
|
|
++mPosition;
|
2005-11-02 10:36:37 +03:00
|
|
|
break;
|
|
|
|
case L_BRACKET:
|
2005-11-02 10:41:11 +03:00
|
|
|
newToken = new Token(mPosition, Token::L_BRACKET);
|
|
|
|
++mPosition;
|
2005-11-02 10:36:37 +03:00
|
|
|
break;
|
|
|
|
case R_BRACKET:
|
2005-11-02 10:41:11 +03:00
|
|
|
newToken = new Token(mPosition, Token::R_BRACKET);
|
|
|
|
++mPosition;
|
2005-11-02 10:36:37 +03:00
|
|
|
break;
|
|
|
|
case COMMA:
|
2005-11-02 10:41:11 +03:00
|
|
|
newToken = new Token(mPosition, Token::COMMA);
|
|
|
|
++mPosition;
|
2005-11-02 10:36:37 +03:00
|
|
|
break;
|
|
|
|
case AT_SIGN :
|
2005-11-02 10:41:11 +03:00
|
|
|
newToken = new Token(mPosition, Token::AT_SIGN);
|
|
|
|
++mPosition;
|
2005-11-02 10:36:37 +03:00
|
|
|
break;
|
|
|
|
case PLUS:
|
2005-11-02 10:41:11 +03:00
|
|
|
newToken = new Token(mPosition, Token::ADDITION_OP);
|
|
|
|
++mPosition;
|
2005-11-02 10:36:37 +03:00
|
|
|
break;
|
|
|
|
case VERT_BAR:
|
2005-11-02 10:41:11 +03:00
|
|
|
newToken = new Token(mPosition, Token::UNION_OP);
|
|
|
|
++mPosition;
|
2005-11-02 10:36:37 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Error, don't grok character :-(
|
2005-11-02 10:41:11 +03:00
|
|
|
return NS_ERROR_XPATH_ILLEGAL_CHAR;
|
2005-11-02 10:36:37 +03:00
|
|
|
}
|
2005-11-02 10:34:13 +03:00
|
|
|
}
|
2005-11-02 10:41:11 +03:00
|
|
|
if (isToken) {
|
|
|
|
NS_ENSURE_TRUE(newToken, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
NS_ENSURE_TRUE(newToken != mLastItem, NS_ERROR_FAILURE);
|
|
|
|
prevToken = newToken;
|
|
|
|
addToken(newToken);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// add a endToken to the list
|
|
|
|
newToken = new Token(end, end, Token::END);
|
|
|
|
addToken(newToken);
|
2005-11-02 10:34:13 +03:00
|
|
|
|
2005-11-02 10:41:11 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|