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

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

?? preprocessor.java

?? 外國人寫的c#語法解析器
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
// Created on 02.05.2004

package net.softgems.resourceparser.preprocessor;

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

import net.softgems.resourceparser.expressions.*;
import net.softgems.resourceparser.main.IParseEventListener;
import antlr.*;
import antlr.collections.AST;

/**
 * The preprocess class is responsible for handling every preprocessor directive in the input. It
 * reads input from the InputConverter stored in the input state and feeds the lexer with its output.
 * 
 *  @author Mike Lischke
 */
public class Preprocessor extends Reader implements IParseEventListener
{
  private static final int DEFINE = 0;
  private static final Integer DEFINE_DIRECTIVE   = new Integer(DEFINE);

  /** Some static data for quick lookups. Also the state stack needs objects. */
  private static final HashMap directives = new HashMap(10);
  private static final int ELIF   = 1;
  private static final Integer ELIF_DIRECTIVE     = new Integer(ELIF);
  private static final int ELSE   = 2;
  private static final Integer ELSE_DIRECTIVE     = new Integer(ELSE);
  private static final int ENDIF  = 3;
  private static final Integer ENDIF_DIRECTIVE    = new Integer(ENDIF);
  private static final int ERROR  = 4;
  private static final Integer ERROR_DIRECTIVE    = new Integer(ERROR);
  private static final int IF     = 5;
  private static final Integer IF_DIRECTIVE       = new Integer(IF);
  private static final int IFDEF  = 6;
  private static final Integer IFDEF_DIRECTIVE    = new Integer(IFDEF);
  private static final int IFNDEF = 7;
  private static final Integer IFNDEF_DIRECTIVE   = new Integer(IFNDEF);
  private static final int INCLUDE = 8;
  private static final Integer INCLUDE_DIRECTIVE  = new Integer(INCLUDE);
  private static final int PRAGMA = 9;
  private static final Integer PRAGMA_DIRECTIVE   = new Integer(PRAGMA);
  private static final int UNDEF  = 10;
  private static final Integer UNDEF_DIRECTIVE    = new Integer(UNDEF);
  
  /** Skip modes used in the state machine. */
  private static final int SKIP_CONDITIONAL = 0;
  private static final int SKIP_NONE        = 1;
  private static final int SKIP_PARENT      = 2;
  private static final int SKIP_SUBTREE     = 3;
  
  /** Regular expression containing allowed white spaces to split parts on a line. */
  private static final String WHITESPACES = " |\t";
  
  /**
   * This charset is assumed to be the initial encoding for the input files. Though this might not
   * always be the case and character sets can change within the file.
   */
  public static final String DEFAULT_CHARSET = "ISO-8859-1";
  
  //------------------------------------------------------------------------------------------------

  static
  {
    directives.put("define", DEFINE_DIRECTIVE);
    directives.put("undef", UNDEF_DIRECTIVE);
    directives.put("if", IF_DIRECTIVE);
    directives.put("ifdef", IFDEF_DIRECTIVE);
    directives.put("ifndef", IFNDEF_DIRECTIVE);
    directives.put("else", ELSE_DIRECTIVE);
    directives.put("elif", ELIF_DIRECTIVE);
    directives.put("endif", ENDIF_DIRECTIVE);
    directives.put("include", INCLUDE_DIRECTIVE);
    directives.put("error", ERROR_DIRECTIVE);
    directives.put("pragma", PRAGMA_DIRECTIVE);
  }
  /** The current input line that is used to feed the lexer. */
  private StringBuffer currentLine = new StringBuffer();
  
  /** The current read position in the input buffer. */
  private int currentPosition;
  
  private boolean hadErrors;
  private boolean hadWarnings;
  private ArrayList includePaths;
  
  /** Flag, which indicates pending comment lines. */
  private boolean inMultilineComment;
  
  /** The class that feeds the preprocessor. */
  private InputConverter input;

  /**
   * The input state itself has a reference to this preprocess but the processor also needs
   * a back reference in order to restore the previous input state once its input is exhausted.
   */
  private PreprocessorInputState inputState;
  
  /** List of event listeners who want to get notified about a preprocessor event. */
  private ArrayList listeners = new ArrayList();
  
  /** Contains a a mapping of identifiers to macro definitions. */
  private MacroTable macroTable;
  
  /** A stack of pending states, which must be correctly finished for a valid file. */
  private Stack pendingStates = new Stack();
  
  /** A list of already processed include files, which are marked with the #pragma once directive. */
  private HashMap processedIncludes;
  
  /** Indicates if the preprocessor is currently skipping lines. */
  private int skip;
  
  /** A stack of skip flags for the state machine. */
  private Stack skipFlags = new Stack();
  
  /** This field is <b>true</b> when the current input file is either a *.c or a *.h file. */
  private boolean skipNonPPLines;
  
  /** Only for debugging. If <b>true</b> then input and output are printed to console. */
  private boolean traceProcessing;
  
  //------------------------------------------------------------------------------------------------

  public Preprocessor(InputConverter input, Preprocessor parentProcessor, PreprocessorInputState inputState,
    boolean traceProcessing)
  {
    this.inputState = inputState;
    this.traceProcessing = traceProcessing;
    this.input = input;

    // Initial skip states.
    skip = SKIP_NONE;
    skipFlags.push(new Integer(skip));
    
    // If the parent processor is set then this is an instance called for an include file.
    // Share certain structures with the parent processor instead creating own ones.
    if (parentProcessor != null)
    {
      macroTable = parentProcessor.macroTable;
      includePaths = parentProcessor.includePaths;
      processedIncludes = parentProcessor.processedIncludes;
    }
    else
    {
      macroTable = new MacroTable();
      macroTable.addMacroEventListener(
        new IParseEventListener() 
        {
          public void handleEvent(int event, String message)
          {
            doEvent(event, message, true);
          };
        }
      );
      includePaths = new ArrayList();
      processedIncludes = new HashMap();
    }
  }
  
  //------------------------------------------------------------------------------------------------

  /**
   * Evaluates the given expression by setting up a local parser and evaluator.
   * 
   * @param expression The expression to evaluate.
   * @return <b>true</b> if the expression turns out to be true, otherwise <b>false</b>.
   */
  private boolean evaluateBooleanExpression(String expression)
  {
    // This variable holds the abstract syntax tree for the parsed expression.
    AST expressionTree = null;
    try
    {
      expressionTree = ExpressionParser.parse(expression, inputState.getFilename(), inputState.getLine(), 
        inputState.getColumn(), this);
    }
    catch (RecognitionException e)
    {
      reportError(e.getMessage()); 
    }
    catch (TokenStreamException e)
    {
      reportError(e.getMessage());
    }
    
    boolean result = false;
    try
    {
      result = Evaluator.evaluateToBoolean(expressionTree, null, true);
    }
    catch (EvaluationException e)
    {
      reportError(e.getMessage());
    }
    
    return result;
  }
  
  //------------------------------------------------------------------------------------------------

  /**
   * Converts the first identifer on the given line (which must start with a number sign) to an 
   * internal ID for quicker processing.
   * 
   * @param line The current input line, including the number sign.
   * @return An integer value for the found directive or -1 if unknown.
   */
  private int getDirective(String line)
  {
    String[] parts = splitDirective(line);
    Integer value = (Integer)directives.get(parts[0]);
    if (value == null)
      return -1;
    else
      return value.intValue();
  }

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

  /**
   * Called when a #define directive is found. Get the identifier and the associated expression
   * and put it into our symbol list.
   * 
   * @param definition Input containing the identifier and the associated expression (if any).
   */
  private void processDefine(String definition)
  {
    macroTable.defineMacro(definition);
  }

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

  /**
   * Checks for any known preprocessor directive and triggers individual processing.
   * 
   * @param input The directive with the number sign.
   * @return <b>true</b> if the calling method should stop its reader loop.
   */
  private boolean processDirective(String input) throws FileNotFoundException, 
    IOException
  {
    boolean result = false;
    int directive = getDirective(input);
    
    // Remove the leading number sign and split the rest into two parts of which the first
    // one is the directive and the second one the expression to parse.
    String[] parts = splitDirective(input);
    String directiveText = parts[1].trim();
    switch (directive)
    {
      case INCLUDE:
      {
        if (skip == SKIP_NONE)
          result = processInclude(macroTable.expandMacros(directiveText));
        break;
      }
      case DEFINE:
      {
        if (skip == SKIP_NONE)
          processDefine(parts[1]);
        break;
      }
      case UNDEF:
      {
        if (skip == SKIP_NONE)
          processUndef(parts[1]);
        break;
      }
      case PRAGMA:
      {
        if (skip == SKIP_NONE)
          processPragma(parts);
        break; 
      }
      case ERROR:
      {
        if (skip == SKIP_NONE)
          reportError(parts[1]);
        break;
      }
      case IFDEF:
      {
        pendingStates.push(IF_DIRECTIVE);
        skipFlags.push(new Integer(skip));
        switch (skip)
        {
          case SKIP_NONE:
          {
            boolean condition = macroTable.isDefined(directiveText);
            if (!condition)
              skip = SKIP_CONDITIONAL;
            break;
          }
          case SKIP_CONDITIONAL:
          {
            // If there was already a previous condition that failed then we are 
            // entering a sub condition right now. Change the skip mode to parent skip to reflect that.
            skip = SKIP_PARENT;
            break;
          }
        }
        break;
      }
      case IFNDEF:
      {
        pendingStates.push(IF_DIRECTIVE);
        skipFlags.push(new Integer(skip));
        switch (skip)
        {
          case SKIP_NONE:
          {
            boolean condition = !macroTable.isDefined(directiveText);
            if (!condition)
              skip = SKIP_CONDITIONAL;
            break;
          }
          case SKIP_CONDITIONAL:
          {
            // If there was already a previous condition that failed then we are 
            // entering a sub condition right now. Change the skip mode to parent skip to reflect that.
            skip = SKIP_PARENT;
            break;
          }
        }
        break;
      }
      case IF:
      {
        pendingStates.push(IF_DIRECTIVE);
        skipFlags.push(new Integer(skip));
        switch (skip)
        {
          case SKIP_NONE:
          {
            boolean condition = evaluateBooleanExpression(macroTable.expandMacros(directiveText));
            if (!condition)
              skip = SKIP_CONDITIONAL;
            break;
          }
          case SKIP_CONDITIONAL:
          {
            // If there was already a previous condition that failed then we are 
            // entering a sub condition right now. Change the skip mode to parent skip to reflect that.
            skip = SKIP_PARENT;
            break;
          }
        }
       break;
      }
      case ELSE:
      {
        Integer pendingState = (Integer) pendingStates.pop();
        // See what the state was, which opened this conditional branch.
        switch (pendingState.intValue())
        {
          case IF:
          case IFDEF:
          case IFNDEF:
          case ELIF:
          {
            pendingStates.push(ELSE_DIRECTIVE);
            // If the superordinated conditional branch was already skipping then continue that,
            // otherwise reveverse the skip mode for this branch.
            switch (skip)
            {
              case SKIP_NONE:
              {
                skip = SKIP_CONDITIONAL;
                break;
              }
              case SKIP_CONDITIONAL:

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
美日韩一区二区| 国内一区二区在线| 五月婷婷激情综合| 午夜国产精品一区| 国产精品影视天天线| 国产成人综合在线| 欧美亚一区二区| 久久久久久日产精品| 综合久久综合久久| 午夜精品久久久久久久久久久| 青青草国产精品亚洲专区无| 成人av电影观看| 日韩欧美精品在线视频| 亚洲色欲色欲www| 毛片基地黄久久久久久天堂| 91捆绑美女网站| 欧美激情艳妇裸体舞| 午夜激情久久久| 99久久精品国产一区| 日韩欧美成人一区二区| 亚洲专区一二三| 成人动漫一区二区| 中文字幕欧美国产| 国产精品一区二区在线看| 欧美一区二区视频在线观看2022| 亚洲三级在线免费| 色综合天天综合色综合av| 久久久精品tv| 欧洲一区二区三区免费视频| 精品入口麻豆88视频| 天天综合网天天综合色| 欧美丰满美乳xxx高潮www| 亚洲一区在线观看免费观看电影高清 | 精品日韩av一区二区| 蜜桃视频在线观看一区| 日韩精品一区二区三区在线播放| 亚洲高清三级视频| 欧美中文字幕一二三区视频| 日韩毛片高清在线播放| 成人av在线影院| 中文字幕中文字幕在线一区 | 日韩一区和二区| 激情文学综合插| 日本一区二区三区dvd视频在线| 国产精品77777| 精品一区二区影视| 欧美精品一区视频| 成人av在线电影| 午夜视频一区在线观看| 2017欧美狠狠色| 色偷偷成人一区二区三区91| 人人超碰91尤物精品国产| 精品国产乱码久久久久久影片| 成人综合在线网站| 视频在线在亚洲| 亚洲欧洲精品一区二区三区 | 色呦呦日韩精品| 麻豆成人久久精品二区三区小说| 久久久噜噜噜久久人人看| 欧美老女人在线| 91在线精品一区二区三区| 美日韩一区二区| 首页国产丝袜综合| 一区二区三区加勒比av| 欧美激情在线观看视频免费| 欧美色视频一区| fc2成人免费人成在线观看播放| 五月综合激情日本mⅴ| 亚洲免费av在线| 国产精品国产三级国产aⅴ原创| 欧美精品一区二区三区很污很色的| 国产精品亲子伦对白| 91精品国产色综合久久ai换脸| 91福利区一区二区三区| www.欧美精品一二区| 麻豆精品一二三| 奇米影视一区二区三区小说| 亚洲成人精品影院| 五月婷婷激情综合| 午夜成人免费视频| 蜜桃视频在线观看一区| 久久69国产一区二区蜜臀| 蜜桃一区二区三区在线观看| 蜜桃视频一区二区| 国产一区二区三区四区在线观看| 激情六月婷婷久久| 国产一区999| 91在线免费播放| 欧美日韩一区二区在线观看 | 日本亚洲最大的色成网站www| 亚洲另类在线制服丝袜| 性欧美疯狂xxxxbbbb| 久久国产免费看| 日韩你懂的在线播放| 欧美高清在线精品一区| 又紧又大又爽精品一区二区| 天天射综合影视| 成人免费高清在线观看| 欧美美女黄视频| 亚洲国产高清aⅴ视频| 国产精品原创巨作av| 欧美日韩一区二区三区免费看| 久久亚洲影视婷婷| 亚洲不卡av一区二区三区| 国产一区二区福利| 日韩美女视频一区二区在线观看| 国产精品素人视频| 日韩福利电影在线观看| 色综合久久久久综合99| 国产精品亲子伦对白| 精品综合久久久久久8888| 欧美三级三级三级爽爽爽| 国产精品久久久久影院老司 | 一区二区三区.www| 国产电影精品久久禁18| 91精品在线免费观看| 亚洲国产精品自拍| 一本大道久久a久久精二百| 亚洲另类在线一区| 91成人免费电影| 一区二区三区色| 欧美亚洲免费在线一区| 亚洲男人的天堂一区二区| 色婷婷久久久久swag精品| 一区二区三区四区精品在线视频 | 中文字幕一区二区三| 处破女av一区二区| 亚洲视频 欧洲视频| 91极品视觉盛宴| 午夜精品福利一区二区三区av| 欧美性欧美巨大黑白大战| 亚洲成人综合在线| 欧美videofree性高清杂交| 国产又粗又猛又爽又黄91精品| 国产欧美视频一区二区三区| 成人毛片老司机大片| 一级女性全黄久久生活片免费| 欧美视频三区在线播放| 国产mv日韩mv欧美| 国产精品久久久久久久久果冻传媒| 岛国av在线一区| 亚洲午夜精品17c| 久久久久久久久99精品| 91在线你懂得| 麻豆成人久久精品二区三区红| 久久精品视频在线看| 在线亚洲免费视频| 国产尤物一区二区在线| 亚洲宅男天堂在线观看无病毒| 久久九九影视网| 69堂国产成人免费视频| 日本高清视频一区二区| 国产福利精品一区二区| 一区二区视频免费在线观看| 欧美变态tickle挠乳网站| 欧美日韩国产影片| 99久久国产综合色|国产精品| 九九精品一区二区| 亚洲.国产.中文慕字在线| 国产精品的网站| 久久精品视频免费观看| 精品国产一区二区亚洲人成毛片 | 日产欧产美韩系列久久99| 亚洲人成影院在线观看| 中文字幕中文字幕中文字幕亚洲无线| 欧美tk丨vk视频| 日韩精品资源二区在线| 91精品国产品国语在线不卡| 欧美天堂一区二区三区| 欧美在线综合视频| 欧美在线综合视频| 91精品免费在线观看| 精品成人a区在线观看| 久久久午夜电影| 国产精品你懂的| 亚洲精品va在线观看| 五月天网站亚洲| 免费欧美在线视频| 成人综合激情网| 在线观看亚洲a| 日韩视频在线一区二区| 久久亚洲二区三区| 亚洲婷婷在线视频| 天堂影院一区二区| 国产自产视频一区二区三区| 精品三级在线看| **性色生活片久久毛片| 亚洲3atv精品一区二区三区| 精品一区二区在线视频| 91在线视频观看| 欧美成人乱码一区二区三区| 成人免费在线视频观看| 日韩成人精品在线观看| av亚洲精华国产精华精华| 欧美猛男超大videosgay| 国产精品久久久久久久久免费相片| 亚洲成a人片综合在线| 91亚洲国产成人精品一区二区三| 在线不卡欧美精品一区二区三区| 国产午夜亚洲精品午夜鲁丝片 |