clex.h

来自「一个基于C++的语法分析类」· C头文件 代码 · 共 57 行

H
57
字号
#ifndef INCLUDED_CLEX#define INCLUDED_CLEX 1#ifndef INCLUDED_STDIO#include <stdio.h>#endifenum Boolean { FALSE, TRUE };#include "clex_sym.h"class Clex    {  friend class Cparse;    enum Clex_mode        { CL_NONE=0, CL_COMMENT=1, CL_QUOTE=2, CL_POUND=4, CL_BRACK=8 }; protected:    short   look;           // a one-char lookahead    FILE*   fp;    Boolean block_brack;    // if TRUE, treat contents of "[]" as a string    long    line_num;       // line number in original source file    char    filename[256];  // name of original source file    short   bufsiz;         // number of chars currently in buf    char    buf[256];    void eat_one()          { look = short(getc(fp)); }    void put_in_buf(char c) { if (bufsiz < sizeof(buf)-1) buf[bufsiz++] = c; }    void buf_one()          { put_in_buf(look); eat_one(); }    Clex_sym terminate(Clex_sym s)  { buf[bufsiz] = '\0'; return s; }    Clex_sym eat_return(Clex_sym);    Clex_sym num(char);    Clex_sym ident(char);    Clex_sym lbrack(Clex_mode);    Clex_sym quote(char, Clex_sym, Clex_mode);    void block_comment(Clex_mode);    void line_comment();    void eoln(Clex_mode);    virtual Boolean pound(Clex_mode, char*, short len); public:    Clex_sym    next();    const char* str()           { return buf; }    short       strlen()        { return bufsiz; }    long        line_no()       { return line_num; }    const char* fname()         { return filename; }    const char* debug(Clex_sym);    Clex(FILE*, Boolean block_brack);    };#endif

⌨️ 快捷键说明

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