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

📄 hashcomment.java

📁 JAVA在编译原理上的应用。
💻 JAVA
字号:
package lolo.scans;/** A recognizer class to scan for hash comments: all characters from <tt>#</tt> up to EOL.  * <p>By default these symbols will be ignored. * * @author <a href="http://www.inf.uos.de/bernd" target="_blank">Bernd K&uuml;hl</a>           (<a href="mailto:bernd@informatik.uni-osnabrueck.de">bernd@informatik.uni-osnabrueck.de</a>) */public class HashComment extends SlashSlashComment {    /** The legal characters. */ // A means ANY    protected static final String chars = "A#\r\n";    /** The state table. */    protected static final int newState [][] = {        // current state, input => newstate        // ANY  #  \r   \n        {  3,   1,  3,  3   },  // state 0, find #        {  1,   1,  2,  2   }   // state 1, okay and need more characters                                // state 2, comment found                                // state 3, error    };    public State nextChar(char ch) {        // is ch a legal input character?        int input = chars.indexOf(ch);        if (input < 0) input = 0;                boolean found = false, more = false;        state = newState[state][input];        switch(state) {            case 3:	 break;    // error state, parse ends            case 0:	 new RuntimeException("illegal state "+state); // cann't be..            case 1:	 more = true; break;            case 2:	 found = true; break;            default: new RuntimeException("illegal state "+state); // cann't be..        }                return stateObject.set(more, found);    }}

⌨️ 快捷键说明

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