home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pascal.zip / parser / parser.hi < prev    next >
Text File  |  1995-10-29  |  3KB  |  132 lines

  1. /*
  2.  *        C . A . P .   P A R S E R
  3.  *
  4.  *        I N T E R N A L   I N C L U D E   F I L E
  5.  *
  6.  *        Stéphane Charette @ C.A.P. Services
  7.  *
  8.  *        Last modified:  Stéphane Charette, 1995 October 29
  9.  *
  10.  *****************************************************************************
  11.  *
  12.  *        Project:    BILL
  13.  *        Group:    parser
  14.  *        File:        parser\parser.hi
  15.  *
  16.  *        This file contains all of the internal definitions used with
  17.  *        the parser portion of the interpreter BILL.
  18.  */
  19.  
  20.  
  21.  
  22. #ifndef _PARSER_H_INTERNAL
  23.  
  24.     #define _PARSER_H_INTERNAL
  25.  
  26.     /*
  27.      *        Includes
  28.      */
  29.         #include "..\parser\parser.h"
  30.         #include "..\parser\pars_ids.h"
  31.         #include "..\lexical\lexical.h"
  32.         #include "..\symtable\symtable.h"
  33.         #include "..\pcode\pcode_id.h"
  34.         #include "..\pcode\pcode.h"
  35.         #include <stdio.h>                // file i/o
  36.         #include <string.h>                // strlen, strcpy
  37.         #include <stdlib.h>                // exit
  38.         #include <stdarg.h>                // vprintf, vfprintf
  39.  
  40.  
  41.  
  42.     /*
  43.      *        Defines
  44.      */
  45.  
  46.         #if( _PARSER_DEBUG )
  47.         #define PARSER_DEBUG_FILENAME "PARSER.TXT"    // output file for parser debug
  48.         #define PARSER_INDENT_VALUE 3                        // value by which to increment/decrement indentation
  49.         #endif
  50.  
  51.  
  52.  
  53.     /*
  54.      *        Types & structures
  55.      */
  56.         #if( _SYMTABLE_DEBUG )
  57.         struct PARSER_DEBUG_STRUCT
  58.         {
  59.             BOOL    ScreenOutput;    // enable screen output
  60.             BOOL    FileOutput;        // enable file output
  61.             USHORT    Indent;        // indentation value for parse tree
  62.         };
  63.         typedef struct PARSER_DEBUG_STRUCT PARSER_DEBUG;
  64.         #endif
  65.  
  66.         struct PARSER_STATES_STRUCT
  67.         {
  68.             UCHAR    Filename[PARSER_MAX_PATH_LEN+1];    // name of file to parse
  69.             ERR        Error;        // keeps track of errors
  70.         };
  71.         typedef struct PARSER_STATES_STRUCT PARSER_STATES;
  72.  
  73.  
  74.  
  75.     /*
  76.      *        Macros
  77.      */
  78.          #define _GetNextToken                                        \
  79.             RC = GetNextToken( );                                    \
  80.             if( RC ) ParserError( RC )
  81.  
  82.         #define _AcceptCurrent( tokentype, tokenerror )        \
  83.             if( Lex_State.TokenID != tokentype ) ParserError( tokenerror )
  84.  
  85.          #define _AcceptNext( tokentype, tokenerror )            \
  86.             _GetNextToken;                                                \
  87.             _AcceptCurrent( tokentype, tokenerror )
  88.  
  89.  
  90.  
  91.     /*
  92.      *        Local (internal) variables
  93.      */
  94.          PARSER_STATES    Parser_State;                // general parser state
  95.         #if( _SYMTABLE_DEBUG )
  96.         PARSER_DEBUG    Parser_Debug;              // parser debug states
  97.         FILE             *ParserDebugFilePtr;            // file pointer for debug output
  98.         #endif
  99.  
  100.  
  101.  
  102.     /*
  103.      *        Local (internal) prototyping
  104.      */
  105.          void ParserError( ERR );                    // sets error flag to specified ERR
  106.         void Parser_Program( void );
  107.         void Parser_Block( void );
  108.         void Parser_Constdeclaration( void );
  109.         void Parser_Vardeclaration( void );
  110.         void Parser_Statementpart( void );
  111.         void Parser_Statementsequence( void );
  112.         void Parser_Statement( void );
  113.         void Parser_Assignment( void );
  114.         void Parser_Expression( void );
  115.         void Parser_Term( void );
  116.         void Parser_Factor( void );
  117.         void Parser_Ifstatement( void );
  118.         void Parser_Whilestatement( void );
  119.         void Parser_Writestatement( void );
  120.         void Parser_Readstatement( void );
  121.         void Parser_Identsequence( void );
  122.         void Parser_Condition( void );
  123.         void Parser_Writelist( void );
  124.         #if( _SYMTABLE_DEBUG )
  125.         ERR ParserDebugWrite( UCHAR *text, ... );    // write debug information to screen/file
  126.         #endif
  127.  
  128.  
  129.  
  130. #endif
  131.  
  132.