Click here to Skip to main content
15,897,518 members
Articles / Programming Languages / C++

Wave: a Standard conformant C++ preprocessor library

Rate me:
Please Sign up or sign in to vote.
4.96/5 (58 votes)
10 Jan 200413 min read 404.1K   4.4K   81  
Describes a free and fully Standard conformant C++ preprocessor library
/*=============================================================================
    Wave: A Standard compliant C++ preprocessor

    Copyright (c) 2001 Daniel C. Nuffer
    Copyright (c) 2001-2003 Hartmut Kaiser
    http://spirit.sourceforge.net/

    Permission to copy, use, modify, sell and distribute this software
    is granted provided this copyright notice appears in all copies.
    This software is provided "as is" without express or implied
    warranty, and with no claim as to its suitability for any purpose.

    See Copyright.txt for full copyright notices and acknowledgements.
=============================================================================*/

#ifndef SCANNER_HPP
#define SCANNER_HPP

#include "wave/cpplexer/re2clex/aq.hpp"

///////////////////////////////////////////////////////////////////////////////
namespace wave {
namespace cpplexer {
namespace re2clex {

struct Scanner;
typedef unsigned char uchar;
typedef int (* ReportErrorProc)(struct Scanner *, char *, ...);

typedef struct Scanner {
    int    fd;  /* file descriptor */
    uchar* first;   /* start of input buffer (if fd == -1) */
    uchar* act;     /* act position of input buffer (if fd == -1) */
    uchar* last;    /* end (one past last char) of input buffer (if fd == -1) */
    uchar* bot; /* beginning of the current buffer */
    uchar* top; /* top of the current buffer */
    uchar* eof; /* when we read in the last buffer, will point 1 past the 
                   end of the file, otherwise 0 */
    uchar* tok; /* points to the beginning of the current token */
    uchar* ptr; /* used for YYMARKER - saves backtracking info */
    uchar* cur; /* saves the cursor (maybe is redundant with tok?) */
    uchar* lim; /* used for YYLIMIT - points to the end of the buffer */
                /* (lim == top) except for the last buffer, it points to
                   the end of the input (lim == eof - 1) */
    unsigned int line; /* current line being lexed */
    ReportErrorProc error_proc;     /* if != 0 this function is called to 
                report an error */
    char const *file_name;  /* name of the lexed file */
    aq_queue eol_offsets;
    int enable_ms_extensions;   /* enable MS extensions */
    int act_in_c99_mode;        /* lexer works in C99 mode */
    int act_in_cpp0x_mode;      /* lexer works in C++0x mode */
} Scanner;

int scan(Scanner *s);

///////////////////////////////////////////////////////////////////////////////
}   // namespace re2clex
}   // namespace cpplexer
}   // namespace wave

#endif // SCANNER_HPP

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
Actively involved in Boost and the development of the Spirit parser construction framework.

Comments and Discussions