⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jsscan.h

📁 java script test programing source code
💻 H
📖 第 1 页 / 共 2 页
字号:
};struct JSToken {    JSTokenType         type;           /* char value or above enumerator */    JSTokenPos          pos;            /* token position in file */    jschar              *ptr;           /* beginning of token in line buffer */    union {        struct {                        /* non-numeric literal */            JSOp        op;             /* operator, for minimal parser */            JSAtom      *atom;          /* atom table entry */        } s;        struct {                        /* atom pair, for XML PIs */            JSAtom      *atom2;         /* auxiliary atom table entry */            JSAtom      *atom;          /* main atom table entry */        } p;        jsdouble        dval;           /* floating point number */    } u;};#define t_op            u.s.op#define t_atom          u.s.atom#define t_atom2         u.p.atom2#define t_dval          u.dvaltypedef struct JSTokenBuf {    jschar              *base;          /* base of line or stream buffer */    jschar              *limit;         /* limit for quick bounds check */    jschar              *ptr;           /* next char to get, or slot to use */} JSTokenBuf;#define JS_LINE_LIMIT   256             /* logical line buffer size limit --                                           physical line length is unlimited */#define NTOKENS         4               /* 1 current + 2 lookahead, rounded */#define NTOKENS_MASK    (NTOKENS-1)     /* to power of 2 to avoid divmod by 3 */struct JSTokenStream {    JSToken             tokens[NTOKENS];/* circular token buffer */    uintN               cursor;         /* index of last parsed token */    uintN               lookahead;      /* count of lookahead tokens */    uintN               lineno;         /* current line number */    uintN               ungetpos;       /* next free char slot in ungetbuf */    jschar              ungetbuf[6];    /* at most 6, for \uXXXX lookahead */    uintN               flags;          /* flags -- see below */    ptrdiff_t           linelen;        /* physical linebuf segment length */    ptrdiff_t           linepos;        /* linebuf offset in physical line */    JSTokenBuf          linebuf;        /* line buffer for diagnostics */    JSTokenBuf          userbuf;        /* user input buffer if !file */    JSStringBuffer      tokenbuf;       /* current token string buffer */    const char          *filename;      /* input filename or null */    FILE                *file;          /* stdio stream if reading from file */    JSPrincipals        *principals;    /* principals associated with source */    JSSourceHandler     listener;       /* callback for source; eg debugger */    void                *listenerData;  /* listener 'this' data */    void                *listenerTSData;/* listener data for this TokenStream */    jschar              *saveEOL;       /* save next end of line in userbuf, to                                           optimize for very long lines */};#define CURRENT_TOKEN(ts)       ((ts)->tokens[(ts)->cursor])#define ON_CURRENT_LINE(ts,pos) ((uint16)(ts)->lineno == (pos).end.lineno)/* JSTokenStream flags */#define TSF_ERROR       0x01            /* fatal error while compiling */#define TSF_EOF         0x02            /* hit end of file */#define TSF_NEWLINES    0x04            /* tokenize newlines */#define TSF_OPERAND     0x08            /* looking for operand, not operator */#define TSF_NLFLAG      0x20            /* last linebuf ended with \n */#define TSF_CRFLAG      0x40            /* linebuf would have ended with \r */#define TSF_DIRTYLINE   0x80            /* non-whitespace since start of line */#define TSF_OWNFILENAME 0x100           /* ts->filename is malloc'd */#define TSF_XMLTAGMODE  0x200           /* scanning within an XML tag in E4X */#define TSF_XMLTEXTMODE 0x400           /* scanning XMLText terminal from E4X */#define TSF_XMLONLYMODE 0x800           /* don't scan {expr} within text/tag *//* Flag indicating unexpected end of input, i.e. TOK_EOF not at top-level. */#define TSF_UNEXPECTED_EOF 0x1000/* * To handle the hard case of contiguous HTML comments, we want to clear the * TSF_DIRTYINPUT flag at the end of each such comment.  But we'd rather not * scan for --> within every //-style comment unless we have to.  So we set * TSF_IN_HTML_COMMENT when a <!-- is scanned as an HTML begin-comment, and * clear it (and TSF_DIRTYINPUT) when we scan --> either on a clean line, or * only if (ts->flags & TSF_IN_HTML_COMMENT), in a //-style comment. * * This still works as before given a malformed comment hiding hack such as: * *    <script> *      <!-- comment hiding hack #1 *      code goes here *      // --> oops, markup for script-unaware browsers goes here! *    </script> * * It does not cope with malformed comment hiding hacks where --> is hidden * by C-style comments, or on a dirty line.  Such cases are already broken. */#define TSF_IN_HTML_COMMENT 0x2000/* Ignore keywords and return TOK_NAME instead to the parser. */#define TSF_KEYWORD_IS_NAME 0x4000/* Unicode separators that are treated as line terminators, in addition to \n, \r */#define LINE_SEPARATOR  0x2028#define PARA_SEPARATOR  0x2029/* * Create a new token stream, either from an input buffer or from a file. * Return null on file-open or memory-allocation failure. * * NB: All of js_New{,Buffer,File}TokenStream() return a pointer to transient * memory in the current context's temp pool.  This memory is deallocated via * JS_ARENA_RELEASE() after parsing is finished. */extern JSTokenStream *js_NewTokenStream(JSContext *cx, const jschar *base, size_t length,                  const char *filename, uintN lineno, JSPrincipals *principals);extern JS_FRIEND_API(JSTokenStream *)js_NewBufferTokenStream(JSContext *cx, const jschar *base, size_t length);extern JS_FRIEND_API(JSTokenStream *)js_NewFileTokenStream(JSContext *cx, const char *filename, FILE *defaultfp);extern JS_FRIEND_API(JSBool)js_CloseTokenStream(JSContext *cx, JSTokenStream *ts);extern JS_FRIEND_API(int)js_fgets(char *buf, int size, FILE *file);/* * If the given char array forms JavaScript keyword, return corresponding * token. Otherwise return TOK_EOF. */extern JSTokenTypejs_CheckKeyword(const jschar *chars, size_t length);#define js_IsKeyword(chars, length) \    (js_CheckKeyword(chars, length) != TOK_EOF)/* * Friend-exported API entry point to call a mapping function on each reserved * identifier in the scanner's keyword table. */extern JS_FRIEND_API(void)js_MapKeywords(void (*mapfun)(const char *));/* * Report a compile-time error by its number, using ts or cg to show context. * Return true for a warning, false for an error. */extern JSBooljs_ReportCompileErrorNumber(JSContext *cx, void *handle, uintN flags,                            uintN errorNumber, ...);extern JSBooljs_ReportCompileErrorNumberUC(JSContext *cx, void *handle, uintN flags,                              uintN errorNumber, ...);/* Steal some JSREPORT_* bits (see jsapi.h) to tell handle's type. */#define JSREPORT_HANDLE 0x300#define JSREPORT_TS     0x000#define JSREPORT_CG     0x100#define JSREPORT_PN     0x200/* * Look ahead one token and return its type. */extern JSTokenTypejs_PeekToken(JSContext *cx, JSTokenStream *ts);extern JSTokenTypejs_PeekTokenSameLine(JSContext *cx, JSTokenStream *ts);/* * Get the next token from ts. */extern JSTokenTypejs_GetToken(JSContext *cx, JSTokenStream *ts);/* * Push back the last scanned token onto ts. */extern voidjs_UngetToken(JSTokenStream *ts);/* * Get the next token from ts if its type is tt. */extern JSBooljs_MatchToken(JSContext *cx, JSTokenStream *ts, JSTokenType tt);JS_END_EXTERN_C#endif /* jsscan_h___ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -