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

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

?? javasourcegenerator.java

?? java實(shí)現(xiàn)的一個(gè)pascal編譯器
?? JAVA
?? 第 1 頁(yè) / 共 4 頁(yè)
字號(hào):
package uk.co.brainycreatures.jpascal.code;

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

import java.util.*;
import java.io.*;

public class JavaSourceGenerator extends DepthFirstAdapter {
  /**
   * used by previous_entity
   */
  private final short PROGRAM = 0;

  private final short MONITOR = 1;

  /**
   * name of main class
   */
  private String class_name;

  /**
   * set to true when an expression is being assigned to a function;
   */
  private boolean function_assign = false;

  /**
   * true if writeln or write statement
   */
  private boolean write_stmt = false;

  /**
   * value of constant assigned to a new constant being defined
   */
  private String const_value;

  /**
   * name of the source file
   */
  private String source_name;

  /**
   * stores the monitors procedures
   */
  private Hashtable monitor_procs = new Hashtable();

  /**
   * stores information about the identifiers of a program
   */
  private Hashtable global_table = new Hashtable();

  /**
   * stores information about the identifiers of a monitor
   */
  private Hashtable monitor_table = new Hashtable();

  /**
   * stores information about the identifiers of a procedure,
   * function or process.
   */
  private Hashtable local_table = new Hashtable();

  /**
   * index of an array
   */
  private String index;

  /**
   * true if a send statement is present
   */
  private boolean send_stmt;

  /**
   * used to generate the output file
   */
  private PrintWriter out;

  /**
   * program or monitor
   */
  private short previous_entity;

  /**
   * set to true if the declarations or statements are 
   * inside the main program block. Initially it is true, because
   * the first declarations belong to a program
   */
  private boolean program = true; 

  /**
   * size of a string
   */
  private String string_size;

  /**
   * value to be sent to a channel
   */
   private String value;

  /**
   * set to true if the declarations or statements are 
   * being processed in a monitor block
   */
  private boolean monitor = false;

  /**
   * set to true if the declarations are in a process
   */
  private boolean process = false;

  /**
   * list of identifiers
   */
  private Vector idlist = new Vector();

  /**
   * holds the name of the current monitor
   */
  private String monitor_name;

  /**
   * set to true if a private procedure
   */
  private boolean private_proc = false;

  /**
   * set to true if a monitor call statement is being processed
   */
  private boolean monitor_call = false;

  /**
   * type of variable, function or constant
   */
   private String type;

  /**
   * Default constructor
   */
  public JavaSourceGenerator(String source) {
    source_name = source;
    class_name = source.substring(0, source.length() - 4);
    try {
      out = new PrintWriter(new BufferedWriter(
                               new FileWriter(class_name + ".java")));
    }
    catch (Exception e) {
      System.out.println(e);
    }
    out.println("// file generated from " + source_name);
    out.println("// by JPascal's compiler ");
    out.println("// author: Fidel Viegas (viegasfh@hotmail.com)");
    out.println();
    out.println("public class " + class_name + " {");
  }

  /**
   * main_body =
   *  begin
   *    main_statement_part
   *  end;
   */
  public void inAMainBody(AMainBody node) {
    out.println("  public static void main(String[] args) {");
  }

  public void outAMainBody(AMainBody node) {
    out.println("  }");
    out.print("}");
  }

  // declarations

  /**
   * private_mod =
   * {non_empty} private |
   * generates the private modifier of a monitor procedure
   */
  public void outANonEmptyPrivateMod(ANonEmptyPrivateMod node) {
    out.print("    private ");
    private_proc = true;
  }

  /**
   * const_declaration =
   * identifier equal constant semicolon ;
   */
  public void outAConstDeclaration(AConstDeclaration node) {
    String const_name = node.getIdentifier().getText();
    if (program) {
      out.println("  static final " + type + " " + const_name + " = " + const_value + ";");
      global_table.put(const_name.toUpperCase(),
		new Constant(const_name, type));
    }
    else if (monitor) {
      out.println("    final " + type + " " + const_name + " = " + const_value + ";");
      monitor_table.put(const_name.toUpperCase(),
                        new Constant(const_name, type));
    }
    else {
      out.println("    final " + type + " " + const_name + " = " + const_value + ";");
      local_table.put(const_name.toUpperCase(),
                      new Constant(const_name, type));
    }
  }

  /**
   * constant =
   *  {identifier} identifier |
   * puts an identifier in the identifiers list of 
   * a variables declaration
   */
  public void outAIdentifierConstant(AIdentifierConstant node) {
    String key = node.getIdentifier().getText().toUpperCase();
    Object entity;

    // if this is a program
    if (program) {
      // get the attributes from the global table
      entity =  global_table.get(key);	
    }
    else if (monitor) { // else if this is a monitor
      // get the attributes from the monitor table
      entity = monitor_table.get(key);
    }
    else { // else if process, function or procedure
        // get the attributes from the local table
        entity = local_table.get(key);
    }
    if (entity instanceof Constant) {
      const_value = ((Constant)entity).getImage();
      type = ((Constant)entity).getType();
    }
    else { // for channel variable
      const_value = ((Variable) entity).getImage();
    }
  }

  /**
   * {signedidentifier} sign identifier |
   */
  public void outASignedidentifierConstant(ASignedidentifierConstant node) {
    String key = node.getIdentifier().getText().toUpperCase();
    Constant constant; 
    if (program) { // oh! this is a program.
      // then get the constant's attributes from the global table
      constant = (Constant) global_table.get(key); 
    }
    else if (monitor) { // alright! this is a monitor declaration
      // then check if the identifier is in the monitor table
      if (monitor_table.containsKey(key)) {
        constant = (Constant) monitor_table.get(key);
      }
      else { // Oh! it is in the globals declaration part
        constant = (Constant) global_table.get(key);
      }
    }
    else { // alright! this is either a procedure, process or 
      // function.
      // then check the locals table
      if (local_table.containsKey(key)) {
        constant = (Constant) local_table.get(key);
      }
      else { // oh! I see, it is in the global table
        constant = (Constant) global_table.get(key);
      }
    } 
    const_value = constant.getImage();
    type = constant.getType();
  }

  /**
   * {signedinteger} sign integer_literal |
   */
  public void outASignedintegerConstant(ASignedintegerConstant node) {
      type = "int";
      if (node.getSign() instanceof APlusSign) {
        const_value = "+" + node.getIntegerLiteral().getText();
      }
      else {
        const_value = "-" + node.getIntegerLiteral().getText();
      }
  }

  /**
   * {unsignedinteger} integer_literal |
   */
  public void outAUnsignedintegerConstant(AUnsignedintegerConstant node) {
      type = "int";
      const_value = node.getIntegerLiteral().getText();
  }

  /**
   * {signedreal} sign real_literal |
   */
  public void outASignedrealConstant(ASignedrealConstant node) {
      type = "double";
      if (node.getSign() instanceof APlusSign) {
        const_value = "+" + node.getRealLiteral().getText();
      }
      else {
        const_value = "-" + node.getRealLiteral().getText();
      }
  }

  /**
   * {unsignedreal} real_literal |
   */
  public void outAUnsignedrealConstant(AUnsignedrealConstant node) {
      type = "double";
      const_value = node.getRealLiteral().getText();
  }

  /**
   * {string} character_literal ;
   */
  public void outAStringConstant(AStringConstant node) {
      String char_lit = node.getCharacterLiteral().getText();
      if (node.getCharacterLiteral().getText().length() <= 3) {
        type = "char";
        const_value = "\"" + char_lit.substring(1, char_lit.length() - 1) + "\"";
      }
      else {
        type = "java.lang.String";
        const_value = "\"" + char_lit.substring(1, char_lit.length() - 1) +
          "\"";
      }
  }

  /**
   * var_declaration =
   *   var var_decl+ ;
   */
  public void inAVarDecl(AVarDecl node) {
    if (!idlist.isEmpty()) {
      idlist.removeAllElements();
    }
  }

  /**
   * var_decl =
   *   identifier_list colon P.type semicolon ;
   */
  public void outAVarDecl(AVarDecl node) {
    String var_name;
    for(Enumeration e = idlist.elements(); e.hasMoreElements();) {
      var_name = (String) e.nextElement();
      if (program) { // is this a program?
        global_table.put(var_name.toUpperCase(),
                        new Variable(var_name, type));
   
        // then indent once
        if (type.substring(type.length() - 2, type.length()).equals("[]")) {
          out.println("  static " + type + " " + var_name + " = new " +
            type.substring(0, type.length() -2) + "[" + index + "];");
        }
        else if (type.equals("exception")) {
          out.println("  static class " + var_name + " extends " +
            "java.lang.Exception {");
          out.println("  }");
        }
        else if (type.equals("uk.edu.sbu.seeie.jpascal.type.ChannelOfInteger")
              || type.equals("uk.edu.sbu.seeie.jpascal.type.ChannelOfReal")
              || type.equals("uk.edu.sbu.seeie.jpascal.type.ChannelOfChar")
              || type.equals("uk.edu.sbu.seeie.jpascal.type.ChannelOfBoolean")
              || type.equals("uk.edu.sbu.seeie.jpascal.type.ChannelOfString")) {
          out.println("  static " + type + " " + var_name + " = " +
              "new " + type + "();");
        }
        else if (type.equals("uk.edu.sbu.seeie.jpascal.type.Semaphore")) {
          out.println("  static " + type + " " + var_name + " = " +
             "new " + type + "(" + index + ");");
        }
        else {
          out.println("  static " + type + " " + var_name + ";");
        }
      }
      else { // No! this is a monitor, process, program, function or 
             // procedure
        if (type.substring(type.length() - 2, type.length()).equals("[]")) {
          out.println("    " + type + " " + var_name + " = new " +
             type.substring(0, type.length() - 2) + "[" + index + "];");
        }
        else if (type.equals("uk.edu.sbu.seeie.jpascal.type.Condition")) {
          out.println("    " + type + " " + var_name + " = " +
             "new " + type + "();");
        }
        else {
          out.println("    " + type + " " + var_name + ";");
        }
        // is this a monitor?
        // then put the identifier on the monitor table
        if (monitor) {
          monitor_table.put(var_name.toUpperCase(),
                          new Variable(var_name, type));
        }
        else { // oops! put it in the local table
          local_table.put(var_name.toUpperCase(), 
                        new Variable(var_name, type));
        }
      }
    }
  }

  /**
   * identifier_list =
   *   {single} identifier |
   */
  public void outASingleIdentifierList(ASingleIdentifierList node) {
      String name = node.getIdentifier().getText();
      idlist.addElement(name);
  }

  /**
   * {sequence} identifier_list comma identifier ;
   */
  public void outASequenceIdentifierList(ASequenceIdentifierList node) {
      String name = node.getIdentifier().getText();
      idlist.addElement(name);
  }

  /**
   * procedure_heading =
   *  {simple} procedure identifier semicolon |
   * generate the procedure heading
   */
  public void inASimpleProcedureHeading(ASimpleProcedureHeading node) {
    String name = node.getIdentifier().getText();
    // is this a program?
    // then store it in the global table
    if (program) {
      global_table.put(name.toUpperCase(), new Procedure(name));
      out.println("  static void " + node.getIdentifier().getText() + "() {");
      previous_entity = PROGRAM;
      program = false;
    }
    else if (monitor) { // this must be a monitor
      if (private_proc) {
        out.println("void " + node.getIdentifier().getText() + "() {");
	private_proc = false;
      }
      else {
        out.println("    public synchronized void " + node.getIdentifier().getText() + "() {");
      }
      monitor_table.put(name.toUpperCase(), new Procedure(name));
      monitor_procs.put(name.toUpperCase(), new Procedure(name));
      previous_entity = MONITOR;
      monitor = false;
    }
  }

  /**
   * {simple_throws} procedure identifier [s1]:semicolon throws
   *     identifier_list semicolon;
   */
  public void inASimpleThrowsProcedureHeading(ASimpleThrowsProcedureHeading node) {
    String name = node.getIdentifier().getText();
    // is this a program?
    // then store it in the global table
    if (program) {
      global_table.put(name.toUpperCase(), new Procedure(name));
      out.print("  static void " + node.getIdentifier().getText());
      previous_entity = PROGRAM;
      program = false;
    }
    else if (monitor) { // this must be a monitor
      if (private_proc) {
	private_proc = false;
      }
      else {
        out.print("    public synchronized void" + node.getIdentifier().getText());
      }
      monitor_table.put(name.toUpperCase(), new Procedure(name));
      monitor_procs.put(name.toUpperCase(), new Procedure(name));
      previous_entity = MONITOR;
      monitor = false;
    }
    if (!idlist.isEmpty()) {
      idlist.removeAllElements();
    }
  }

  /**
   * generates the throws part
   */
  public void outASimpleThrowsProcedureHeading(ASimpleThrowsProcedureHeading node) {
    out.print("() throws ");
    Enumeration e = idlist.elements();
    String key = ((String) e.nextElement()).toUpperCase();
    String id = ((Variable) global_table.get(key)).getImage();
    out.print(id);
    for (; e.hasMoreElements();) {
      key = ((String) e.nextElement()).toUpperCase();
      id = ((Variable) global_table.get(key)).getImage();
      out.print(", " + id);
    }
    out.println(" {");
  }

  /**
   * This method generates the heading for a procedure with arguments
   */
  public void inAArgumentsProcedureHeading(AArgumentsProcedureHeading node) {
    String name = node.getIdentifier().getText();
     // is this a program?
     if (program) {
       out.print("  static void " + name + "(");
       global_table.put(name.toUpperCase(), new Procedure(name));
       previous_entity = PROGRAM;
       program = false;
     }
     else { // indent twice
       out.print("    public synchronized void " + name + "(");
       monitor_table.put(name.toUpperCase(), new Procedure(name));

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品在线观看| 国产午夜亚洲精品不卡| 久久66热re国产| 综合色中文字幕| 欧美一区二区三区免费大片 | 欧美一区二区免费观在线| 国产一区二区伦理| 亚洲色大成网站www久久九九| 色系网站成人免费| 亚洲成人av福利| 久久久国产精华| 欧美日韩高清一区二区| 免费亚洲电影在线| 1000精品久久久久久久久| 3d动漫精品啪啪1区2区免费| 国产69精品一区二区亚洲孕妇| 亚洲黄色小视频| 欧美激情一区在线观看| 欧美一区午夜精品| 色狠狠桃花综合| 国产精品自拍一区| 日本女优在线视频一区二区| 国产精品久久综合| 欧美成人vps| 欧美日韩久久久久久| 成人精品在线视频观看| 九九精品一区二区| 亚洲国产cao| 亚洲人成7777| 国产欧美日韩中文久久| 精品国产乱码久久久久久1区2区 | 欧美日本视频在线| 91网站最新地址| 日韩欧美国产麻豆| 在线这里只有精品| 成人高清视频免费观看| 国产传媒欧美日韩成人| 热久久国产精品| 五月激情综合色| 亚洲线精品一区二区三区| 亚洲欧美色一区| 中文字幕永久在线不卡| 国产欧美日韩另类一区| 久久久久久久久久久久电影| 91精品国产综合久久国产大片| 在线观看三级视频欧美| 不卡视频免费播放| proumb性欧美在线观看| 国产成人精品一区二区三区网站观看| 青娱乐精品视频在线| 日韩电影在线一区二区| 日韩中文字幕av电影| 亚洲午夜久久久久久久久电影院| 亚洲乱码国产乱码精品精的特点 | 日韩欧美一二三| 欧美一区二区三区免费观看视频 | 99精品久久久久久| 99久久精品费精品国产一区二区| 国产91丝袜在线观看| 国产精品一二三区| 国产999精品久久久久久绿帽| 国产福利91精品| 成人深夜福利app| 97久久精品人人做人人爽| 色综合天天视频在线观看 | 欧美一区二区视频在线观看 | 欧洲日韩一区二区三区| 欧美在线一区二区三区| 欧美在线免费观看亚洲| 欧美精品乱人伦久久久久久| 在线电影欧美成精品| 欧美一区二区三区免费视频| 久久一区二区视频| 国产情人综合久久777777| 中文字幕一区二区在线播放| 亚洲欧洲制服丝袜| 人人爽香蕉精品| 国产乱对白刺激视频不卡| zzijzzij亚洲日本少妇熟睡| 欧美亚洲高清一区| 欧美一区二区国产| 日本一区二区不卡视频| 亚洲丝袜美腿综合| 亚洲福利视频一区| 国产在线精品免费| 91视频一区二区| 欧美日本一区二区在线观看| 欧美哺乳videos| 亚洲视频精选在线| 婷婷国产v国产偷v亚洲高清| 国产制服丝袜一区| 色狠狠色噜噜噜综合网| 欧美一卡2卡3卡4卡| 国产精品网曝门| 午夜影院在线观看欧美| 日韩电影在线免费| 福利91精品一区二区三区| 欧洲视频一区二区| 欧美精品一区二区三区视频| 中文一区一区三区高中清不卡| 一区二区不卡在线播放 | 亚洲18女电影在线观看| 国产一区二区不卡| 91官网在线免费观看| 久久影院午夜片一区| 亚洲一卡二卡三卡四卡无卡久久| 麻豆一区二区三| 色哦色哦哦色天天综合| 欧美白人最猛性xxxxx69交| 一区二区三区四区乱视频| 久久99日本精品| 国产精品另类一区| 国产美女在线观看一区| 欧美日韩aaa| 亚洲黄一区二区三区| 国产91精品欧美| 在线电影一区二区三区| 亚洲成人动漫精品| 91在线免费视频观看| 国产视频一区二区三区在线观看| 午夜av一区二区三区| 色婷婷亚洲综合| 中文字幕欧美国产| 日韩成人午夜精品| 在线精品观看国产| 亚洲欧美另类久久久精品| 日日摸夜夜添夜夜添精品视频| 一本久道久久综合中文字幕| 国产精品麻豆99久久久久久| 国产老肥熟一区二区三区| 欧美精品黑人性xxxx| 婷婷亚洲久悠悠色悠在线播放 | 风间由美一区二区三区在线观看| 日韩欧美一级片| 免费在线观看精品| 欧美高清视频在线高清观看mv色露露十八 | 蜜桃av一区二区三区电影| 91免费观看国产| 国产精品美女www爽爽爽| 国产成人免费视频一区| 精品日韩一区二区| 亚洲国产日韩av| 99久久久精品| 自拍偷拍亚洲激情| 成人av手机在线观看| 久久精品欧美一区二区三区不卡 | 蜜桃一区二区三区四区| 欧美精品日韩精品| 香蕉成人啪国产精品视频综合网| 91久久精品国产91性色tv| 中文字幕在线不卡视频| 日韩一卡二卡三卡| 五月婷婷色综合| 欧美日韩亚洲综合一区| 肉丝袜脚交视频一区二区| 欧美日韩视频专区在线播放| 一区二区三区四区蜜桃| 91国在线观看| 亚洲永久精品国产| 在线欧美一区二区| 亚洲18色成人| 欧美大片在线观看一区二区| 裸体一区二区三区| 日韩三级免费观看| 国产老女人精品毛片久久| 国产三级久久久| av在线一区二区三区| 亚洲影院理伦片| 337p亚洲精品色噜噜| 麻豆精品一区二区三区| 欧美va在线播放| 成人黄色小视频| 亚洲一区国产视频| 欧美岛国在线观看| 成人免费高清视频| 亚洲国产日日夜夜| 精品国产91九色蝌蚪| 夫妻av一区二区| 一级日本不卡的影视| 69精品人人人人| 国产一区二区不卡| 一区二区在线观看不卡| 欧美精品免费视频| 国产精品2024| 一区二区三区免费网站| 51精品视频一区二区三区| 精品一区二区三区视频| 国产精品福利在线播放| 欧美日韩mp4| 国产一区二区三区黄视频| 国产亚洲制服色| 97久久超碰精品国产| 午夜免费久久看| 久久久久久久综合日本| 91免费小视频| 日韩高清一级片| 国产精品无圣光一区二区| 欧美精品视频www在线观看| 国产精品 欧美精品| 亚洲午夜精品一区二区三区他趣|