/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* 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/. */
/** * A Token class for the ExprLexer. * * This class was ported from XSL:P, an open source Java based * XSLT processor, written by yours truly.
*/ class Token { public: /** * Token types
*/ enum Type { //-- Trivial Tokens
NULL_TOKEN = 1,
LITERAL,
NUMBER,
CNAME,
VAR_REFERENCE,
PARENT_NODE,
SELF_NODE,
R_PAREN,
R_BRACKET, // 9 /** * start of tokens for 3.7, bullet 1 * ExprLexer::nextIsOperatorToken bails if the tokens aren't * consecutive.
*/
COMMA,
AT_SIGN,
L_PAREN,
L_BRACKET,
AXIS_IDENTIFIER,
// These tokens include their following left parenthesis
FUNCTION_NAME_AND_PAREN, // 15
COMMENT_AND_PAREN,
NODE_AND_PAREN,
PROC_INST_AND_PAREN,
TEXT_AND_PAREN,
iterator mStart, mEnd;
Type mType;
Token* mNext;
};
/** * A class for splitting an "Expr" String into tokens and * performing basic Lexical Analysis. * * This class was ported from XSL:P, an open source Java based XSL processor
*/
class txExprLexer { public:
txExprLexer();
~txExprLexer();
/** * Parse the given string. * returns an error result if lexing failed. * The given string must outlive the use of the lexer, as the * generated Tokens point to Substrings of it. * mPosition points to the offending location in case of an error.
*/
nsresult parse(const nsAString& aPattern);
using iterator = nsAString::const_char_iterator;
iterator mPosition;
/** * Functions for iterating over the TokenList
*/
Token* nextToken();
Token* peek() {
NS_ASSERTION(mCurrentItem, "peek called uninitialized lexer"); return mCurrentItem;
}
Token* peekAhead() {
NS_ASSERTION(mCurrentItem, "peekAhead called on uninitialized lexer"); // Don't peek past the end node return (mCurrentItem && mCurrentItem->mNext) ? mCurrentItem->mNext
: mCurrentItem;
} bool hasMoreTokens() {
NS_ASSERTION(mCurrentItem, "HasMoreTokens called on uninitialized lexer"); return (mCurrentItem && mCurrentItem->mType != Token::END);
}
/** * Returns true if the following Token should be an operator. * This is a helper for the first bullet of [XPath 3.7] * Lexical Structure
*/ bool nextIsOperatorToken(Token* aToken);
/** * Returns true if the given character represents a numeric letter (digit) * Implemented in ExprLexerChars.cpp
*/ staticbool isXPathDigit(char16_t ch) { return (ch >= '0' && ch <= '9'); }
};
#endif
Messung V0.5
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.