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

📄 inpbuf.h

📁 PL/0源码
💻 H
字号:
//////////////////////////////////////////////////////////////////////////////////  inpbuf.[h,cc] -- source program input buffering routines////  Inpbuf interacts with four other portions of the compiler://  the driver, the scanner, the syntax corrector, and anybody who needs//  to report an error or warning that is keyed to the source.////  Inpbuf reads the source program on demand, and keeps the entire//  thing buffered in the compiler.  The driver calls init_input_buffer.//  During compilation, various routines add error messages to//  appropriate lines by calling warning or error.  At the end  of the//  parse, the driver calls finalize_input_buffer to dump accumulated syntax//  corrections and messages.////  The scanner calls read_char to get the next character of source.//  It calls unread_chars to give back characters it doesn't need.//  It inspects variable scanner_peeking to determine when it needs to know//  whether it is *really* scanning, as opposed to looking ahead//  on behalf of the syntax corrector (see below).  It calls//  get_source_location to get a "pointer" (meaningful to inpbuf; ought//  to be an opaque type) to the location in the source program of the//  character most recently returned by read_char.////  The syntax corrector calls prepare_to_correct when it has discovered//  a syntax error and needs to begin peeking ahead in the input.  It calls//  done_peeking when it has figured out what correction it wants to make.//  It then calls display_deletions zero or one times to delete any tokens//  it wants to get rid of and display_insertion zero or more times to//  insert any tokens it wants.  Finally, it calls done_correcting to put//  the input stream back before the corrected input, where the parser can//  begin looking at it again.////  Routines that want to print warning or error messages call routines//  issue_warning and issue_error, respectively.  Each routine takes a//  location_t at which the message is to be delivered.  Inpbuf hangs onto all//  messages until the end of compilation, at which point it prints//  them all in order, when the driver calls finalize_input_buffer.//#ifndef INPBUF_H#define INPBUF_H#include <string>#define    FILE_END     '\01'   // returned by readChar at EOF////////////  Forward references...//class input_buffer_t;//////////  location_t should be an opaque type.  Nobdy outside of inpbuf.cc should//  ever look inside a location_t, so we provide a few simple member functions//  to make everyone else's life easier.class location_t  {public:    input_buffer_t *    line;        // see inpbuf.p    int                 column;    int                 get_lineno(void) const;    int                 get_column(void) const;};extern bool scanner_peeking;//  Are we really scanning, or just looking ahead for the syntax//  corrector? Don't print error messages if we're scanner_peeking.//  This variable should really be read-only outside inpbuf.pextern bool compile_ok;//  Can we go ahead and generate code, or were there fatal errors?void init_input_buffer(void);//  Called by drivervoid finalize_input_buffer(void);//  Dumps all accumulated syntax corrections, warnings, and error messageschar read_char(void);//  Get next character of inputvoid unread_chars (unsigned int how_many);//  Give back characters that the scanner didn't want after alllocation_t get_source_location(void);//  Return location in source program of next character to be scannedvoid prepare_to_correct (location_t where);//  We are about to begin a set of changesvoid done_peeking (void);//  We have decided on a set of changes, and are about to make themvoid display_deletions (int how_many);//  Remove howmany tokens from the current linevoid display_insertion (string insertion);//  Insert some characters (one token) into the current linevoid done_correcting (void);//  We are done making changes (for now); prepare to read more charactersvoid issue_error (location_t loc, string msg);//  Issue an error message at a given source code location.void issue_warning (location_t loc, string msg);//  Issue a warning at a given source code location.void die_compiler (string msg);//  Print message and halt.string get_line_info(const input_buffer_t *line, input_buffer_t *& next,                        int &line_num);//  Given the pointer to an input_buffer_t, extract the pointer to the next//  input_buffer_t, the line # and return the text.#endif

⌨️ 快捷键说明

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