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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? macrotable.java

?? 外國人寫的c#語法解析器
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
/**
 * Soft Gems Resource parser. Created by Mike Lischke.
 * 
 * The source code in this file can freely be used for any purpose provided this notice remains 
 * unchanged in the file.
 * 
 * Copyright 2004 by Mike Lischke, www.soft-gems.net, public@soft-gems.net. All rights reserved.
 */

package net.softgems.resourceparser.preprocessor;

import java.io.*;
import java.text.MessageFormat;
import java.util.*;

import net.softgems.resourceparser.main.IParseEventListener;

/**
 * This class provides support for macro substitution and symbol lookup. The implementation is
 * based on the C/C++ preprocessor language description in MSDN:
 *   Visual Studio -> Visual C++ -> Visual C++ Reference -> C/C++ Languages -> 
 *   C/C++ Preprocessor Reference -> The Preprocessor -> Macros.
 */
public class MacroTable
{
  /** A list of macros, which are currently being expanded (to avoid endless recursions). */
  protected ArrayList evaluationList = new ArrayList();
  /** List of event listeners who want to get notified about a preprocessor event. */
  private ArrayList listeners = new ArrayList();
  /** A list of Macro classes, sorted by the name of the macros. */
  private HashMap macros = new HashMap();
  
  //------------------------------------------------------------------------------------------------

  /**
   * This private class is the actual representation of a macro in the macro table.
   */
  private class Macro
  {
    protected int formalParameterCount;
    protected String[] formalParameters;
    protected String name;
    protected String substitution;
    
    //----------------------------------------------------------------------------------------------

    /**
     * Constructor of the Macro class.
     * 
     * @param theName The name (identification) of the macro.
     * @param theParameters The formal parameters of the macro or <b>null</b> if there aren't any.
     * @param theSubstitution The string to use instead of the macro identification, when calling
     *         {@see getSubstitution}.
     */
    public Macro(String theName, String[] theParameters, String theSubstition)
    {
      name = theName;
      formalParameters = theParameters;
      if (formalParameters == null)
        formalParameterCount = 0;
      else
        formalParameterCount = formalParameters.length;
      substitution = theSubstition;
    }

    //----------------------------------------------------------------------------------------------

    /**
     * Looks through the list of formal parameters to find the given symbol and returns the 
     * actual parameter from the <b>parameters</b> list if there is one.
     * 
     * @param parameters The list of actual parameters.
     * @return The actual parameter, which corresponds to the given symbol.
     */
    private String getActualParameter(ArrayList parameters, String symbol)
    {
      // Look whether this symbol is a parameter and get its index in the parameter list if so.
      int index = -1;
      for (int i = 0; i < formalParameters.length; i++)
        if (formalParameters[i].equals(symbol))
        {
          index = i;
          break;
        }
       
      // Replace the formal parameter by its actual equivalent if there is one.
      if (index > -1 && index < parameters.size())
        return (String) parameters.get(index);
      else
        return symbol;
    }
    
    //----------------------------------------------------------------------------------------------

    /**
     * This method handles stringizing or charizing of parameters.
     * 
     * @param parameters The list of actual parameters.
     * @param tokenizer The currently used tokenizer.
     */
    private String handleNumberSign(ArrayList parameters, MacroTokenizer tokenizer)
    {
      StringBuffer result = new StringBuffer();
      int lookAhead = tokenizer.nextToken();
      if (lookAhead == '@')
      {
        // Skip leading whitespaces.
        do
        {
          lookAhead = tokenizer.nextToken();
        }
        while (lookAhead == ' ' || lookAhead == '\t');

        // Charizing is requested.
        result.append('\'');
        // The next token must be a single character.
        if (lookAhead == StreamTokenizer.TT_WORD)
        {
          String actualParameter = getActualParameter(parameters, tokenizer.getStringValue());
          if (actualParameter.length() == 1)
            result.append(expandMacros(actualParameter));
          else
            reportError("Invalid charizing sequence in macro \"" + name + "\".");
        }
        else
          reportError("Invalid charizing sequence in macro \"" + name + "\".");
        result.append('\'');
      }
      else
      {
        // Skip leading whitespaces.
        while (lookAhead == ' ' || lookAhead == '\t')
        {
          lookAhead = tokenizer.nextToken();
        }
        if (lookAhead == StreamTokenizer.TT_WORD)
        {
          result.append("\"");
          // Expand any macro before making it a string literal.
          String actualParameter = getActualParameter(parameters, tokenizer.getStringValue());
          {
            StringBuffer expandedValue = new StringBuffer(expandMacros(actualParameter));
            // Mask any character, which would make the string literal invalid.
            for (int i = expandedValue.length() - 1; i >= 0; i--)
            {
              switch (expandedValue.charAt(i))
              {
                case '\\':
                case '"':
                {
                  expandedValue.insert(i, '\\');
                  break;
                }
              }
            }
            result.append(expandedValue.toString());
          }
          result.append("\"");
        }
        else
          reportError("Invalid macro operator in \"" + name + "\"");
      }
      
      return result.toString();
    }
    
    //----------------------------------------------------------------------------------------------

    /**
     * Replaces the formal parameters in the macro definition by the given actual parameters and
     * returns the result.
     */
    public String getSubstition(String[] actualParameters)
    {
      StringBuffer result;
      
      if (substitution == null)
        result = null;
      else
      {
        result = new StringBuffer();
        
        // Convert the actual parameters into a list of non-empty entries.
        // Note: MSVC allows for strange constructs here like
        //    macro(1,,,,,,,,,3)
        // where any empty entry is skipped. So the 3 would actually be used as second parameter.
        ArrayList parameters = new ArrayList();
        if (actualParameters != null)
        {
          for (int i = 0; i < actualParameters.length; i++)
            if ((actualParameters[i] != null) && (actualParameters[i].length() > 0))
              parameters.add(actualParameters[i].trim());
        }        
        
        if (parameters.size() > formalParameterCount)
          reportWarning("Macro \"" + name + "\": too many actual parameters in macro call.");
        if (parameters.size() < formalParameterCount)
          reportWarning("Macro \"" + name + "\": too few actual parameters in macro call.");
        
        boolean pastingPending = false;
        if (formalParameterCount == 0)
          // Shortcut if there is nothing to substitution.
          result.append(substitution);
        else
        {
          // Scan the list of formal parameters and replace any occurance in the substitution by the
          // matching actual parameter.
          MacroTokenizer tokenizer = new MacroTokenizer(substitution, true);
          
          // Copy everything from the substition to the output until the opening parenthesis is found.
          int token = 0;
          if (substitution.indexOf('(') > -1)
          {
            boolean stopPreLoop = false;
            do
            {
              token = tokenizer.nextToken();
              switch (token)
              {
                case StreamTokenizer.TT_EOF:
                case '(':
                {
                  if (token == '(')
                    result.append((char) token);
                  stopPreLoop = true;
                  break;
                }
                case StreamTokenizer.TT_WORD:
                {
                  result.append(tokenizer.getStringValue());
                  break;
                }
                case '"':
                {
                  result.append('"');
                  result.append(tokenizer.getStringValue());
                  result.append('"');
                  break;
                }
                case '\'':
                {
                  result.append('\'');
                  result.append(tokenizer.getStringValue());
                  result.append('\'');
                  break;
                }
                default:
                  result.append((char) token);
              }
            }
            while (!stopPreLoop);
          }
          
          do
          { 
            // Collect leading whitespace but do not write them to the result yet.
            boolean whiteSpacePending = false;
            do
            {
              token = tokenizer.nextToken();
              if (token == ' ' || token == '\t')
                whiteSpacePending = true;
              else
                break;
            }
            while (true);
            
            if (token == StreamTokenizer.TT_EOF)
              break;
  
            switch (token) 
            {
              case StreamTokenizer.TT_WORD:
              {
                if (whiteSpacePending && !pastingPending)
                  result.append(" ");
                String actualParameter = getActualParameter(parameters, tokenizer.getStringValue());
                result.append(expandMacros(actualParameter));
                pastingPending = false;
                break;
              }
              case '#': // Macro operator.
              {
                token = tokenizer.nextToken();
                switch (token)
                {
                  case '#':
                  {
                    // Token-pasting operator. Leave out any pending white space and keep a flag to
                    // indicate that he next token is written directly to the previous token.
                    // Check that this operator is not the first token in the substitution.
                    if (result.length() == 0)
                      reportError("\'##\' cannot occur at the beginning of a macro definition");
                    pastingPending = true;
                    break;
                  }
                  case '@':
                  {
                    // Charizing operator.
                    if (whiteSpacePending)
                      result.append(" ");
                    tokenizer.pushBack();
                    result.append(handleNumberSign(parameters, tokenizer));
                    break;
                  }
                  default:
                  {
                    // Stringizing operator.
                    if (whiteSpacePending)
                      result.append(" ");
                    tokenizer.pushBack();
                    result.append(handleNumberSign(parameters, tokenizer));
                  }
                }
                break;
              }
              case '"':
              {
                if (whiteSpacePending)
                  result.append(" ");
                result.append('"');
                result.append(tokenizer.getStringValue());
                result.append('"');
                break;
              }
              case '\'':
              {
                if (whiteSpacePending)
                  result.append(" ");
                result.append('\'');
                result.append(tokenizer.getStringValue());
                result.append('\'');
                break;
              }
              default:
              {
                if (whiteSpacePending)
                  result.append(" ");
                result.append((char)token);
              }
            }
          }
          while (true);
        }
        
        if (pastingPending)
          reportError("\'##\' cannot occur at the end of a macro definition");
      }
      

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲三级在线免费| 国产精品99久久久久久似苏梦涵| 免费日韩伦理电影| 粉嫩久久99精品久久久久久夜| 欧美午夜精品久久久久久超碰| www激情久久| 欧美一区二区三区视频免费| 欧美三电影在线| 欧美人与z0zoxxxx视频| 欧美国产亚洲另类动漫| 日本不卡高清视频| 91老师片黄在线观看| 久久精品一区蜜桃臀影院| 毛片基地黄久久久久久天堂| 久久99精品国产.久久久久| 欧美视频一区二区三区四区| 国产嫩草影院久久久久| 国产真实乱子伦精品视频| 制服丝袜日韩国产| 亚洲一区二区三区四区在线| 日日摸夜夜添夜夜添亚洲女人| 青青青爽久久午夜综合久久午夜| 色国产综合视频| 日韩无一区二区| 亚洲v日本v欧美v久久精品| 日本乱码高清不卡字幕| 中文字幕一区二区三区在线不卡 | 国产ts人妖一区二区| 91麻豆精品国产| 婷婷六月综合网| 国产精品资源在线观看| 日韩视频免费观看高清完整版| 午夜婷婷国产麻豆精品| 欧美日本精品一区二区三区| 亚洲在线观看免费视频| 国产美女视频91| 国产蜜臀97一区二区三区| 国产一区二区在线观看免费 | 久久久蜜桃精品| 极品销魂美女一区二区三区| 日韩欧美电影一区| 亚洲免费观看高清| 日本精品视频一区二区三区| 亚洲国产成人av网| 国产99久久久国产精品| 中文字幕在线观看不卡视频| 麻豆精品国产传媒mv男同| 精品国产91亚洲一区二区三区婷婷| 中文字幕一区二区日韩精品绯色| 免费高清在线视频一区·| 91视频精品在这里| 亚洲一卡二卡三卡四卡 | aa级大片欧美| 精品国产乱码久久久久久老虎| 亚洲国产精品久久久久秋霞影院| 成人午夜视频网站| 亚洲人精品一区| 国产乱码精品一区二区三区忘忧草| 欧美亚男人的天堂| 亚洲视频资源在线| 国产精品一区免费视频| 久久久久久久久伊人| 国产在线一区二区| 精品国产乱码久久久久久图片 | 久久综合久久综合久久| 北条麻妃国产九九精品视频| 久久亚洲春色中文字幕久久久| 男人的天堂久久精品| 国产欧美日韩综合| 成人视屏免费看| 国产区在线观看成人精品| 在线观看日韩毛片| 激情图区综合网| 一区二区国产视频| 国产日韩欧美高清在线| 国产精品一区二区久久不卡| 2020国产精品| 国产成人精品影视| 午夜激情一区二区| 欧美激情一区二区三区在线| 国产一区二区三区四区在线观看| 精品国产髙清在线看国产毛片| 波波电影院一区二区三区| 青青青伊人色综合久久| 久久亚洲综合av| 国产精品一区二区三区四区 | 久久精品国产99久久6| 欧美成人精品福利| 色婷婷一区二区三区四区| 国产一区 二区 三区一级| 欧美激情一区三区| 欧美哺乳videos| 成人性生交大片免费| 亚洲欧美日韩在线不卡| 久久精品一区蜜桃臀影院| 成人中文字幕合集| 久久草av在线| 亚洲欧洲99久久| 亚洲国产精品传媒在线观看| 精品视频一区 二区 三区| 99久久精品免费看国产免费软件| 亚洲色图欧美偷拍| 国产精品免费人成网站| 欧美午夜电影网| 91行情网站电视在线观看高清版| 成人免费福利片| 高清国产一区二区三区| 国产精品一区二区x88av| 亚洲另类一区二区| 亚洲欧洲综合另类| 亚洲人被黑人高潮完整版| 国产精品三级av| 国产精品国产精品国产专区不片 | 欧美一区二区女人| 欧美日韩国产乱码电影| 欧美伊人久久久久久久久影院 | 国产成人精品综合在线观看 | 日本美女一区二区三区视频| 亚洲va欧美va人人爽午夜| 亚洲午夜影视影院在线观看| 日韩亚洲欧美综合| 99精品视频在线免费观看| 成人国产在线观看| 日韩高清不卡在线| 蜜桃av噜噜一区二区三区小说| 美女视频一区二区| 欧美日韩国产精选| 日韩欧美三级在线| 日本乱人伦一区| 欧美男同性恋视频网站| 日韩视频免费观看高清完整版在线观看| 国产成人自拍网| 丰满岳乱妇一区二区三区| www.亚洲在线| 国产综合色在线视频区| 亚洲午夜久久久| 免费在线观看一区二区三区| 国产美女一区二区三区| 白白色 亚洲乱淫| 国产精品一区二区果冻传媒| 成人性生交大合| 国产美女主播视频一区| 懂色av噜噜一区二区三区av| 日本高清成人免费播放| 成人av在线资源| 欧美在线免费播放| 欧美电视剧免费观看| 欧美一区二区私人影院日本| 在线观看av一区| 色婷婷亚洲精品| 精品成人私密视频| 日韩理论电影院| 亚洲免费视频中文字幕| 美女视频黄 久久| 99精品视频一区| 成人短视频下载| 正在播放一区二区| 椎名由奈av一区二区三区| 日韩精品亚洲一区二区三区免费| 国产成人高清视频| 国产999精品久久| 成人av资源网站| 欧美成人一区二区三区片免费| 日韩欧美国产综合| 亚洲视频一区在线观看| 亚洲三级免费观看| 一二三区精品福利视频| 国产真实乱偷精品视频免| 国产传媒一区在线| 制服丝袜激情欧洲亚洲| 日韩精品一区二区三区中文不卡| 精品久久久久香蕉网| 国产亚洲欧美日韩日本| 亚洲欧洲另类国产综合| 老司机午夜精品| 欧美亚洲一区三区| 欧美一级黄色大片| 成人美女在线观看| 欧美一区二区三区视频在线观看 | 一区二区三区精品视频| 亚洲图片一区二区| 久久99热这里只有精品| 精彩视频一区二区| 欧美精品久久一区| 精品国产一区a| 日本亚洲一区二区| 欧美日本不卡视频| 午夜精品爽啪视频| 欧美偷拍一区二区| 一区二区激情视频| 精品一二三四区| 成人一级片在线观看| 欧美日韩视频在线观看一区二区三区| 国产欧美视频一区二区| 国产福利一区二区三区视频| 久久免费看少妇高潮| 亚洲在线观看免费| 狠狠色丁香久久婷婷综合_中| 日韩一区二区电影| 奇米精品一区二区三区在线观看一 |