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

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

?? 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一区二区三区免费野_久草精品视频
国产女同互慰高潮91漫画| 在线免费精品视频| 久久视频一区二区| 国产一区久久久| 久久人人爽人人爽| 国产不卡视频一区| 亚洲色图欧洲色图婷婷| 欧美色图片你懂的| 蜜臀久久99精品久久久久久9 | 99久久伊人网影院| 国产精品久久久一区麻豆最新章节| 99久久精品免费看| 午夜视频在线观看一区二区三区| 日韩午夜激情av| 风间由美一区二区三区在线观看| 亚洲精品中文在线影院| 欧美精三区欧美精三区| 国产精品中文欧美| 亚洲欧美乱综合| 日韩欧美色综合| 99久久精品免费观看| 日本三级韩国三级欧美三级| 国产亚洲欧洲997久久综合| 欧洲视频一区二区| 国产乱码精品一品二品| 亚洲欧美日韩国产另类专区| 欧美一区二区视频观看视频| 国产成人丝袜美腿| 亚洲成a人片在线观看中文| www一区二区| 欧洲色大大久久| 国产99久久久国产精品免费看| 一区二区不卡在线播放 | 日韩精品一区二区三区视频| 北岛玲一区二区三区四区| 日韩激情在线观看| 国产精品美女久久久久久久久| 欧美三级韩国三级日本一级| 国产精品18久久久久久久久久久久| 一区二区三区四区激情| 久久精品欧美日韩精品| 欧美理论片在线| 91国偷自产一区二区三区成为亚洲经典| 老司机午夜精品| 亚洲国产乱码最新视频| 国产精品午夜春色av| 日韩女同互慰一区二区| 欧美日韩一区二区三区在线| 成人一区在线观看| 狠狠色丁香久久婷婷综合丁香| 亚洲国产欧美日韩另类综合| 日韩毛片精品高清免费| 国产丝袜美腿一区二区三区| 日韩视频免费观看高清完整版| 欧洲中文字幕精品| 99久久久久久99| 成人午夜精品一区二区三区| 国产在线一区二区综合免费视频| 午夜久久久久久电影| 亚洲中国最大av网站| 亚洲欧美日韩系列| 自拍偷拍亚洲欧美日韩| 国产精品青草综合久久久久99| 2023国产精品视频| 欧美大片一区二区| 日韩午夜电影在线观看| 7878成人国产在线观看| 欧美性感一类影片在线播放| 色婷婷av一区二区三区大白胸| 福利视频网站一区二区三区| 国产精品18久久久久久久久| 国产一区二区三区精品欧美日韩一区二区三区| 人人狠狠综合久久亚洲| 免费国产亚洲视频| 精东粉嫩av免费一区二区三区| 免费一级欧美片在线观看| 日韩电影在线免费看| 日韩经典中文字幕一区| 免费在线观看一区二区三区| 久久精品999| 精品一区二区影视| 丁香婷婷综合色啪| 99国产欧美另类久久久精品 | 91成人在线观看喷潮| 欧美在线观看视频一区二区| 欧美精品高清视频| 日韩三级在线观看| 久久一夜天堂av一区二区三区| 欧美精品一区在线观看| 国产午夜亚洲精品理论片色戒| 国产欧美一区二区三区沐欲| 国产精品久99| 亚洲一区中文日韩| 日韩国产欧美一区二区三区| 美女脱光内衣内裤视频久久网站| 国产一区二区h| 99久久综合99久久综合网站| 欧美中文字幕一区| 日韩视频一区二区在线观看| 中文字幕 久热精品 视频在线| 国产精品国产三级国产有无不卡 | 国产成人精品免费网站| av电影一区二区| 精品视频色一区| 日韩欧美国产综合在线一区二区三区| 精品国产乱码久久久久久浪潮| 中日韩av电影| 天天操天天干天天综合网| 精品午夜一区二区三区在线观看 | 亚洲制服丝袜在线| 精品中文av资源站在线观看| 97精品久久久久中文字幕 | 国产精品一二三区在线| 色婷婷精品久久二区二区蜜臀av | 欧美视频自拍偷拍| 久久久久久亚洲综合影院红桃| 中文字幕一区二区不卡 | 精品区一区二区| 中文字幕中文字幕一区| 日韩电影免费一区| 成人午夜激情在线| 欧美精品丝袜久久久中文字幕| 国产日韩精品一区二区浪潮av| 亚洲一区二区av电影| 国产成人亚洲综合a∨猫咪| 欧美色图在线观看| 国产精品久久看| 精品在线免费视频| 欧美日韩精品福利| 亚洲天堂久久久久久久| 国内成+人亚洲+欧美+综合在线| 色婷婷国产精品| 国产精品另类一区| 经典三级视频一区| 欧美一区二区三区在线观看| 亚洲欧洲综合另类在线| 国产成人精品免费| 精品美女在线观看| 日韩 欧美一区二区三区| 99精品国产91久久久久久| 久久九九国产精品| 麻豆高清免费国产一区| 欧美三级在线播放| 亚洲理论在线观看| 成人美女视频在线看| 亚洲精品一区二区精华| 美腿丝袜亚洲色图| 欧美精品第1页| 午夜免费久久看| 欧美日韩国产经典色站一区二区三区| 国产精品成人免费在线| 懂色av中文字幕一区二区三区 | 中文字幕一区二区三区视频 | 成人国产精品免费观看动漫| 精品噜噜噜噜久久久久久久久试看| 亚洲精品成人在线| 91亚洲精华国产精华精华液| 欧美激情资源网| 成人一道本在线| 亚洲欧美一区二区视频| 成人禁用看黄a在线| 中文字幕 久热精品 视频在线| 国产成人综合在线| 久久久精品欧美丰满| 国产福利电影一区二区三区| 久久久亚洲欧洲日产国码αv| 狠狠色丁香久久婷婷综| 久久免费国产精品 | jvid福利写真一区二区三区| 久久九九久久九九| 国产91丝袜在线播放| 国产午夜精品一区二区| 成人激情视频网站| 国产精品久久久久影院亚瑟| www.亚洲色图| 一区二区在线观看不卡| 欧美在线观看视频一区二区 | 国产午夜精品久久久久久免费视| 国产精品资源在线观看| 中文在线资源观看网站视频免费不卡 | 美女精品一区二区| 日韩视频免费观看高清在线视频| 精品一区二区三区在线观看国产 | 精品在线免费视频| 欧美激情综合在线| 色八戒一区二区三区| 香蕉久久一区二区不卡无毒影院 | av电影在线观看完整版一区二区| 中文字幕一区在线观看视频| 在线免费精品视频| 蜜臀va亚洲va欧美va天堂| 国产日韩欧美一区二区三区综合| 成人的网站免费观看| 天涯成人国产亚洲精品一区av| 欧美成人女星排行榜| 不卡的av在线| 日韩在线观看一区二区| 国产日韩综合av| 欧美日韩中文字幕一区| 国产精品一品二品|