所以我继续按照this教程尝试我的第一个NB插件。
我收到以下错误:
java.lang.IllegalStateException: Lexer org.htm.lexer.HTMLexer@6787f302
returned null token but lexerInput.readLength()=2
lexer-state: null
tokenStartOffset=8, readOffset=10, lookaheadOffset=11
我的语法是:
options {
JAVA_UNICODE_ESCAPE = true;
ERROR_REPORTING = false;
STATIC = false;
COMMON_TOKEN_ACTION = false;
TOKEN_FACTORY = "Token";
JDK_VERSION = "1.8";
BUILD_PARSER = false;
}
PARSER_BEGIN(HTMLParser)
package org.html.jcclexer;
import java.io.*;
/**
* Grammar to parse Java version 1.5
* @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5
*/
public class HTMLParser {}
PARSER_END(HTMLParser)
/* WHITE SPACE */
TOKEN :
{
< WHITESPACE:
" "
| "\t"
| "\n"
| "\r"
| "\f">
}
TOKEN : { < HTML : "html" > }
MORE :
{
< ~[] >
}
HTMLexer.java
public org.netbeans.api.lexer.Token<HTMTokenId> nextToken()
{
try
{
Token token = javaParserTokenManager.getNextToken();
System.out.println("Token Info Begins");
System.out.println(token.image);
System.out.println(token.next);
System.out.println("Token Info Ends");
if (info.input().readLength() < 1)
{
return null;
}
return info.tokenFactory().createToken(HTMLanguageHierarchy.getToken(token.kind));
}
catch(Exception ex)
{
System.out.println(ex.getLocalizedMessage());
return null;
}
}