Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Private Member Functions | Private Attributes
nsXFormsXPathScanner Class Reference

The XPath Expression scanner, used by nsXFormsXPathParser. More...

#include <nsXFormsXPathScanner.h>

Collaboration diagram for nsXFormsXPathScanner:
Collaboration graph
[legend]

List of all members.

Public Types

enum  XPATHTOKEN {
  LPARAN, RPARAN, LBRACK, RBRACK,
  AT, COMMA, COLONCOLON, DOT,
  DOTDOT, SLASH, SLASHSLASH, UNION,
  PLUS, MINUS, EQUAL, NOTEQUAL,
  LEQUAL, LESS, GEQUAL, GREATER,
  MULTIPLYOPERATOR, WHITESPACE, NUMBER, LITERAL,
  AND, OR, MOD, DIV,
  NODE, PI, TEXT, COMMENT,
  FUNCTIONNAME, NCNAME, QNAME, VARIABLE,
  STAR, ANCESTOR, ANCESTOR_OR_SELF, ATTRIBUTE,
  CHILD, DESCENDANT, DESCENDANT_OR_SELF, FOLLOWING,
  FOLLOWING_SIBLING, NAMESPACE, PARENT, PRECEDING,
  PRECEDING_SIBLING, SELF, XPATHEOF, ERRORXPATHTOKEN,
  NONE
}

Public Member Functions

 nsXFormsXPathScanner ()
 nsXFormsXPathScanner (const nsAString &aExpression)
 ~nsXFormsXPathScanner ()
void Init (const nsAString &aExpression)
XPATHTOKEN NextToken ()
PRInt32 Offset ()
PRInt32 Length ()
void Image (PRInt32 &aOffset, PRInt32 &aLength)
PRBool HasMoreTokens ()
nsAString & Expression ()

Private Member Functions

PRUnichar PopChar ()
PRUnichar PeekChar ()
PRUnichar PeekChar (PRInt32 offset)
PRUnichar NextNonWhite ()
PRInt32 GetOffsetForNonWhite ()
PRBool SolveDiambiguate ()
XPATHTOKEN SolveStar ()
XPATHTOKEN ScanNumber ()
XPATHTOKEN ScanVariable ()
XPATHTOKEN ScanWhitespace ()
XPATHTOKEN ScanLiteral ()
XPATHTOKEN ScanQName ()
XPATHTOKEN ScanNCName ()

Private Attributes

XPATHTOKEN mState
XPATHTOKEN mLast
nsAutoString mExpression
PRInt32 mOffset
PRInt32 mLength
PRInt32 mSize

Detailed Description

The XPath Expression scanner, used by nsXFormsXPathParser.

Note:
Should be reimplemented and moved to Transformiix

Definition at line 51 of file nsXFormsXPathScanner.h.


Member Enumeration Documentation

Enumerator:
LPARAN 
RPARAN 
LBRACK 
RBRACK 
AT 
COMMA 
COLONCOLON 
DOT 
DOTDOT 
SLASH 
SLASHSLASH 
UNION 
PLUS 
MINUS 
EQUAL 
NOTEQUAL 
LEQUAL 
LESS 
GEQUAL 
GREATER 
MULTIPLYOPERATOR 
WHITESPACE 
NUMBER 
LITERAL 
AND 
OR 
MOD 
DIV 
NODE 
PI 
TEXT 
COMMENT 
FUNCTIONNAME 
NCNAME 
QNAME 
VARIABLE 
STAR 
ANCESTOR 
ANCESTOR_OR_SELF 
ATTRIBUTE 
CHILD 
DESCENDANT 
DESCENDANT_OR_SELF 
FOLLOWING 
FOLLOWING_SIBLING 
NAMESPACE 
PARENT 
PRECEDING 
PRECEDING_SIBLING 
SELF 
XPATHEOF 
ERRORXPATHTOKEN 
NONE 

Definition at line 54 of file nsXFormsXPathScanner.h.


Constructor & Destructor Documentation

nsXFormsXPathScanner::nsXFormsXPathScanner ( const nsAString &  aExpression)

Definition at line 48 of file nsXFormsXPathScanner.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 84 of file nsXFormsXPathScanner.cpp.

{
  return mExpression;
}

Here is the caller graph for this function:

Definition at line 121 of file nsXFormsXPathScanner.cpp.

{
  PRInt32 co = mOffset + mLength + 1;
  while (nsXFormsXPathXMLUtil::IsWhitespace(PeekChar(co)))
    co++;
  return co;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 130 of file nsXFormsXPathScanner.cpp.

{
  return mState != XPATHEOF;
}
void nsXFormsXPathScanner::Image ( PRInt32 aOffset,
PRInt32 aLength 
)
void nsXFormsXPathScanner::Init ( const nsAString &  aExpression)

Definition at line 61 of file nsXFormsXPathScanner.cpp.

{
  mExpression = aExpression;
  mSize = mExpression.Length();
  mLength = 0;
  mOffset = -1;
  mLast = NONE;
  mState = NONE;
}

Here is the caller graph for this function:

Definition at line 72 of file nsXFormsXPathScanner.cpp.

{
  return mLength;
}

Here is the caller graph for this function:

Definition at line 115 of file nsXFormsXPathScanner.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 136 of file nsXFormsXPathScanner.cpp.

{
  if (mState != WHITESPACE)
    mLast = mState;
  mOffset = mOffset + mLength;
  mLength = 0;

  PRUnichar c = PeekChar();
  if (c == '\0') {
    mState = XPATHEOF;
  } else if (nsXFormsXPathXMLUtil::IsDigit(c)) {
    mState = ScanNumber();
  } else if (c == '_' || nsXFormsXPathXMLUtil::IsLetter(c)) {
    mState = ScanQName();
  } else if (c == '"' || c == '\'') {
    mState = ScanLiteral();
  } else {
    switch (c) {
    case '(':
      mState = LPARAN;
      PopChar();
      break;
      
    case ')':
      mState = RPARAN;
      PopChar();
      break;
      
    case '[':
      mState = LBRACK;
      PopChar();
      break;
      
    case ']':
      mState = RBRACK;
      PopChar();
      break;
      
    case '@':
      mState = AT;
      PopChar();
      break;
      
    case ',':
      mState = COMMA;
      PopChar();
      break;
      
    case ':':
      PopChar();
      if (PeekChar() == ':') {
        mState = COLONCOLON;
        PopChar();
      } else
        mState = ERRORXPATHTOKEN;
      break;
      
    case '.':
      PopChar();
      if (PeekChar() == '.') {
        mState = DOTDOT;
        PopChar();
      } else if (nsXFormsXPathXMLUtil::IsDigit(PeekChar()))
        mState = ScanNumber();
      else
        mState = DOT;
      break;
      
    case '$':
      mState = ScanVariable();
      break;
      
    case '/':
      PopChar();
      if (PeekChar() == '/') {
        mState = SLASHSLASH;
        PopChar();
      } else
        mState = SLASH;
      break;
      
    case '|':
      PopChar();
      mState = UNION;
      break;
      
    case '+':
      PopChar();
      mState = PLUS;
      break;
      
    case '-':
      PopChar();
      mState = MINUS;
      break;
      
    case '=':
      PopChar();
      mState = EQUAL;
      break;
      
    case '!':
      PopChar();
      if (PeekChar() == '=') {
        mState = NOTEQUAL;
        PopChar();
      } else
        mState = ERRORXPATHTOKEN;
      break;
      
    case '<':
      PopChar();
      if (PeekChar() == '=') {
        mState = LEQUAL;
        PopChar();
      } else
        mState = LESS;
      break;
      
    case '>':
      PopChar();
      if (PeekChar() == '=') {
        mState = GEQUAL;
        PopChar();
      } else
        mState = GREATER;
      break;
      
    case '*':
      PopChar();
      mState = SolveStar();
      break;
      
    case '\r':
    case '\n':
    case '\t':
    case ' ':
      mState = ScanWhitespace();
      break;
      
    default:
      PopChar();
      mState = ERRORXPATHTOKEN;
    }
  }

  return mState;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 78 of file nsXFormsXPathScanner.cpp.

{
  return mOffset;
}

Here is the caller graph for this function:

Definition at line 101 of file nsXFormsXPathScanner.cpp.

{
  return PeekChar(mOffset + mLength + 1);
}

Here is the caller graph for this function:

Definition at line 107 of file nsXFormsXPathScanner.cpp.

{
  if (mSize > aOffset)
    return mExpression[aOffset];
  return '\0';
}

Definition at line 90 of file nsXFormsXPathScanner.cpp.

{
  PRUnichar c = '\0';
  mLength++;
  if (mOffset + mLength < mSize) {
    c =  mExpression[mOffset + mLength];
  }
  return c;
}

Here is the caller graph for this function:

Definition at line 342 of file nsXFormsXPathScanner.cpp.

{
  PRUnichar c = PopChar();
  PRUnichar p;
  while ((p = PeekChar()) != c && p != '\0')
    PopChar();
  if (p == '\0')
    return ERRORXPATHTOKEN;
  PopChar();
  return LITERAL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 427 of file nsXFormsXPathScanner.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 303 of file nsXFormsXPathScanner.cpp.

{
  PRUnichar c = PopChar();
  PRBool decimal = (c == '.');

  while (c != '\0') {
    c = PeekChar();
    if (!decimal && c == '.') {
      decimal = PR_TRUE;
    } else if (!nsXFormsXPathXMLUtil::IsDigit(c)) {
      return NUMBER;
    }
    PopChar();
  }
  return NUMBER;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 355 of file nsXFormsXPathScanner.cpp.

{
  XPATHTOKEN second = NONE;
  ScanNCName();
  if (PeekChar() == ':' && PeekChar(mOffset + mLength + 2) != ':') {
    PopChar();
    second = ScanNCName();
  }

  nsDependentSubstring image = Substring(mExpression, Offset() + 1);

  if (SolveDiambiguate()) {
    if (StringBeginsWith(image, NS_LITERAL_STRING("and")))
      return AND;
    if (StringBeginsWith(image, NS_LITERAL_STRING("or")))
      return OR;
    if (StringBeginsWith(image, NS_LITERAL_STRING("mod")))
      return MOD;
    if (StringBeginsWith(image, NS_LITERAL_STRING("div")))
      return DIV;
    return ERRORXPATHTOKEN;
  }

  PRUnichar c = NextNonWhite();
  if (c == '(') {
    if (StringBeginsWith(image, NS_LITERAL_STRING("comment")))
      return COMMENT;
    if (StringBeginsWith(image, NS_LITERAL_STRING("text")))
      return TEXT;
    if (StringBeginsWith(image, NS_LITERAL_STRING("processing-instruction")))
      return PI;
    if (StringBeginsWith(image, NS_LITERAL_STRING("node")))
      return NODE;

    return FUNCTIONNAME;
  }

  PRInt32 of = GetOffsetForNonWhite();
  if (PeekChar(of) == ':' && PeekChar(of + 1) == ':') {
    if (StringBeginsWith(image, NS_LITERAL_STRING("ancestor")))
      return ANCESTOR;
    if (StringBeginsWith(image, NS_LITERAL_STRING("ancestor-or-self")))
      return ANCESTOR_OR_SELF;
    if (StringBeginsWith(image, NS_LITERAL_STRING("attribute")))
      return ATTRIBUTE;
    if (StringBeginsWith(image, NS_LITERAL_STRING("child")))
      return CHILD;
    if (StringBeginsWith(image, NS_LITERAL_STRING("descendant")))
      return DESCENDANT;
    if (StringBeginsWith(image, NS_LITERAL_STRING("descendant-or-self")))
      return DESCENDANT_OR_SELF;
    if (StringBeginsWith(image, NS_LITERAL_STRING("following")))
      return FOLLOWING;
    if (StringBeginsWith(image, NS_LITERAL_STRING("following-sibling")))
      return FOLLOWING_SIBLING;
    if (StringBeginsWith(image, NS_LITERAL_STRING("namespace")))
      return NAMESPACE;
    if (StringBeginsWith(image, NS_LITERAL_STRING("parent")))
      return PARENT;
    if (StringBeginsWith(image, NS_LITERAL_STRING("preceding")))
      return PRECEDING;
    if (StringBeginsWith(image, NS_LITERAL_STRING("preceding-sibling")))
      return PRECEDING_SIBLING;
    if (StringBeginsWith(image, NS_LITERAL_STRING("self")))
      return SELF;

    return ERRORXPATHTOKEN;
  }
  return second != NONE ? QNAME : NCNAME;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 321 of file nsXFormsXPathScanner.cpp.

{
  PopChar();
  if (ScanQName() != ERRORXPATHTOKEN)
    return VARIABLE;
  return ERRORXPATHTOKEN;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 330 of file nsXFormsXPathScanner.cpp.

{
  PRUnichar c;
  do {
    PopChar();
    c = PeekChar();
  } while (nsXFormsXPathXMLUtil::IsWhitespace(c));

  return WHITESPACE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 286 of file nsXFormsXPathScanner.cpp.

{
  return mLast != NONE && (mLast != AT && mLast != COLONCOLON && mLast != LPARAN && mLast != LBRACK &&
                            mLast != AND && mLast != OR && mLast != DIV && mLast != MOD && mLast != SLASH && mLast != MULTIPLYOPERATOR &&
                            mLast != SLASHSLASH && mLast != UNION && mLast != PLUS && mLast != MINUS && mLast != NOTEQUAL && mLast != EQUAL && mLast != LESS &&
                            mLast != LEQUAL && mLast != GEQUAL && mLast != GREATER && mLast != COMMA);
}

Here is the caller graph for this function:

Definition at line 295 of file nsXFormsXPathScanner.cpp.

{
  if (SolveDiambiguate())
    return MULTIPLYOPERATOR;
  return STAR;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 68 of file nsXFormsXPathScanner.h.

Definition at line 67 of file nsXFormsXPathScanner.h.

Definition at line 69 of file nsXFormsXPathScanner.h.

Definition at line 69 of file nsXFormsXPathScanner.h.

Definition at line 69 of file nsXFormsXPathScanner.h.

Definition at line 67 of file nsXFormsXPathScanner.h.


The documentation for this class was generated from the following files: