home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 20 / AACD20.BIN / AACD / Programming / Jikes / Source / src / scanner.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-24  |  3.3 KB  |  135 lines

  1. // $Id: scanner.h,v 1.8 2001/01/05 09:13:21 mdejong Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #ifndef scanner_INCLUDED
  11. #define scanner_INCLUDED
  12.  
  13. #include "platform.h"
  14. #include "code.h"
  15. #include "javadef.h"
  16. #include "javasym.h"
  17. #include "stream.h"
  18.  
  19. #ifdef HAVE_CTYPE_H
  20. #include <ctype.h>
  21. #endif
  22.  
  23. #ifdef HAVE_TIME_H
  24. #include <time.h>
  25. #endif
  26.  
  27. #ifdef    HAVE_JIKES_NAMESPACE
  28. namespace Jikes {    // Open namespace Jikes block
  29. #endif
  30.  
  31. class Control;
  32. class FileSymbol;
  33.  
  34. //
  35. // The Scanner object
  36. //
  37. class Scanner
  38. {
  39. public:
  40.  
  41.     Scanner(Control &);
  42.  
  43.     ~Scanner() { }
  44.  
  45.     void SetUp(FileSymbol *);
  46.     void Scan(FileSymbol *);
  47.  
  48. private:
  49.     Control &control;
  50.  
  51.     LexStream* lex;
  52.     wchar_t *cursor;
  53.  
  54.     LexStream::Token *current_token;
  55.     LexStream::TokenIndex current_token_index;
  56.  
  57.     void Initialize(FileSymbol *);
  58.     void Scan();
  59.  
  60.     static int (*scan_keyword[13]) (wchar_t *p1);
  61.     static int ScanKeyword0(wchar_t *p1);
  62.     static int ScanKeyword2(wchar_t *p1);
  63.     static int ScanKeyword3(wchar_t *p1);
  64.     static int ScanKeyword4(wchar_t *p1);
  65.     static int ScanKeyword5(wchar_t *p1);
  66.     static int ScanKeyword6(wchar_t *p1);
  67.     static int ScanKeyword7(wchar_t *p1);
  68.     static int ScanKeyword8(wchar_t *p1);
  69.     static int ScanKeyword9(wchar_t *p1);
  70.     static int ScanKeyword10(wchar_t *p1);
  71.     static int ScanKeyword12(wchar_t *p1);
  72.  
  73.     inline void CheckOctalLiteral(wchar_t *, wchar_t *);
  74.     inline void SkipSpaces();
  75.     void ScanSlashComment();
  76.     void ScanStarComment();
  77.  
  78.     class BraceStack
  79.     {
  80.     public:
  81.         void Push(LexStream::TokenIndex brace) { table.Next() = brace; }
  82.         void Pop()                             { if (table.Length() > 0) table.Reset(table.Length() - 1); }
  83.         int  Size()                            { return table.Length(); }
  84.         LexStream::TokenIndex Top()            { return (table.Length() > 0 ? table[table.Length() - 1] : 0); }
  85.  
  86.     private:
  87.         Tuple<LexStream::TokenIndex> table;
  88.     } brace_stack;
  89.  
  90.     void (Scanner::*classify_token[128 + 1])();
  91.  
  92.     void ClassifyCharLiteral();
  93.     void ClassifyStringLiteral();
  94.     void ClassifyIdOrKeyword();
  95.     void ClassifyId();
  96.     void ClassifyNumericLiteral();
  97.     void ClassifyColon();
  98.     void ClassifyPlus();
  99.     void ClassifyMinus();
  100.     void ClassifyStar();
  101.     void ClassifyDocComment();
  102.     void ClassifySlash();
  103.     void ClassifyLess();
  104.     void ClassifyGreater();
  105.     void ClassifyAnd();
  106.     void ClassifyOr();
  107.     void ClassifyXor();
  108.     void ClassifyNot();
  109.     void ClassifyEqual();
  110.     void ClassifyMod();
  111.     void ClassifyPeriod();
  112.     void ClassifySemicolon();
  113.     void ClassifyComma();
  114.     void ClassifyLbrace();
  115.     void ClassifyRbrace();
  116.     void ClassifyLparen();
  117.     void ClassifyRparen();
  118.     void ClassifyLbracket();
  119.     void ClassifyRbracket();
  120.     void ClassifyComplement();
  121.     void ClassifyPound();
  122.     void ClassifyBadToken();
  123.     void ClassifyQuestion();
  124.     void ClassifyEof();
  125.  
  126.     void ClassifyNonAsciiUnicode();
  127. };
  128.  
  129. #ifdef    HAVE_JIKES_NAMESPACE
  130. }            // Close namespace Jikes block
  131. #endif
  132.  
  133. #endif
  134.  
  135.