File:  [Public] / Amaya / amaya / XPointer.h
Revision 1.4: download - view: text, annotated - select for diffs
Tue Feb 20 09:40:05 2001 UTC (23 years, 4 months ago) by kahan
Branches: MAIN
CVS tags: HEAD, Amaya-9-55-1, Amaya-9-55, Amaya-9-54, Amaya-9-53bis, Amaya-9-53, Amaya-9-52, Amaya-9-51, Amaya-9-5, Amaya-9-4, Amaya-9-3, Amaya-9-2-1, Amaya-9-2, Amaya-9-1, Amaya-8-7, Amaya-8-6, Amaya-8-5, Amaya-8-4, Amaya-8-3, Amaya-8-2, Amaya-8-1b, Amaya-8-1, Amaya-8-0, Amaya-7-2, Amaya-7-1, Amaya-7-0, Amaya-6-4, Amaya-6-3, Amaya-6-2, Amaya-6-1, Amaya-6-0, Amaya-5-3, Amaya-5-2, Amaya-5-1, Amaya-5-0, Amaya-4-3-2, Amaya-4-3-1, Amaya-4-3, Amaya-10-0
JK: Bug fix: Elements or ID names bigger than 10 characters caused
a memory overrun.
Side effect: we can now use XPointers on SVG (thanks to Irene's selection
changes).

#ifndef AMAYA_XPOINTER_H
#define AMAYA_XPOINTER_H

/***************************************************
  General definitions
**************************************************/

/* the different types of nodes */
typedef enum _nodeType {
  SINGLE_NODE=0x1,     /* XPointer is a single node */
  RANGE_TO=0x2,        /* XPointer is a node set (two nodes */
  STRING_RANGE=0x4,    /* XPointer node points to a string */
  START_POINT=0x8,     /* XPointer node points to a string */
  END_POINT=0x10       /* XPointer node points to a string */

} nodeType;

/***************************************************
  Symbol table  (move this back to XPointerparse.c)
***************************************************/

#define STRMAX 999 /* size of lexemes array */
#define SYMMAX 100 /* size of symtable */

/* forms of symbol table entry */
struct entry { 
  char *lexptr;
  int token;
};

/* tokens */
typedef enum {
  /* type identifiers */
  NUM=256,
  ID,
  /* the xpointer functions */
  FID,            
  FRANGE_TO,
  FSTRING_RANGE,
  FSTARTP,
  FENDP,
  /* non-operators */
  DONE,
  NONE
} tokEnum;

/* the symbol table */
typedef struct _symTableCtx {
  char lexemes[STRMAX];  /* lexemes table */
  int lastchar;          /* last used position in lexemes */
  struct entry symtable[SYMMAX]; 
  int lastentry;        /* last entry in the symtable */
} symTableCtx;

typedef symTableCtx *symTableCtxPtr;

/***************************************************
  The parser context
**************************************************/

/* the node info that the parsing will return */
typedef struct _nodeInfo {
  Element  el;
  char *node;      /* temporary buffer for storing a node's name */
  int  nodeSize;   /* size of the above temporary buffer */
  nodeType type;
  int  startC;
  int  endC;
  int  index;
  int  processed;
} nodeInfo;

typedef struct _XPointerContext {
  Document doc; /* document where we are resolving the XPointer */
  Element root; /* root element of the document */

  char *cur;    /* the current char being parsed */
  char *buffer; /* the input string */

  char *error;    /* error code */

  int   lookahead;  /* the lookahead token */
  tokEnum tok;      /* token */
  int tokval;       /* token value */

  symTableCtxPtr symtable; /* the symbol table */
  
  nodeType   type;        /* 0, single node, 1 range-to */
  nodeInfo  *curNode;
  nodeInfo   nodeStart;
  nodeInfo   nodeEnd;
} XPointerContext;

typedef XPointerContext *XPointerContextPtr;

#endif /* AMAYA_XPOINTER_H */




Webmaster