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

📄 parselist.java

📁 Hecl编程语言是一个高层次的脚本语言的Java实现。其用意是要小
💻 JAVA
字号:
/* Copyright 2004-2006 David N. Welton Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */package org.hecl;/** * <code>ParseList</code> parses up Hecl lists. * * @author <a href="mailto:davidw@dedasys.com">David N. Welton </a> * @version 1.0 */public class ParseList extends Parse {    /**     * Creates a new <code>ParseList</code> instance.     *     * @param in_in a <code>String</code> value     */    public ParseList(String in_in) {        in = in_in;        state = new ParseState(in);        parselist = true;    }    /**     * <code>parseLine</code> parses a line of Hecl code.     *     * @param state a <code>ParseState</code> value     * @exception HeclException if an error occurs     */    public void parseLine(ParseState state) throws HeclException {        char ch;        while (true) {            ch = state.nextchar();            if (state.done()) {                return;            }            if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') {                continue;            }            switch (ch) {		/*		    // new - used to ignore '[' and '\' in list parsing                case '[' :                    parseCommand(state);                    addCurrent();                    break;		case '\\':		    if (!parseEscape(state)) {			parseWord(state);			addCurrent();		    }		    break;		    // end new		 */                case '{' :                    parseBlock(state);                    addCurrent();                    break;                 case '"' :                    parseText(state);                    addCurrent();                    break;                default :                    appendToCurrent(ch);                    parseWord(state);                    addCurrent();                    break;            }        }    }    /**     * <code>parseText</code> parses some text, such as that enclosed in     * quotes "".     *     * @param state a <code>ParseState</code> value     * @exception HeclException if an error occurs     */    public void parseText(ParseState state) throws HeclException {        char ch;        while (true) {            ch = state.nextchar();            if (state.done()) {		// was: 		// return;		throw new HeclException("Unbalanced open quote in list",					"PARSE_ERROR");            }            switch (ch) {	      case '\\' :		parseEscape(state);		break;	      case '"' :		return;	      default :		appendToCurrent(ch);		break;            }	    // new	    // end new	    /* was:	    if (ch == '"') {		return;	    } else {		appendToCurrent(ch);            }	    */        }    }    /**     * <code>parseWord</code> parses a plain Hecl word.     *     * @param state a <code>ParseState</code> value     * @exception HeclException if an error occurs     */    public void parseWord(ParseState state) throws HeclException {        char ch;        while (true) {            ch = state.nextchar();            if (state.done()) {		return;            }            if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') {                return;            }	    appendToCurrent(ch);        }    }}

⌨️ 快捷键说明

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