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

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

?? evaluator.java

?? 外國人寫的c#語法解析器
?? JAVA
?? 第 1 頁 / 共 3 頁
字號(hào):
/**
 * 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.expressions;

import java.math.BigInteger;
import java.util.StringTokenizer;

import antlr.collections.AST;

/** 
 * Evaluates an expression contained in an AST.
 */
public class Evaluator
{
  private static ISymbolTable symbols;
  /** If <b>true</b> then unresolvable symbols are assumed to be integers with value 0. */
  private static boolean implicitSymbols;
  
  //------------------------------------------------------------------------------------------------
  
  private Evaluator()
  {
    // Using a private contructor to prevent instantiation.
    // Using class as a simple static utility class.
  }
  
  //------------------------------------------------------------------------------------------------
  
  /**
   * Determines if value is of type boolen and throws an exception if not.
   * 
   * @param value The value to check.
   */
  private static void checkBoolean(Object value)
  {
    checkEmpty(value);
    if (!isBoolean(value))
      showError("Boolean value expected, but " + value.toString() + " found.");
  }
  
  //------------------------------------------------------------------------------------------------
  
  /**
   * Checks if value is assigned.
   * 
   * @param value The value to check.
   */
  private static void checkEmpty(Object value)
  {
    if (value == null)
      showError("Internal error. Empty expression value encountered.");
  }

  //------------------------------------------------------------------------------------------------
  
  /**
   * Determines if value is an integer type and throws an exception if not.
   * 
   * @param value The class to check.
   */
  private static void checkInteger(Object value)
  {
    checkEmpty(value);
    if (!isInteger(value))
      showError("Integer value expected, but " + value.toString() + " found.");
  }
  
  //------------------------------------------------------------------------------------------------
  
  /**
   * Determines if value is a float or integer type and throws an exception if not.
   * 
   * @param value The class to check.
   */
  private static void checkNumber(Object value)
  {
    checkEmpty(value);
    if (!isNumber(value))
      showError("Number value expected, but " + value.toString() + " found.");
  }
  
  //------------------------------------------------------------------------------------------------
  
  /**
   * Determines if value is a character or string type and throws an exception if not.
   * 
   * @param value The class to check.
   */
  private static void checkString(Object value)
  {
    checkEmpty(value);
    if (!isString(value))
      showError("Character literal or string value expected, but " + value.toString() + " found.");
  }

  //------------------------------------------------------------------------------------------------
  
  /**
   * Checks the class of the given value whether it is derived from the class given in <b>classType</b>.
   * It throws an exception if it does not correspond.
   * 
   * @param value The value to check.
   * @param classType The type to check against.
   */
  private static void checkType(Object value, Class classType)
  {
    checkEmpty(value);
    if (!isBoolean(value))
      showError(classType.toString() + " expected but " + value.toString() + " found.");
  }
  
  //------------------------------------------------------------------------------------------------
  
  /**
   * Determines if value is a boolean type.
   * 
   * @param value The class to check.
   * @return <b>true</b> if the value is a boolean value, otherwise <b>false</b>.
   */
  private static boolean isBoolean(Object value)
  {
    return (value instanceof Boolean);
  }

  //------------------------------------------------------------------------------------------------
  
  /**
   * Determines if value is of type float, that is, Float or Double.
   * 
   * @param value The class to check.
   * @return <b>true</b> if the value is a float value, otherwise <b>false</b>.
   */
  private static boolean isFloat(Object value)
  {
    return (value instanceof Float || value instanceof Double);
  }
  
  //------------------------------------------------------------------------------------------------
  
  /**
   * Determines if value is an integer type, that is, Byte, Integer, Long or Short.
   * 
   * @param value The class to check.
   * @return <b>true</b> if the value is an integer value, otherwise <b>false</b>.
   */
  private static boolean isInteger(Object value)
  {
    return (value instanceof Byte || value instanceof Integer || value instanceof Long || 
      value instanceof Short);
  }

  //------------------------------------------------------------------------------------------------
  
  /**
   * Determines if value is an integer type, that is, Byte, Integer, Long or Short.
   * 
   * @param value The class to check.
   * @return <b>true</b> if the value is a number value, otherwise <b>false</b>.
   */
  private static boolean isNumber(Object value)
  {
    return (isFloat(value) || isInteger(value));
  }
  
  //------------------------------------------------------------------------------------------------
  
  /**
   * Determines if value is an integer type, that is, Byte, Integer, Long or Short.
   * 
   * @param value The class to check.
   * @return <b>true</b> if the value is a character or string value, otherwise <b>false</b>.
   */
  private static boolean isString(Object value)
  {
    return (value instanceof Character || value instanceof String);
  }
  
  //------------------------------------------------------------------------------------------------
  
  /**
   * Does a lookup on the symbol table to find the predefined value for the given identifier.
   * 
   * @param symbol The identifier to look up.
   * @param node The node for which a value must be looked up. Contains location info for error messages.
   * @return The value of the identifier.
   */
  private static Object lookupValue(String symbol, AST node)
  {
    if (symbols == null || !symbols.isDefined(symbol))
    {
      if (implicitSymbols)
        return new Integer(0);
      else
      {
        showError("Undeclared identifier \"" + symbol + "\"");
        return null;
      }
    }
    
    return symbols.lookup(symbol, node.getLine(), node.getColumn());
  }

  //------------------------------------------------------------------------------------------------
  
  /**
   * Handles all forms of a long integer. Due to various suffixes this requires a bit extra work.
   * Fortunately, hexadecimal and octal number parsing is done by the decode method implicitly.
   * 
   * @param node The node containing the value as string.
   * @return The parsed Integer.
   */
  private static Object parserIntegerType(AST node)
  {
    String raw = node.getText().toLowerCase();
    
    // Remove any suffix. We cannot distinct between pure negative and positive types anyway.
    if (raw.endsWith("i128") || raw.endsWith("u128"))
      return new BigInteger(raw.substring(0, raw.length() - 4));
    else
      if (raw.endsWith("i64") || raw.endsWith("u64"))
        return Long.decode(raw.substring(0, raw.length() - 3));
      else
        if (raw.endsWith("i32") || raw.endsWith("u32") || raw.endsWith("ul"))
          return Integer.decode(raw.substring(0, raw.length() - 3));
        else
          if (raw.endsWith("i16") || raw.endsWith("u16"))
            return Short.decode(raw.substring(0, raw.length() - 3));
          else
            if (raw.endsWith("i8") || raw.endsWith("u8"))
              return Byte.decode(raw.substring(0, raw.length() - 2));
            else
              if (raw.endsWith("l") || raw.endsWith("u"))
                return Long.decode(raw.substring(0, raw.length() - 1));
              else
                return Long.decode(raw);
  }

  //------------------------------------------------------------------------------------------------
  
  /**
   * Evaluates the given AST into a scalar value.
   * 
   * @param node The (sub) AST to evaluate.
   * @return An object, which encapsulates a scalar value.
   */
  private static Object process(AST node)
  {
    if (node == null)
      return null;
    else
    {
      AST left = node.getFirstChild();
      AST right = null;
      if (left != null)
        right = left.getNextSibling();
      Object leftValue = null;
      Object result = null;
      try
      {
        switch (node.getType())
        {
          // Node values.
          case ExpressionLexerTokenTypes.CHARACTER_LITERAL:
            result = new Character(node.getText().charAt(0));
            break;
          case ExpressionLexerTokenTypes.STRING_LITERAL:
            result = processStringLiteral(node.getText());
            break;
          case ExpressionLexerTokenTypes.IDENTIFIER:
            result = lookupValue(node.getText(), node);
            break;
          case ExpressionLexerTokenTypes.FLOAT_LITERAL:
            result = new Float(node.getText());
            break;
          case ExpressionLexerTokenTypes.DOUBLE_LITERAL:
            result = new Double(node.getText());
            break;
          case ExpressionLexerTokenTypes.HEX_LITERAL:
          case ExpressionLexerTokenTypes.OCTAL_LITERAL:
          case ExpressionLexerTokenTypes.BYTE_LITERAL:
          case ExpressionLexerTokenTypes.SHORT_LITERAL:
          case ExpressionLexerTokenTypes.INTEGER_LITERAL:
          case ExpressionLexerTokenTypes.LONG_LITERAL:
          case ExpressionLexerTokenTypes.BIGINT_LITERAL:
            result = parserIntegerType(node);
            break;
          case ExpressionLexerTokenTypes.NUMERAL:
            result = new Integer(node.getText());
            break;
          case ExpressionLexerTokenTypes.LITERAL_true:
            result = new Boolean(true);
            break;
          case ExpressionLexerTokenTypes.LITERAL_false:
            result = new Boolean(false);
            break;
          default:
          {
            leftValue = process(left);

            // Handle non-terminals.
            switch (node.getType())
            {
              // Unary operations.
              case ExpressionLexerTokenTypes.LOGICAL_NOT:
                result = processLogicalNot(leftValue);
                break;
              case ExpressionLexerTokenTypes.BITWISE_NOT:
                result = processBitwiseNot(leftValue);
                break;
              case ExpressionLexerTokenTypes.INC:
              case ExpressionLexerTokenTypes.POST_INC:
                result = processInc(leftValue);
                break;
              case ExpressionLexerTokenTypes.DEC:
              case ExpressionLexerTokenTypes.POST_DEC:
                result = processDec(leftValue);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美久久婷婷综合色| 在线免费观看不卡av| 北岛玲一区二区三区四区| 欧美视频三区在线播放| 欧美精品一区二区三区久久久| 中文字幕国产一区二区| 青青草视频一区| 91社区在线播放| 久久久三级国产网站| 午夜激情久久久| 一本到三区不卡视频| 中文字幕乱码日本亚洲一区二区| 老司机精品视频在线| 欧美久久久久久久久| 中文字幕一区二区日韩精品绯色| 激情综合一区二区三区| 欧美日韩成人综合在线一区二区| 国产精品―色哟哟| 成人精品免费看| 久久久av毛片精品| 国产一区二区三区四区五区入口 | 亚洲综合视频在线| 成人理论电影网| 欧美国产一区视频在线观看| 狠狠色丁香久久婷婷综合_中| 欧美一区二区黄色| 日本少妇一区二区| 日韩欧美国产wwwww| 奇米综合一区二区三区精品视频| 欧美日精品一区视频| 亚洲国产综合色| 欧美日韩一区二区三区视频| 一区二区三区四区在线播放 | 精品一区二区免费视频| 日韩欧美国产一区在线观看| 日韩国产精品久久久久久亚洲| 欧美日韩成人综合在线一区二区| 亚洲成a人片在线不卡一二三区| 欧美日韩一二三区| 偷拍与自拍一区| 91精品国产综合久久精品 | 欧美揉bbbbb揉bbbbb| 偷窥国产亚洲免费视频| 91精品在线麻豆| 久久精品国产久精国产爱| 精品欧美乱码久久久久久1区2区 | 午夜精品福利一区二区三区蜜桃| 欧美中文字幕一区二区三区| 性欧美大战久久久久久久久| 日韩一区二区视频在线观看| 国产综合色产在线精品| 国产日本欧美一区二区| 99精品欧美一区| 图片区日韩欧美亚洲| 久久综合精品国产一区二区三区 | 欧美aaaaaa午夜精品| 欧美xxxxx牲另类人与| 国产成人精品1024| 亚洲色欲色欲www在线观看| 欧美午夜理伦三级在线观看| 日本最新不卡在线| 欧美激情综合在线| 欧美色综合天天久久综合精品| 另类专区欧美蜜桃臀第一页| 中文无字幕一区二区三区| 欧美色图12p| 国产精品综合久久| 亚洲综合在线视频| 精品日韩欧美一区二区| 色94色欧美sute亚洲13| 久久精品国产一区二区三区免费看| 国产欧美日韩另类一区| 精品视频999| 懂色av噜噜一区二区三区av| 视频在线在亚洲| 中文av字幕一区| 日韩亚洲欧美高清| youjizz久久| 久久精品999| 亚洲成人免费电影| 国产精品第13页| 精品粉嫩超白一线天av| 色94色欧美sute亚洲13| 国产福利精品导航| 天天色 色综合| 亚洲三级理论片| 久久久久久久综合日本| 91精品国产综合久久精品app| 91一区二区三区在线观看| 国产一区二区三区在线看麻豆| 亚洲综合激情网| 中文字幕中文字幕一区二区| 日韩免费一区二区三区在线播放| 91同城在线观看| 国产一区二区三区四区五区入口 | 欧美白人最猛性xxxxx69交| 欧美性猛交xxxx乱大交退制版| 国产福利一区二区三区视频| 久久激情五月激情| 日韩av午夜在线观看| 亚洲一区二区三区影院| 综合久久一区二区三区| 欧美国产日韩一二三区| www一区二区| 精品福利在线导航| 久久九九久久九九| 国产欧美精品一区二区色综合朱莉| 欧美一级生活片| 欧美日本在线视频| 欧美日韩视频一区二区| 欧美日韩综合一区| 91国产精品成人| 欧美视频中文字幕| 欧美午夜精品久久久久久孕妇| 一本色道**综合亚洲精品蜜桃冫| 99久久综合国产精品| 99视频在线精品| 99精品欧美一区二区三区综合在线| 成人精品国产福利| 97久久久精品综合88久久| 99久久精品一区| 在线视频欧美精品| 欧美视频在线观看一区| 777奇米成人网| 日韩女优av电影| 久久精品一区四区| 国产精品三级在线观看| ...av二区三区久久精品| 伊人婷婷欧美激情| 婷婷国产在线综合| 久久丁香综合五月国产三级网站| 精彩视频一区二区| 成人午夜在线视频| 91片在线免费观看| 在线电影一区二区三区| 精品1区2区在线观看| 国产夜色精品一区二区av| 国产精品久久99| 亚洲成年人网站在线观看| 免费在线看一区| 成人av网站大全| 欧美三级视频在线| 精品国产乱码久久久久久图片 | 免费在线观看一区| 国产精品一区免费在线观看| 成年人国产精品| 欧美片网站yy| 欧美国产乱子伦 | 精品精品欲导航| 国产精品久久久久久久久搜平片 | 精品电影一区二区| 亚洲视频免费在线观看| 蜜臀av一区二区| voyeur盗摄精品| 日韩欧美一二三四区| 国产精品久久久久久久久动漫 | 午夜不卡在线视频| 国产精品亚洲专一区二区三区| 一本一道综合狠狠老| 日韩欧美国产精品| 一区二区三区美女视频| 国产美女精品一区二区三区| 91久久线看在观草草青青| 久久人人超碰精品| 日日摸夜夜添夜夜添精品视频| 国产精品原创巨作av| 日本韩国欧美三级| 国产亚洲欧美日韩日本| 亚洲成在人线免费| 97se亚洲国产综合自在线观| 日韩视频不卡中文| 一区二区三区中文字幕| 国产剧情一区在线| 91精品国产乱码| 樱花草国产18久久久久| jlzzjlzz亚洲日本少妇| 亚洲精品在线观| 丝袜亚洲精品中文字幕一区| 99久久久无码国产精品| 国产亚洲欧美色| 国产资源在线一区| 精品少妇一区二区三区日产乱码| 亚洲电影中文字幕在线观看| 97精品久久久久中文字幕| 久久精品视频在线看| 精油按摩中文字幕久久| 欧美一级免费大片| 午夜精品视频在线观看| 在线精品观看国产| 一区二区三区免费网站| 色综合久久88色综合天天6| 国产精品无码永久免费888| 国产成人午夜99999| 欧美变态tickle挠乳网站| 日本欧美韩国一区三区| 337p亚洲精品色噜噜狠狠| 爽好久久久欧美精品| 欧美夫妻性生活| 日本va欧美va欧美va精品| 欧美精品欧美精品系列|