ao-lexer.cpp File Reference

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <ctype.h>
#include <assert.h>
#include "ao-syntax.h"
#include <unistd.h>
Include dependency graph for ao-lexer.cpp:

Classes

struct  yy_buffer_state
struct  yy_trans_info

Defines

#define YY_INT_ALIGNED   short int
#define yy_create_buffer   ao_create_buffer
#define yy_delete_buffer   ao_delete_buffer
#define yy_flex_debug   ao_flex_debug
#define yy_init_buffer   ao_init_buffer
#define yy_flush_buffer   ao_flush_buffer
#define yy_load_buffer_state   ao_load_buffer_state
#define yy_switch_to_buffer   ao_switch_to_buffer
#define yyin   aoin
#define yyleng   aoleng
#define yylex   aolex
#define yylineno   aolineno
#define yyout   aoout
#define yyrestart   aorestart
#define yytext   aotext
#define yywrap   aowrap
#define yyalloc   aoalloc
#define yyrealloc   aorealloc
#define yyfree   aofree
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION   2
#define YY_FLEX_MINOR_VERSION   5
#define YY_FLEX_SUBMINOR_VERSION   35
#define FLEX_BETA
#define INT8_MIN   (-128)
#define INT16_MIN   (-32767-1)
#define INT32_MIN   (-2147483647-1)
#define INT8_MAX   (127)
#define INT16_MAX   (32767)
#define INT32_MAX   (2147483647)
#define UINT8_MAX   (255U)
#define UINT16_MAX   (65535U)
#define UINT32_MAX   (4294967295U)
#define yyconst
#define YY_NULL   0
#define YY_SC_TO_UI(c)   ((unsigned int) (unsigned char) c)
#define BEGIN   (yy_start) = 1 + 2 *
#define YY_START   (((yy_start) - 1) / 2)
#define YYSTATE   YY_START
#define YY_STATE_EOF(state)   (YY_END_OF_BUFFER + state + 1)
#define YY_NEW_FILE   aorestart(aoin )
#define YY_END_OF_BUFFER_CHAR   0
#define YY_BUF_SIZE   16384
#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
#define EOB_ACT_CONTINUE_SCAN   0
#define EOB_ACT_END_OF_FILE   1
#define EOB_ACT_LAST_MATCH   2
#define YY_LESS_LINENO(n)
#define yyless(n)
#define unput(c)   yyunput( c, (yytext_ptr) )
#define YY_BUFFER_NEW   0
#define YY_BUFFER_NORMAL   1
#define YY_BUFFER_EOF_PENDING   2
#define YY_CURRENT_BUFFER
#define YY_CURRENT_BUFFER_LVALUE   (yy_buffer_stack)[(yy_buffer_stack_top)]
#define YY_FLUSH_BUFFER   ao_flush_buffer(YY_CURRENT_BUFFER )
#define yy_new_buffer   ao_create_buffer
#define yy_set_interactive(is_interactive)
#define yy_set_bol(at_bol)
#define YY_AT_BOL()   (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
#define yytext_ptr   aotext
#define YY_DO_BEFORE_ACTION
#define YY_NUM_RULES   23
#define YY_END_OF_BUFFER   24
#define REJECT   reject_used_but_not_detected
#define yymore()   yymore_used_but_not_detected
#define YY_MORE_ADJ   0
#define YY_RESTORE_YY_MORE_OFFSET
#define YYSTYPE   char*
#define INITIAL   0
#define YY_EXTRA_TYPE   void *
#define YY_READ_BUF_SIZE   8192
#define ECHO   do { if (fwrite( aotext, aoleng, 1, aoout )) {} } while (0)
#define YY_INPUT(buf, result, max_size)
#define yyterminate()   return YY_NULL
#define YY_START_STACK_INCR   25
#define YY_FATAL_ERROR(msg)   yy_fatal_error( msg )
#define YY_DECL_IS_OURS   1
#define YY_DECL   int aolex (void)
#define YY_BREAK   break;
#define YY_RULE_SETUP   YY_USER_ACTION
#define YY_EXIT_FAILURE   2
#define yyless(n)
#define YYTABLES_NAME   "yytables"

Typedefs

typedef signed char flex_int8_t
typedef short int flex_int16_t
typedef int flex_int32_t
typedef unsigned char flex_uint8_t
typedef unsigned short int flex_uint16_t
typedef unsigned int flex_uint32_t
typedef struct yy_buffer_stateYY_BUFFER_STATE
typedef size_t yy_size_t
typedef unsigned char YY_CHAR
typedef int yy_state_type

Functions

void aorestart (FILE *input_file)
void ao_switch_to_buffer (YY_BUFFER_STATE new_buffer)
YY_BUFFER_STATE ao_create_buffer (FILE *file, int size)
void ao_delete_buffer (YY_BUFFER_STATE b)
void ao_flush_buffer (YY_BUFFER_STATE b)
void aopush_buffer_state (YY_BUFFER_STATE new_buffer)
void aopop_buffer_state (void)
YY_BUFFER_STATE ao_scan_buffer (char *base, yy_size_t size)
YY_BUFFER_STATE ao_scan_string (yyconst char *yy_str)
YY_BUFFER_STATE ao_scan_bytes (yyconst char *bytes, int len)
void * aoalloc (yy_size_t)
void * aorealloc (void *, yy_size_t)
void aofree (void *)
int aolex_destroy (void)
int aoget_debug (void)
void aoset_debug (int debug_flag)
YY_EXTRA_TYPE aoget_extra (void)
void aoset_extra (YY_EXTRA_TYPE user_defined)
FILE * aoget_in (void)
void aoset_in (FILE *in_str)
FILE * aoget_out (void)
void aoset_out (FILE *out_str)
int aoget_leng (void)
char * aoget_text (void)
int aoget_lineno (void)
void aoset_lineno (int line_number)
int aowrap (void)
int aolex (void)
void aoerror (const char *)

Variables

int aoleng
FILE * aoin = (FILE *) 0
FILE * aoout = (FILE *) 0
int aolineno = 1
char * aotext
int ao_flex_debug = 0

Define Documentation

#define BEGIN   (yy_start) = 1 + 2 *
#define ECHO   do { if (fwrite( aotext, aoleng, 1, aoout )) {} } while (0)
#define EOB_ACT_CONTINUE_SCAN   0
#define EOB_ACT_END_OF_FILE   1
#define EOB_ACT_LAST_MATCH   2
#define FLEX_BETA
#define FLEX_SCANNER
#define INITIAL   0
#define INT16_MAX   (32767)
#define INT16_MIN   (-32767-1)
#define INT32_MAX   (2147483647)
#define INT32_MIN   (-2147483647-1)
#define INT8_MAX   (127)
#define INT8_MIN   (-128)
#define REJECT   reject_used_but_not_detected
#define UINT16_MAX   (65535U)
#define UINT32_MAX   (4294967295U)
#define UINT8_MAX   (255U)
#define unput (  )     yyunput( c, (yytext_ptr) )
 
#define YY_AT_BOL (  )     (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
#define YY_BREAK   break;
#define YY_BUF_SIZE   16384
#define YY_BUFFER_EOF_PENDING   2
#define YY_BUFFER_NEW   0
#define YY_BUFFER_NORMAL   1
#define yy_create_buffer   ao_create_buffer
#define YY_CURRENT_BUFFER
#define YY_CURRENT_BUFFER_LVALUE   (yy_buffer_stack)[(yy_buffer_stack_top)]
#define YY_DECL   int aolex (void)
#define YY_DECL_IS_OURS   1
#define yy_delete_buffer   ao_delete_buffer
#define YY_DO_BEFORE_ACTION
Value:
(yytext_ptr) = yy_bp; \
        aoleng = (size_t) (yy_cp - yy_bp); \
        (yy_hold_char) = *yy_cp; \
        *yy_cp = '\0'; \
        (yy_c_buf_p) = yy_cp;
#define YY_END_OF_BUFFER   24
#define YY_END_OF_BUFFER_CHAR   0
#define YY_EXIT_FAILURE   2
#define YY_EXTRA_TYPE   void *
#define YY_FATAL_ERROR ( msg   )     yy_fatal_error( msg )
#define YY_FLEX_MAJOR_VERSION   2
#define YY_FLEX_MINOR_VERSION   5
#define YY_FLEX_SUBMINOR_VERSION   35
#define YY_FLUSH_BUFFER   ao_flush_buffer(YY_CURRENT_BUFFER )
#define yy_flush_buffer   ao_flush_buffer
#define yy_init_buffer   ao_init_buffer
#define YY_INPUT ( buf,
result,
max_size   ) 
Value:
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
                { \
                int c = '*'; \
                size_t n; \
                for ( n = 0; n < max_size && \
                             (c = getc( aoin )) != EOF && c != '\n'; ++n ) \
                        buf[n] = (char) c; \
                if ( c == '\n' ) \
                        buf[n++] = (char) c; \
                if ( c == EOF && ferror( aoin ) ) \
                        YY_FATAL_ERROR( "input in flex scanner failed" ); \
                result = n; \
                } \
        else \
                { \
                errno=0; \
                while ( (result = fread(buf, 1, max_size, aoin))==0 && ferror(aoin)) \
                        { \
                        if( errno != EINTR) \
                                { \
                                YY_FATAL_ERROR( "input in flex scanner failed" ); \
                                break; \
                                } \
                        errno=0; \
                        clearerr(aoin); \
                        } \
                }\
\
#define YY_INT_ALIGNED   short int
#define YY_LESS_LINENO ( n   ) 
Value:
do { \
                int yyl;\
                for ( yyl = n; yyl < aoleng; ++yyl )\
                    if ( aotext[yyl] == '\n' )\
                        --aolineno;\
            }while(0)
#define yy_load_buffer_state   ao_load_buffer_state
#define YY_MORE_ADJ   0
#define yy_new_buffer   ao_create_buffer
#define YY_NEW_FILE   aorestart(aoin )
#define YY_NULL   0
#define YY_NUM_RULES   23
#define YY_READ_BUF_SIZE   8192
#define YY_RESTORE_YY_MORE_OFFSET
#define YY_RULE_SETUP   YY_USER_ACTION
#define YY_SC_TO_UI (  )     ((unsigned int) (unsigned char) c)
#define yy_set_bol ( at_bol   ) 
Value:
{ \
        if ( ! YY_CURRENT_BUFFER ){\
        aoensure_buffer_stack (); \
                YY_CURRENT_BUFFER_LVALUE =    \
            ao_create_buffer(aoin,YY_BUF_SIZE ); \
        } \
        YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
        }
#define yy_set_interactive ( is_interactive   ) 
Value:
{ \
        if ( ! YY_CURRENT_BUFFER ){ \
        aoensure_buffer_stack (); \
                YY_CURRENT_BUFFER_LVALUE =    \
            ao_create_buffer(aoin,YY_BUF_SIZE ); \
        } \
        YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
        }
#define YY_START   (((yy_start) - 1) / 2)
#define YY_START_STACK_INCR   25
#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
#define YY_STATE_EOF ( state   )     (YY_END_OF_BUFFER + state + 1)
#define yy_switch_to_buffer   ao_switch_to_buffer

Referenced by yy_scan_buffer().

#define yyalloc   aoalloc

Referenced by yy_scan_buffer(), and yy_scan_bytes().

#define yyconst
#define yyfree   aofree

Referenced by yylex_destroy().

FILE * yyin   aoin

Referenced by yyget_in(), and yyset_in().

int yyleng   aoleng

Referenced by yyget_leng().

#define yyless ( n   ) 
Value:
do \
                { \
                /* Undo effects of setting up aotext. */ \
        int yyless_macro_arg = (n); \
        YY_LESS_LINENO(yyless_macro_arg);\
                aotext[aoleng] = (yy_hold_char); \
                (yy_c_buf_p) = aotext + yyless_macro_arg; \
                (yy_hold_char) = *(yy_c_buf_p); \
                *(yy_c_buf_p) = '\0'; \
                aoleng = yyless_macro_arg; \
                } \
        while ( 0 )
#define yyless ( n   ) 
Value:
do \
                { \
                /* Undo effects of setting up aotext. */ \
        int yyless_macro_arg = (n); \
        YY_LESS_LINENO(yyless_macro_arg);\
                *yy_cp = (yy_hold_char); \
                YY_RESTORE_YY_MORE_OFFSET \
                (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
                YY_DO_BEFORE_ACTION; /* set up aotext again */ \
                } \
        while ( 0 )
#define yylex   aolex
int yylineno   aolineno
 
#define yymore (  )     yymore_used_but_not_detected
FILE * yyout   aoout

Referenced by yyget_out(), and yyset_out().

#define yyrealloc   aorealloc
#define yyrestart   aorestart
#define YYSTATE   YY_START
#define YYSTYPE   char*

Referenced by yyparse().

#define YYTABLES_NAME   "yytables"
 
#define yyterminate (  )     return YY_NULL
char * yytext   aotext
#define yytext_ptr   aotext
int yywrap   aowrap

Typedef Documentation

typedef short int flex_int16_t
typedef int flex_int32_t
typedef signed char flex_int8_t
typedef unsigned short int flex_uint16_t
typedef unsigned int flex_uint32_t
typedef unsigned char flex_uint8_t
typedef unsigned char YY_CHAR
typedef size_t yy_size_t
typedef int yy_state_type

Function Documentation

YY_BUFFER_STATE ao_create_buffer ( FILE *  file,
int  size 
)
void ao_delete_buffer ( YY_BUFFER_STATE  b  ) 
void ao_flush_buffer ( YY_BUFFER_STATE  b  ) 

Discard all buffered characters. On the next scan, YY_INPUT will be called.

Parameters:
b the buffer state to be flushed, usually YY_CURRENT_BUFFER.

References yy_buffer_state::yy_at_bol, yy_buffer_state::yy_buf_pos, YY_BUFFER_NEW, yy_buffer_state::yy_buffer_status, yy_buffer_state::yy_ch_buf, YY_CURRENT_BUFFER, YY_END_OF_BUFFER_CHAR, and yy_buffer_state::yy_n_chars.

YY_BUFFER_STATE ao_scan_buffer ( char *  base,
yy_size_t  size 
)

Setup the input buffer state to scan directly from a user-specified character buffer.

Parameters:
base the character buffer
size the size in bytes of the character buffer
Returns:
the newly allocated buffer state object.

References ao_switch_to_buffer(), aoalloc(), yy_buffer_state::yy_at_bol, yy_buffer_state::yy_buf_pos, yy_buffer_state::yy_buf_size, YY_BUFFER_NEW, yy_buffer_state::yy_buffer_status, yy_buffer_state::yy_ch_buf, YY_END_OF_BUFFER_CHAR, YY_FATAL_ERROR, yy_buffer_state::yy_fill_buffer, yy_buffer_state::yy_input_file, yy_buffer_state::yy_is_interactive, yy_buffer_state::yy_is_our_buffer, and yy_buffer_state::yy_n_chars.

Referenced by ao_scan_bytes().

YY_BUFFER_STATE ao_scan_bytes ( yyconst char *  yybytes,
int  _yybytes_len 
)

Setup the input buffer state to scan the given bytes. The next call to aolex() will scan from a copy of bytes.

Parameters:
yybytes the byte buffer to scan
_yybytes_len the number of bytes in the buffer pointed to by bytes.
Returns:
the newly allocated buffer state object.

References ao_scan_buffer(), aoalloc(), n, YY_END_OF_BUFFER_CHAR, YY_FATAL_ERROR, and yy_buffer_state::yy_is_our_buffer.

Referenced by ao_scan_string().

YY_BUFFER_STATE ao_scan_string ( yyconst char *  yystr  ) 

Setup the input buffer state to scan a string. The next call to aolex() will scan from a copy of str.

Parameters:
yystr a NUL-terminated string to scan
Returns:
the newly allocated buffer state object.
Note:
If you want to scan bytes that may contain NUL values, then use ao_scan_bytes() instead.

References ao_scan_bytes().

void ao_switch_to_buffer ( YY_BUFFER_STATE  new_buffer  ) 

Referenced by ao_scan_buffer().

void * aoalloc ( yy_size_t  size  ) 

Referenced by ao_scan_buffer(), and ao_scan_bytes().

void aoerror ( const char *   ) 
void aofree ( void *  ptr  ) 

Referenced by aolex_destroy().

int aoget_debug ( void   ) 
YY_EXTRA_TYPE aoget_extra ( void   ) 
FILE * aoget_in ( void   ) 

Get the input stream.

References aoin.

int aoget_leng ( void   ) 

Get the length of the current token.

References aoleng.

int aoget_lineno ( void   ) 

Get the current line number.

FILE * aoget_out ( void   ) 

Get the output stream.

References aoout.

char * aoget_text ( void   ) 

Get the current token.

int aolex ( void   ) 
int aolex_destroy ( void   ) 
void aopop_buffer_state ( void   ) 

Removes and deletes the top of the stack, if present. The next element becomes the new top.

References ao_delete_buffer(), YY_CURRENT_BUFFER, and YY_CURRENT_BUFFER_LVALUE.

Referenced by aolex_destroy().

void aopush_buffer_state ( YY_BUFFER_STATE  new_buffer  ) 

Pushes the new state onto the stack. The new state becomes the current state. This function will allocate the stack if necessary.

Parameters:
new_buffer The new state.

References YY_CURRENT_BUFFER, and YY_CURRENT_BUFFER_LVALUE.

void * aorealloc ( void *  ptr,
yy_size_t  size 
)
void aorestart ( FILE *  input_file  ) 
void aoset_debug ( int  debug_flag  ) 
void aoset_extra ( YY_EXTRA_TYPE  user_defined  ) 
void aoset_in ( FILE *  in_str  ) 

Set the input stream. This does not discard the current input buffer.

Parameters:
in_str A readable stream.
See also:
ao_switch_to_buffer

References aoin.

Referenced by cpp(), and dopascal().

void aoset_lineno ( int  line_number  ) 

Set the current line number.

Parameters:
line_number 
void aoset_out ( FILE *  out_str  ) 

References aoout.

int aowrap ( void   ) 

Variable Documentation

int ao_flex_debug = 0
FILE * aoin = (FILE *) 0

Referenced by aoget_in(), and aoset_in().

int aoleng

Referenced by aoget_leng().

int aolineno = 1
FILE * aoout = (FILE *) 0

Referenced by aoget_out(), and aoset_out().

char * aotext
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by  doxygen 1.6.2