📄 scanner.h
字号:
////////////////////////////////////////////////////////////////////////////////// scanner.[h,cc] -- table-driven lexical scanner//// Scanner tables are created by the program makescan, and are linked// into the compiler in the form of scantab.cc.//// assumptions:// There is only one 'except' class in the scangen tables, and// it constitutes the reserve words.// Tokens never contain NULL characters.// Case is insignificant.//#ifndef SCANNER_H#define SCANNER_H#include "inpbuf.h"#define MAX_MAJOR_TOKEN_NUM 100#define MAX_MINOR_TOKEN_NUM 300#define MAX_STRING_SPACE 20000// Major and minor token numbers for all tokens can be found in tokens.h,// generated automatically by mungegrammartypedef char major_token_t; // 0..MAX_MAJOR_TOKEN_NUM typedef char minor_token_t; // 0..MAX_MINOR_TOKEN_NUMtypedef short string_number_t; // 0..MAX_STRING_SPACE class token_attrib_t {public: major_token_t major; minor_token_t minor; string_number_t text_handle; location_t location; major_token_t get_major(void) const { return major; } minor_token_t get_minor(void) const { return minor; } location_t get_location(void) const { return location; } const char * get_text(void) const;};int init_scanner(void);string_number_t define_ident(const char *ident);// Allows outside routines to insert pre-defined identifiers into// the scanner's internal tables.token_attrib_t token_fake(major_token_t tok);// Used by the corrector to create a hypothetical inserted token.major_token_t token_get(token_attrib_t& attr);// Returns the next token from the source program, and sets a reference// parameter to contain its synthetic attributes. Return value is the// same as attr.major.string token_text(string_number_t where);// Return (non-tossed) text of a token.const char *token_chars(string_number_t where);// Return a character pointer to the string's space.#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -