home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / POLYEDIT.LZH / ML / SCANNER.H < prev    next >
C/C++ Source or Header  |  1996-01-17  |  4KB  |  138 lines

  1. /*
  2.  *        トークン読み込み関数
  3.  *
  4.  *        T.Kobayashi        1993.8.5
  5.  */
  6.  
  7. #define    SCANNER        1
  8.  
  9. #ifndef    DATA
  10.     #include "data.h"
  11. #endif
  12.  
  13. /*    入力用構造体    */
  14. typedef    struct    {
  15.     FILE            *fp ;
  16.     unsigned char    *last ;
  17.     unsigned char    *buf, *ptr ;
  18.     int                ch, ch1 ;
  19.     int                token ;
  20.     char            str[IDENT_CHARS+1] ;
  21.     DataStruct        data ;
  22. }
  23.     InputStruct ;
  24.  
  25. extern    InputStruct    Input ;
  26. extern    char        *InputFile ;
  27. extern    int            InputLine ;
  28.  
  29. /*    定数リスト    */
  30. typedef    struct    {
  31.     char        *name ;
  32.     DataStruct    data ;
  33. }
  34.     ConstStruct ;
  35.  
  36. extern    int            SysConsts ;
  37. extern    ConstStruct    SysConst[] ;
  38.  
  39.  
  40. /*
  41.  *        識別子
  42.  */
  43. #define        SYM_IDENT        0x00000
  44.  
  45.  
  46. /*
  47.  *        特殊文字
  48.  */
  49. #define        SYM_SPL_CHAR    0x10000
  50.  
  51. /*    かっこ    */
  52. #define        SYM_OPEN1        (SYM_SPL_CHAR+1)    /*    (    */
  53. #define        SYM_CLOSE1        (SYM_SPL_CHAR+2)    /*    )    */
  54. #define        SYM_OPEN2        (SYM_SPL_CHAR+3)    /*    {    */
  55. #define        SYM_CLOSE2        (SYM_SPL_CHAR+4)    /*    }    */
  56. #define        SYM_OPEN3        (SYM_SPL_CHAR+5)    /*    [    */
  57. #define        SYM_CLOSE3        (SYM_SPL_CHAR+6)    /*    ]    */
  58.  
  59. /*    四則演算    */
  60. #define        SYM_PLUS        (SYM_SPL_CHAR+11)    /*    +    */
  61. #define        SYM_MINUS        (SYM_SPL_CHAR+12)    /*    -    */
  62. #define        SYM_MULT        (SYM_SPL_CHAR+13)    /*    *    */
  63. #define        SYM_DIVIDE        (SYM_SPL_CHAR+14)    /*    /    */
  64. #define        SYM_MOD            (SYM_SPL_CHAR+15)    /*    %    */
  65. #define        SYM_DOT            (SYM_SPL_CHAR+16)    /*    .    */
  66. #define        SYM_REFER        (SYM_SPL_CHAR+17)    /*    ->    */
  67.  
  68. /*    論理演算    */
  69. #define        SYM_AND            (SYM_SPL_CHAR+22)    /*    &    */
  70. #define        SYM_OR            (SYM_SPL_CHAR+23)    /*    |    */
  71. #define        SYM_XOR            (SYM_SPL_CHAR+24)    /*    ^    */
  72. #define        SYM_NOT            (SYM_SPL_CHAR+25)    /*    !    */
  73.  
  74. /*    比較    */
  75. #define        SYM_NOTEQ        (SYM_SPL_CHAR+31)    /*    !=    */
  76. #define        SYM_EQ            (SYM_SPL_CHAR+32)    /*    ==    */
  77. #define        SYM_LSS            (SYM_SPL_CHAR+33)    /*    <    */
  78. #define        SYM_GTR            (SYM_SPL_CHAR+34)    /*    >    */
  79. #define        SYM_LSSEQ        (SYM_SPL_CHAR+35)    /*    <=    */
  80. #define        SYM_GTREQ        (SYM_SPL_CHAR+36)    /*    >=    */
  81.  
  82. /*    シフト演算    */
  83. #define        SYM_LSFT        (SYM_SPL_CHAR+37)    /*    <<    */
  84. #define        SYM_RSFT        (SYM_SPL_CHAR+38)    /*    >>    */
  85.  
  86. /*    代入    */
  87. #define        SYM_ASSIGN        (SYM_SPL_CHAR+41)    /*    =    */
  88. #define        SYM_ASN_PLUS    (SYM_SPL_CHAR+42)    /*    +=    */
  89. #define        SYM_ASN_MINUS    (SYM_SPL_CHAR+43)    /*    -=    */
  90. #define        SYM_ASN_MULT    (SYM_SPL_CHAR+44)    /*    *=    */
  91. #define        SYM_ASN_DIVIDE    (SYM_SPL_CHAR+45)    /*    /=    */
  92. #define        SYM_ASN_AND        (SYM_SPL_CHAR+46)    /*    &=    */
  93. #define        SYM_ASN_OR        (SYM_SPL_CHAR+47)    /*    |=    */
  94. #define        SYM_ASN_XOR        (SYM_SPL_CHAR+48)    /*    ^=    */
  95. #define        SYM_ASN_INC        (SYM_SPL_CHAR+49)    /*    ++    */
  96. #define        SYM_ASN_DEC        (SYM_SPL_CHAR+50)    /*    --    */
  97.  
  98. /*    その他    */
  99. #define        SYM_COMMA        (SYM_SPL_CHAR+61)    /*    ,    */
  100. #define        SYM_SEMCLN        (SYM_SPL_CHAR+62)    /*    ;    */
  101. #define        SYM_COLON        (SYM_SPL_CHAR+63)    /*    :    */
  102. #define        SYM_PREPROC        (SYM_SPL_CHAR+64)    /*    #    */
  103. #define        SYM_EOF            (SYM_SPL_CHAR+70)
  104. #define        SYM_UNKNOWN        (SYM_SPL_CHAR+71)
  105.  
  106. /*
  107.  *        予約語
  108.  */
  109. #define        SYM_RESERVED    0x20000
  110. #define        SYM_BREAK        (SYM_RESERVED+1)
  111. #define        SYM_CONST        (SYM_RESERVED+2)
  112. #define        SYM_CONTINUE    (SYM_RESERVED+3)
  113. #define        SYM_DO            (SYM_RESERVED+4)
  114. #define        SYM_ELSE        (SYM_RESERVED+5)
  115. #define        SYM_FOR            (SYM_RESERVED+6)
  116. #define        SYM_FUNCTION    (SYM_RESERVED+7)
  117. #define        SYM_IF            (SYM_RESERVED+8)
  118. #define        SYM_PRIVATE        (SYM_RESERVED+9)
  119. #define        SYM_RETURN        (SYM_RESERVED+10)
  120. #define        SYM_VAR            (SYM_RESERVED+11)
  121. #define        SYM_WHILE        (SYM_RESERVED+12)
  122.  
  123. /*
  124.  *        定数
  125.  */
  126. #define        SYM_CONSTDATA    0x40000
  127.  
  128.  
  129. /*
  130.  *        プロトタイプ
  131.  */
  132. /*    scanner.c    */
  133. extern    void    ScannerInit( void );
  134. extern    void    SetSystemConst( char*, DataStruct* );
  135. extern    void    FileOpen( char* );
  136. extern    void    FileClose( void );
  137. extern    int        GetToken( void );
  138.