⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rclexer.java

📁 外国人写的c#语法解析器
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
// $ANTLR 2.7.4: "Resource file lexer.g" -> "RCLexer.java"$

/**
 * 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.main;

import java.util.ArrayList;

import net.softgems.resourceparser.main.*;

import java.io.InputStream;
import antlr.TokenStreamException;
import antlr.TokenStreamIOException;
import antlr.TokenStreamRecognitionException;
import antlr.CharStreamException;
import antlr.CharStreamIOException;
import antlr.ANTLRException;
import java.io.Reader;
import java.util.Hashtable;
import antlr.CharScanner;
import antlr.InputBuffer;
import antlr.ByteBuffer;
import antlr.CharBuffer;
import antlr.Token;
import antlr.CommonToken;
import antlr.RecognitionException;
import antlr.NoViableAltForCharException;
import antlr.MismatchedCharException;
import antlr.TokenStream;
import antlr.ANTLRHashString;
import antlr.LexerSharedInputState;
import antlr.collections.impl.BitSet;
import antlr.SemanticException;

public class RCLexer extends antlr.CharScanner implements RCLexerTokenTypes, TokenStream
 {

  /** List of event listeners who want to get notified about an lexer event. */
  private ArrayList listeners = new ArrayList();
  boolean hadErrors;
  boolean hadWarnings;
  
  //------------------------------------------------------------------------------------------------
  
  public void addLexerEventListener(IParseEventListener listener)
  {
    listeners.add(listener);
  }
  
  //------------------------------------------------------------------------------------------------
  
  public void removeLexerEventListener(IParseEventListener listener)
  {
    listeners.remove(listener);
  }
  
  //------------------------------------------------------------------------------------------------
  
  public void newline()
  {
    super.newline();
    doEvent(IParseEventListener.NEW_LINE, null);
  }
  
  //------------------------------------------------------------------------------------------------

  public void panic()
  {
  	hadErrors = true;
    doEvent(IParseEventListener.PANIC, "RC lexer panic");
  }

  //------------------------------------------------------------------------------------------------
  
  /** 
   * This method is executed by ANTLR internally when it detected an illegal
   *  state that cannot be recovered from.
   */
  public void panic(String s)
  {
  	hadErrors = true;
    doEvent(IParseEventListener.PANIC, "RC lexer panic: " + s);
  }
  
  //------------------------------------------------------------------------------------------------
  
  public void reportError(RecognitionException ex)
  {
  	hadErrors = true;
    doEvent(IParseEventListener.ERROR, ex.toString());
  }

  //------------------------------------------------------------------------------------------------
  
  public void reportError(String s)
  {
  	hadErrors = true;
    if (getFilename() == null)
    {
      doEvent(IParseEventListener.ERROR, s);
    }
    else
    {
      doEvent(IParseEventListener.ERROR, getFilename() + ": " + s);
    }
  }

  //------------------------------------------------------------------------------------------------
  
  public void reportWarning(String s)
  {
  	hadWarnings = true;
    if (getFilename() == null)
    {
      doEvent(IParseEventListener.WARNING, s);
    }
    else
    {
      doEvent(IParseEventListener.WARNING, getFilename() + ": " + s);
    }
  }

  //------------------------------------------------------------------------------------------------
  
  private void doEvent(int event, String message)
  {
    for (int i = 0; i < listeners.size(); i++)
    {
      IParseEventListener listener = (IParseEventListener) listeners.get(i);
      listener.handleEvent(event, message);
    }
  }
  
  //------------------------------------------------------------------------------------------------
  
  public boolean hadErrors()
  {
    return hadErrors;
  }
  
  //------------------------------------------------------------------------------------------------
  
  public boolean hadWarnings()
  {
    return hadWarnings;
  }
  
  //------------------------------------------------------------------------------------------------
  
public RCLexer(InputStream in) {
	this(new ByteBuffer(in));
}
public RCLexer(Reader in) {
	this(new CharBuffer(in));
}
public RCLexer(InputBuffer ib) {
	this(new LexerSharedInputState(ib));
}
public RCLexer(LexerSharedInputState state) {
	super(state);
	caseSensitiveLiterals = false;
	setCaseSensitive(false);
	literals = new Hashtable();
	literals.put(new ANTLRHashString("characteristics", this), new Integer(114));
	literals.put(new ANTLRHashString("scrollbar", this), new Integer(153));
	literals.put(new ANTLRHashString("fileversion", this), new Integer(169));
	literals.put(new ANTLRHashString("messagetable", this), new Integer(165));
	literals.put(new ANTLRHashString("filesubtype", this), new Integer(175));
	literals.put(new ANTLRHashString("cursor", this), new Integer(130));
	literals.put(new ANTLRHashString("caption", this), new Integer(116));
	literals.put(new ANTLRHashString("button", this), new Integer(184));
	literals.put(new ANTLRHashString("menuitem", this), new Integer(155));
	literals.put(new ANTLRHashString("autocheckbox", this), new Integer(136));
	literals.put(new ANTLRHashString("end", this), new Integer(99));
	literals.put(new ANTLRHashString("icon", this), new Integer(152));
	literals.put(new ANTLRHashString("dialog", this), new Integer(131));
	literals.put(new ANTLRHashString("language", this), new Integer(111));
	literals.put(new ANTLRHashString("style", this), new Integer(118));
	literals.put(new ANTLRHashString("checked", this), new Integer(157));
	literals.put(new ANTLRHashString("groupbox", this), new Integer(144));
	literals.put(new ANTLRHashString("shared", this), new Integer(108));
	literals.put(new ANTLRHashString("toolbar", this), new Integer(183));
	literals.put(new ANTLRHashString("fileflags", this), new Integer(172));
	literals.put(new ANTLRHashString("ascii", this), new Integer(123));
	literals.put(new ANTLRHashString("help", this), new Integer(159));
	literals.put(new ANTLRHashString("textinclude", this), new Integer(181));
	literals.put(new ANTLRHashString("rtext", this), new Integer(133));
	literals.put(new ANTLRHashString("auto3state", this), new Integer(135));
	literals.put(new ANTLRHashString("pure", this), new Integer(106));
	literals.put(new ANTLRHashString("not", this), new Integer(78));
	literals.put(new ANTLRHashString("moveable", this), new Integer(104));
	literals.put(new ANTLRHashString("preload", this), new Integer(101));
	literals.put(new ANTLRHashString("hedit", this), new Integer(148));
	literals.put(new ANTLRHashString("fixed", this), new Integer(103));
	literals.put(new ANTLRHashString("\"translation\"", this), new Integer(180));
	literals.put(new ANTLRHashString("control", this), new Integer(128));
	literals.put(new ANTLRHashString("pushbox", this), new Integer(139));
	literals.put(new ANTLRHashString("ctext", this), new Integer(134));
	literals.put(new ANTLRHashString("popup", this), new Integer(163));
	literals.put(new ANTLRHashString("menubarbreak", this), new Integer(161));
	literals.put(new ANTLRHashString("class", this), new Integer(117));
	literals.put(new ANTLRHashString("pushbutton", this), new Integer(140));
	literals.put(new ANTLRHashString("menu", this), new Integer(121));
	literals.put(new ANTLRHashString("combobox", this), new Integer(150));
	literals.put(new ANTLRHashString("versioninfo", this), new Integer(168));
	literals.put(new ANTLRHashString("impure", this), new Integer(107));
	literals.put(new ANTLRHashString("edittext", this), new Integer(146));
	literals.put(new ANTLRHashString("bitmap", this), new Integer(129));
	literals.put(new ANTLRHashString("fileos", this), new Integer(173));
	literals.put(new ANTLRHashString("version", this), new Integer(115));
	literals.put(new ANTLRHashString("\"stringfileinfo\"", this), new Integer(177));
	literals.put(new ANTLRHashString("radiobutton", this), new Integer(142));
	literals.put(new ANTLRHashString("autoradiobutton", this), new Integer(137));
	literals.put(new ANTLRHashString("iedit", this), new Integer(149));
	literals.put(new ANTLRHashString("designinfo", this), new Integer(182));
	literals.put(new ANTLRHashString("grayed", this), new Integer(158));
	literals.put(new ANTLRHashString("dlginit", this), new Integer(185));
	literals.put(new ANTLRHashString("defpushbutton", this), new Integer(141));
	literals.put(new ANTLRHashString("font", this), new Integer(120));
	literals.put(new ANTLRHashString("pragma", this), new Integer(95));
	literals.put(new ANTLRHashString("code_page", this), new Integer(96));
	literals.put(new ANTLRHashString("exstyle", this), new Integer(119));
	literals.put(new ANTLRHashString("\"varfileinfo\"", this), new Integer(179));
	literals.put(new ANTLRHashString("noinvert", this), new Integer(125));
	literals.put(new ANTLRHashString("ltext", this), new Integer(132));
	literals.put(new ANTLRHashString("loadoncall", this), new Integer(102));
	literals.put(new ANTLRHashString("menubreak", this), new Integer(162));
	literals.put(new ANTLRHashString("inactive", this), new Integer(160));
	literals.put(new ANTLRHashString("fileflagsmask", this), new Integer(171));
	literals.put(new ANTLRHashString("state3", this), new Integer(143));
	literals.put(new ANTLRHashString("virtkey", this), new Integer(124));
	literals.put(new ANTLRHashString("default", this), new Integer(97));
	literals.put(new ANTLRHashString("bedit", this), new Integer(147));
	literals.put(new ANTLRHashString("nonshared", this), new Integer(109));
	literals.put(new ANTLRHashString("false", this), new Integer(80));
	literals.put(new ANTLRHashString("productversion", this), new Integer(170));
	literals.put(new ANTLRHashString("separator", this), new Integer(156));
	literals.put(new ANTLRHashString("stringtable", this), new Integer(112));
	literals.put(new ANTLRHashString("l", this), new Integer(110));
	literals.put(new ANTLRHashString("checkbox", this), new Integer(138));
	literals.put(new ANTLRHashString("discardable", this), new Integer(105));
	literals.put(new ANTLRHashString("value", this), new Integer(178));
	literals.put(new ANTLRHashString("menuex", this), new Integer(164));
	literals.put(new ANTLRHashString("begin", this), new Integer(98));
	literals.put(new ANTLRHashString("shift", this), new Integer(127));
	literals.put(new ANTLRHashString("block", this), new Integer(176));
	literals.put(new ANTLRHashString("true", this), new Integer(79));
	literals.put(new ANTLRHashString("rcdata", this), new Integer(166));
	literals.put(new ANTLRHashString("alt", this), new Integer(126));
	literals.put(new ANTLRHashString("dialogex", this), new Integer(154));
	literals.put(new ANTLRHashString("accelerators", this), new Integer(122));
	literals.put(new ANTLRHashString("filetype", this), new Integer(174));
	literals.put(new ANTLRHashString("userbutton", this), new Integer(145));
	literals.put(new ANTLRHashString("listbox", this), new Integer(151));
}

public Token nextToken() throws TokenStreamException {
	Token theRetToken=null;
tryAgain:
	for (;;) {
		Token _token = null;
		int _ttype = Token.INVALID_TYPE;
		resetText();
		try {   // for char stream error handling
			try {   // for lexical error handling
				switch ( LA(1)) {
				case '#':
				{
					mNUMBER_SIGN(true);
					theRetToken=_returnToken;
					break;
				}
				case '(':
				{
					mLEFT_PARENTHESE(true);
					theRetToken=_returnToken;
					break;
				}
				case ')':
				{
					mRIGHT_PARENTHESE(true);
					theRetToken=_returnToken;
					break;
				}
				case '{':
				{
					mLEFT_BRACE(true);
					theRetToken=_returnToken;
					break;
				}
				case '}':
				{
					mRIGHT_BRACE(true);
					theRetToken=_returnToken;
					break;
				}
				case '[':
				{
					mLEFT_BRACKET(true);
					theRetToken=_returnToken;
					break;
				}
				case ']':
				{
					mRIGHT_BRACKET(true);
					theRetToken=_returnToken;
					break;
				}
				case ';':
				{
					mSEMICOLON(true);
					theRetToken=_returnToken;
					break;
				}
				case ',':
				{
					mCOMMA(true);
					theRetToken=_returnToken;
					break;
				}
				case ':':
				{
					mCOLON(true);
					theRetToken=_returnToken;
					break;
				}
				case '~':
				{
					mBITWISE_NOT(true);
					theRetToken=_returnToken;
					break;
				}
				case '^':
				{
					mBITWISE_XOR(true);
					theRetToken=_returnToken;
					break;
				}
				case '*':
				{
					mSTAR(true);
					theRetToken=_returnToken;
					break;
				}
				case '%':
				{
					mMOD(true);
					theRetToken=_returnToken;
					break;
				}
				case '\\':
				{
					mPATH_SEPARATOR(true);
					theRetToken=_returnToken;
					break;
				}
				case '"':
				{
					mSTRING_LITERAL(true);
					theRetToken=_returnToken;
					break;
				}
				case '\t':  case '\n':  case '\u000c':  case '\r':
				case '\u0011':  case ' ':  case '\u2028':  case '\u2029':
				{
					mWHITE_SPACE(true);
					theRetToken=_returnToken;
					break;
				}
				case '.':  case '0':  case '1':  case '2':
				case '3':  case '4':  case '5':  case '6':
				case '7':  case '8':  case '9':
				{
					mNUMERAL(true);
					theRetToken=_returnToken;
					break;
				}
				default:
					if ((LA(1)=='&') && (LA(2)=='&')) {
						mLOGICAL_AND(true);
						theRetToken=_returnToken;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -