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

📄 readertypespec.java

📁 A framework written in Java for implementing high-level and dynamic languages, compiling them into J
💻 JAVA
字号:
// Copyright (c) 2001  Per M.A. Bothner// This is free software;  for terms and warranty disclaimer see ./COPYING.package gnu.kawa.lispexpr;import gnu.text.*;import gnu.mapping.InPort;/** Reader table entry for '<' to treat '[' and ']' as constituents. * Lets us use (say) '<char[]>' as a token even if  '[' and ']' are parens. * @author Bruce R. Lewis. */public class ReaderTypespec extends ReadTableEntry{  public int getKind()  {    return ReadTable.NON_TERMINATING_MACRO;  }  public Object read (Lexer in, int ch, int count)    throws java.io.IOException, SyntaxException  {    int startPos = in.tokenBufferLength;    LineBufferedReader port = in.getPort();    ReadTable rtable = ReadTable.getCurrent();    ReadTableEntry entry;    char saveReadState = '\0';    in.tokenBufferAppend(ch);    int c = ch;    int prev;    if (port instanceof InPort)      {	saveReadState = ((InPort) port).readState;	((InPort) port).readState = (char) ch;      }    try      {	boolean got_open_square = false;	for (;;)	  {	    int next;	    prev = c;	    if (port.pos < port.limit && prev != '\n')	      c = port.buffer[port.pos++];	    else	      c = port.read();	    if (c == '\\')	      {		if (in instanceof LispReader)		  c = ((LispReader) in).readEscape();		else		  c = port.read();	      }	    else	      {		if ( (!got_open_square && c == '['		      && true == (got_open_square = true))		     || (got_open_square && c == ']'			 && false == (got_open_square = false))		     || (null != (entry = rtable.lookup(c))			 && entry.getKind() == ReadTable.CONSTITUENT))		  {		      in.tokenBufferAppend(c);		      continue;		  }		else		  {		    in.unread(c);		    break;		  }	      }	    }	return (new java.lang.String (in.tokenBuffer, startPos,				      in.tokenBufferLength - startPos)).intern();      }    finally      {	in.tokenBufferLength = startPos;	if (port instanceof InPort)	  ((InPort) port).readState = saveReadState;      }  }}

⌨️ 快捷键说明

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