亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? typechecker.java

?? java實現(xiàn)的一個pascal編譯器
?? JAVA
?? 第 1 頁 / 共 5 頁
字號:
/**
 * File : TypeChecker.java
 * Description : This class is used in the semantic analysis phase
 * of the compiler for JPascal. It certifies that the operators are
 * applied to the correct type, that the variables are of the same
 * type, and it also checks if the literals are not out of range.
 */
package uk.co.brainycreatures.jpascal.semantic;

import uk.co.brainycreatures.jpascal.node.*;
import uk.co.brainycreatures.jpascal.analysis.*;
import java.util.*;

public class TypeChecker extends DepthFirstAdapter implements Types {
  /**
   * used by previous_entity.
   */
  private final short PROGRAM = 0;
  
  /**
   * same as above.
   */
  private final short MONITOR = 1;

  /**
   * used to distinguish between a program's procedure and a 
   * monitor's procedure.
   */
  private short previous_entity = PROGRAM;

  /**
   * true when a procedure call.
   */
  private boolean procedure_call = false;

  /**
   * used to hold the type of a variable(s) or the type of
   * returned by a function
   */
  private Type type;

  /**
   * true when a channel operation is requested.
   */
  private boolean channel_operations = false;

  /**
   * stores all the procedures and functions that raise
   * exceptions.
   */
  private Hashtable throws_table = new Hashtable();

  /**
   * used when a try statement is accessed
   */
  private boolean try_statement = false;

  /**
   * true when the declarations or statements are
   * in a program
   */
  private boolean program = true; 

  /**
   * true when the declarations are local to a monitor
   */
  private boolean monitor = false;

  /**
   * used when statements meant to be used inside
   * a process are present
   */
  private boolean process = false;

  /**
   * true when a function
   */
  private boolean function = false;

  /**
   * true when a monitor call is processed.
   */
  private boolean monitor_call = false;

  /**
   * name of the current function
   */
  private String current_function;

  /**
   * used to hold the identifiers of a global 
   * declaration part
   */
  private Hashtable global_table = new Hashtable();

  /**
   * Used to hold identifiers local to a 
   * monitor
   */
  private Hashtable monitor_table = new Hashtable();

  /**
   * stores the list of identifiers in a procedure or
   * function throws heading.
   */
  private Hashtable throws_list = new Hashtable();

  /**
   * used to hold identifiers local to a procedure
   * function or process.
   */
  private Hashtable local_table = new Hashtable();

  /**
   * used to hold the type of each argument and the 
   * number of arguments expected (size of vector)
   */
   private Vector arguments = new Vector();

  /**
   * stores identifiers found in a variables
   * declaration part and functions or procedures
   * parameters.
   */
  private Vector idlist = new Vector();

  /** 
   * stores the type of each expression passed as an argument
   * to a function or procedure.
   */
  private Vector exp_list = new Vector();

  /**
   * true if the procedure local to a monitor is
   * private
   */
  private boolean private_modifier = false;

  /**
   * reports error messages
   */
  ErrorMessage err = new ErrorMessage();

  /**
   * private_mod =
   *   {non_empty} private |
   *   {empty} ;
   *
   * if the private keyword is present, then alternative
   * {non_empty} will set private_modifier to true
   */
  public void outANonEmptyPrivateMod(ANonEmptyPrivateMod node) {
    private_modifier = true;
  }

  /**
   * const_declaration =
   *   identifier equal constant semicolon
   * puts the identifier in the corresponding symbol table
   */
  public void outAConstDeclaration(AConstDeclaration node) {
    TIdentifier ident = node.getIdentifier();
    String key = ident.getText().toUpperCase();

    // is this a program
    if (program) { // put it in the global table
      global_table.put(key, new Constant(type));
    }
    else if (monitor) { //oh! this is a monitor
      // put it in the monitor table
      monitor_table.put(key, new Constant(type));
    } 
    else { // it must be a process, function or procedure
      // put it in the local table
      local_table.put(key, new Constant(type));
    }
  }

  /**
   * constant =
   *   {identifier} identifier |
   *
   * sets type to constant's type and checks if it is 
   * a constant in a process, monitor, function or procedure
   * declaration section
   */
  public void outAIdentifierConstant(AIdentifierConstant node) {
    TIdentifier ident = node.getIdentifier();
    String key = ident.getText().toUpperCase();
    Object entity = null;

    if (program) {
      entity = global_table.get(key);
      if ((entity instanceof Variable) && channel_operations) {
        type = ((Variable) entity).getType();
      }
      else {
        type = ((Constant) entity).getType();
      } 
    }
    else if (monitor) {
      if (monitor_table.containsKey(key)) {
        entity = monitor_table.get(key);
        if ((entity instanceof Variable) && channel_operations) {
          type = ((Variable) entity).getType();
        }
        else {
          type = ((Constant) entity).getType();
        }
      }
      else {
        entity = global_table.get(key);
        if ((entity instanceof Variable) && channel_operations) {
          type = ((Variable) entity).getType();
        }
        else if (entity instanceof Constant) {
          type = ((Constant) entity).getType();
        }
        else {
          err.report(3, ident.getLine(), ident.getPos());
        }
      }
    }
    else { 
      if (local_table.containsKey(key)) {
        entity = local_table.get(key);
        if ((entity instanceof Variable) && channel_operations) {
          type = ((Variable) entity).getType();
        }
        else {
          type = ((Constant) entity).getType();
        }
      }
      else {
        entity = global_table.get(key);
        if ((entity instanceof Variable) && channel_operations) {
          type = ((Variable) entity).getType();
        }
        else if (entity instanceof Constant) {
          type = ((Constant) entity).getType();
        }
        else {
          err.report(3, ident.getLine(), ident.getPos());
        }
      }
    }
  }

  /**
   * constant =
   *  .......... |
   *  {signedidentifier} sign identifier |
   *  .......... |
   *  .......... ;
   * @see TypeChecker.outAIdentifierConstant
   */
  public void outASignedidentifierConstant(ASignedidentifierConstant node) {
    TIdentifier ident = node.getIdentifier();
    String key = ident.getText().toUpperCase();
    Object entity = null;

    if (program) {
      entity = global_table.get(key);
      if ((entity instanceof Variable) && channel_operations) {
        type = ((Variable) entity).getType();
      }
      else {
        type = ((Constant) entity).getType();
      }
    }
    else if (monitor) {
      if (monitor_table.containsKey(key)) {
        entity = monitor_table.get(key);
        if ((entity instanceof Variable) && channel_operations) {
          type = ((Variable) entity).getType();
        }
        else {
          type = ((Constant) entity).getType();
        }
      }
      else {
        entity = global_table.get(key);
        if ((entity instanceof Variable) && channel_operations) {
          type = ((Variable) entity).getType();
        }
        else if (entity instanceof Constant) {
          type = ((Constant) entity).getType();
        }
        else {
          err.report(3, ident.getLine(), ident.getPos());
        }
      }
    }
    else { 
      if (local_table.containsKey(key)) {
        entity = global_table.get(key);
        if ((entity instanceof Variable) && channel_operations) {
          type = ((Variable) entity).getType();
        }
        else {
          type = ((Constant) entity).getType();
        }
      }
      else {
        entity = global_table.get(key);
        if ((entity instanceof Variable) && channel_operations) {
          type = ((Variable) entity).getType();
        }
        else if (entity instanceof Constant) {
          type = ((Constant) entity).getType();
        }
        else {
          err.report(3, ident.getLine(), ident.getPos());
        }
      }
    }
  }

  /**
   * constant =
   *   ............ |
   *   {signedinteger} sign integer_literal |
   *   ............ |
   *   ............ ;
   * reports an error if the identifier is out of range
   */
  public void outASignedintegerConstant(ASignedintegerConstant node) {
    TIntegerLiteral int_lit= node.getIntegerLiteral();
    PSign sign = node.getSign();
    String image = int_lit.getText();

    type = INTEGER;

    if (sign instanceof APlusSign) {
      image = "+" + image;
    }
    else {
      image = "-" + image;
    }

    try {
      int value = Integer.parseInt(image);

      if ((value < Integer.MIN_VALUE) || (value > Integer.MAX_VALUE)) {
        err.report(6, int_lit.getLine(), int_lit.getPos());
      }
    }
    catch (NumberFormatException ex) {
      err.report(6, int_lit.getLine(), int_lit.getPos());
    }
  }

  /**
   * constant =
   *    ........ |
   *    {unsignedinteger} integer_literal |
   *    ........ | 
   *    ........ ;
   * @see TypeChecker.outASignedIntegerConstant
   */
  public void outAUnsignedintegerConstant(AUnsignedintegerConstant node) {
    TIntegerLiteral int_lit= node.getIntegerLiteral();
    String image = int_lit.getText();

    type = INTEGER;

    try {
      int value = Integer.parseInt(image);
      if (value > Integer.MAX_VALUE) {
        err.report(6, int_lit.getLine(), int_lit.getPos());
      }
    }
    catch (NumberFormatException ex) {
      err.report(6, int_lit.getLine(), int_lit.getPos());
    }
  }

  /**
   * constant =
   *    ............ |
   *    {signedreal} sign real_literal |
   *    .............. ;
   * reports an error if the real_literal is 
   * out of range.
   */
  public void outASignedrealConstant(ASignedrealConstant node) {
    TRealLiteral real_lit = node.getRealLiteral();
    String image = real_lit.getText();
    PSign sign = node.getSign();
  
    type = REAL;

    if (sign instanceof APlusSign) {
      image = "+" + image;
    }
    else {
      image = "-" + image;
    }

    try {
      float value = Float.valueOf(image).floatValue();
      if ((value < (float) (-3.4028235e38)) || (value > Float.MAX_VALUE)) {
        err.report(17, real_lit.getLine(), real_lit.getPos());
      }
    } 
    catch (NumberFormatException ex) {
      err.report(17, real_lit.getLine(), real_lit.getPos());
    }
  }
  
  /**
   * constant =
   *   ........... |
   *   {unsignedreal} real_literal |
   *   ........... ;
   */
  public void outAUnsignedrealConstant(AUnsignedrealConstant node) {
    TRealLiteral real_lit = node.getRealLiteral();
    String image = real_lit.getText();

    type = REAL;
    try {
      float value = Float.valueOf(image).floatValue();
      if (value > Float.MAX_VALUE) {
        err.report(17, real_lit.getLine(), real_lit.getPos());
      }
    } 
    catch (NumberFormatException ex) {
      err.report(17, real_lit.getLine(), real_lit.getPos());

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲高清久久久| 国产女主播在线一区二区| 亚洲一区二区影院| 欧美性一二三区| 天天色综合成人网| 制服丝袜亚洲色图| 激情伊人五月天久久综合| 精品国产sm最大网站免费看| 国产精品亚洲综合一区在线观看| 国产亚洲一区二区三区四区| 国产91精品露脸国语对白| 1024成人网| 欧美一区二区视频观看视频| 国产精品资源在线观看| 亚洲激情在线播放| 日韩午夜av电影| 国产剧情在线观看一区二区| 亚洲精品免费在线| 日韩一级完整毛片| proumb性欧美在线观看| 视频一区免费在线观看| 欧美经典一区二区| 欧美三级视频在线观看| 激情成人午夜视频| 亚洲一二三四区不卡| 精品日本一线二线三线不卡| jlzzjlzz国产精品久久| 美日韩黄色大片| 亚洲欧美日韩系列| 精品对白一区国产伦| 色噜噜狠狠色综合中国| 国产在线视视频有精品| 亚洲黄色小说网站| 久久先锋影音av| 欧美日韩精品一区二区| 成人av电影在线播放| 日韩在线观看一区二区| 日韩一区中文字幕| 精品少妇一区二区三区免费观看| 日韩欧美国产综合在线一区二区三区 | 日韩欧美一区二区三区在线| 国产99久久久国产精品免费看| 午夜精品免费在线观看| 中文字幕一区二区日韩精品绯色| 欧美一卡二卡三卡| 91激情在线视频| 国v精品久久久网| 久久99精品网久久| 亚洲成a人v欧美综合天堂| 亚洲国产高清在线观看视频| 日韩一区二区精品在线观看| 欧美在线视频日韩| 不卡av免费在线观看| 国产在线一区观看| 免费看日韩精品| 亚洲一区二区三区四区不卡| 中文字幕永久在线不卡| 欧美国产一区视频在线观看| 亚洲精品在线免费观看视频| 日韩欧美一区电影| 777久久久精品| 欧美日韩国产天堂| 在线观看日韩毛片| 欧美制服丝袜第一页| av影院午夜一区| 99re视频精品| 91玉足脚交白嫩脚丫在线播放| 成熟亚洲日本毛茸茸凸凹| 国产自产视频一区二区三区| 久久99蜜桃精品| 久久成人精品无人区| 日本不卡的三区四区五区| 丝袜脚交一区二区| 日韩av中文字幕一区二区三区| 日韩专区中文字幕一区二区| 婷婷国产在线综合| 男女男精品网站| 久久97超碰国产精品超碰| 老司机精品视频导航| 国内精品写真在线观看| 九色|91porny| 国产精一区二区三区| 成人小视频在线观看| 成人免费高清在线| 97久久超碰国产精品电影| 91美女在线看| 欧美精品久久天天躁| 欧美一卡二卡在线观看| 久久综合精品国产一区二区三区| 国产欧美精品国产国产专区 | 国产精品女同互慰在线看| 中文av一区二区| 亚洲人成网站在线| 爽爽淫人综合网网站| 久久国产三级精品| 成人妖精视频yjsp地址| 一本大道久久a久久精品综合| 欧美色综合网站| 欧美成人video| 国产精品乱码人人做人人爱| 亚洲精品成a人| 欧美性xxxxxxxx| 欧美一区二区三区视频在线| 久久伊99综合婷婷久久伊| 欧美激情中文字幕一区二区| 一区二区三区久久| 美国毛片一区二区三区| 成人av免费观看| 欧美一区二区二区| 国产精品久久久久精k8| 天天色图综合网| 国产成人免费视| 欧美天堂亚洲电影院在线播放| 日韩精品一区二区三区在线观看 | 久久久精品黄色| 亚洲精品免费一二三区| 久久精品免费观看| 色综合久久久久综合体| 欧美白人最猛性xxxxx69交| 成人欧美一区二区三区视频网页 | 国内外成人在线| 在线观看视频欧美| 久久午夜国产精品| 午夜私人影院久久久久| 岛国精品在线观看| 欧美狂野另类xxxxoooo| 国产精品乱码人人做人人爱 | 亚洲婷婷综合久久一本伊一区 | 有码一区二区三区| 久久成人免费网站| 欧美日韩精品系列| 国产精品日日摸夜夜摸av| 蜜臀av亚洲一区中文字幕| 一本大道av一区二区在线播放| 欧美va日韩va| 婷婷久久综合九色国产成人| va亚洲va日韩不卡在线观看| 欧美va亚洲va| 丝袜美腿高跟呻吟高潮一区| 91视频观看视频| 欧美国产一区二区在线观看 | 成人妖精视频yjsp地址| 欧美一级日韩免费不卡| 亚洲成人免费看| 久久久久久久免费视频了| 五月天网站亚洲| 91福利社在线观看| 专区另类欧美日韩| 国产成人午夜精品影院观看视频| 精品少妇一区二区三区日产乱码 | 日韩欧美第一区| 亚洲国产精品久久久男人的天堂| 成人app在线| 国产人妖乱国产精品人妖| 久久99久久99小草精品免视看| 欧美三级电影网站| 一片黄亚洲嫩模| 色综合久久久久综合| 亚洲欧美一区二区三区极速播放| 国产美女久久久久| 精品国产91乱码一区二区三区| 青青青爽久久午夜综合久久午夜| 欧美午夜一区二区| 午夜精品成人在线视频| 欧美日韩欧美一区二区| 一区二区三区成人在线视频| 一本久久a久久免费精品不卡| 国产精品久久久爽爽爽麻豆色哟哟| 国产91精品久久久久久久网曝门| 国产婷婷一区二区| 丁香一区二区三区| 国产精品久久久久一区| 99免费精品在线观看| 亚洲美女视频在线| 欧美午夜影院一区| 日韩精品成人一区二区在线| 欧美一区二区福利视频| 韩国欧美国产一区| 国产午夜亚洲精品理论片色戒| 成人深夜在线观看| 亚洲同性同志一二三专区| 欧美在线免费播放| 日韩二区三区四区| 久久嫩草精品久久久久| 国产91对白在线观看九色| 亚洲日本在线a| 在线电影院国产精品| 久88久久88久久久| 国产精品成人一区二区三区夜夜夜| 91亚洲精华国产精华精华液| 亚洲小少妇裸体bbw| 日韩午夜激情免费电影| 国产精品一区久久久久| 最新国产精品久久精品| 精品视频一区二区不卡| 蜜桃视频第一区免费观看| 国产女同互慰高潮91漫画| 91蝌蚪porny| 美国毛片一区二区| √…a在线天堂一区|