2
我繼ANTLR教程和教程說。但是,當我嘗試添加寫完全相同的代碼不能使用Eclipse調試簡單的通道標誌在ANTLR
$channel = HIDDEN;
保持它給我的錯誤,如
Multiple markers:
-(100): syntax error: antlr: MissingTokenException(inserted [@-1,0:0='<missing RPAREN>',<69>,22:41]
at channel)
-(100): syntax error: antlr: NoViableAltException([email protected][])
-(100): syntax error: antlr: NoViableAltException([email protected][])
「$通道」的紅色誤差欄下,和
(100): syntax error: antlr: MissingTokenException(inserted [@-1,0:0='<missing EOF>',<-1>,22:58]
at))
的紅色誤差棒下「;」
這是代碼:
grammar Sample;
options {
language = Java;
}
@header {
package a.b.c;
}
@lexer::header {
package a.b.c;
}
programe
: 'program' IDENT '='
'begin'
'end' IDENT '.'
;
IDENT:'a'..'z'+;
WS : (' '| 't' | '\n' | '\r' | 'f')+ ($channel = HIDDEN;);
,這是錯誤消息當我試圖挽救它
error(100): /ANTLR 3.x Tutorial/src/sample/Sample.g:22:40: syntax error: antlr: NoViableAltException([email protected][])
|---> WS : (' '| 't' | '\n' | '\r' | 'f')+ ($channel = HIDDEN;);
error(100): /ANTLR 3.x Tutorial/src/sample/Sample.g:22:41: syntax error: antlr: NoViableAltException([email protected][])
|---> WS : (' '| 't' | '\n' | '\r' | 'f')+ ($channel = HIDDEN;);
error(100): /ANTLR 3.x Tutorial/src/sample/Sample.g:22:41: syntax error: antlr: MissingTokenException(inserted [@-1,0:0='<missing RPAREN>',<69>,22:40] at channel)
|---> WS : (' '| 't' | '\n' | '\r' | 'f')+ ($channel = HIDDEN;);
error(100): /ANTLR 3.x Tutorial/src/sample/Sample.g:22:58: syntax error: antlr: MissingTokenException(inserted [@-1,0:0='<missing EOF>',<-1>,22:57] at))
|---> WS : (' '| 't' | '\n' | '\r' | 'f')+ ($channel = HIDDEN;);
error(10): internal error: /ANTLR 3.x Tutorial/src/sample/Sample.g : java.lang.IllegalStateException: java.lang.NullPointerException
org.deved.antlride.runtime.AntlrErrorListener$DynamicToken.invokeMethod(AntlrErrorListener.java:59)
org.deved.antlride.runtime.AntlrErrorListener$DynamicToken.getLine(AntlrErrorListener.java:64)
org.deved.antlride.runtime.AntlrErrorListener.report(AntlrErrorListener.java:131)
org.deved.antlride.runtime.AntlrErrorListener.message(AntlrErrorListener.java:113)
org.deved.antlride.runtime.AntlrErrorListener.error(AntlrErrorListener.java:103)
org.antlr.tool.ErrorManager.syntaxError(ErrorManager.java:768)
org.antlr.grammar.v3.AssignTokenTypesWalker.reportError(AssignTokenTypesWalker.java:208)
org.antlr.grammar.v3.AssignTokenTypesWalker.block(AssignTokenTypesWalker.java:2419)
org.antlr.grammar.v3.AssignTokenTypesWalker.ebnf(AssignTokenTypesWalker.java:3439)
org.antlr.grammar.v3.AssignTokenTypesWalker.element(AssignTokenTypesWalker.java:3166)
org.antlr.grammar.v3.AssignTokenTypesWalker.alternative(AssignTokenTypesWalker.java:2483)
org.antlr.grammar.v3.AssignTokenTypesWalker.block(AssignTokenTypesWalker.java:2389)
org.antlr.grammar.v3.AssignTokenTypesWalker.ruleBody(AssignTokenTypesWalker.java:1947)
org.antlr.grammar.v3.AssignTokenTypesWalker.rule(AssignTokenTypesWalker.java:1569)
org.antlr.grammar.v3.AssignTokenTypesWalker.rules(AssignTokenTypesWalker.java:1505)
org.antlr.grammar.v3.AssignTokenTypesWalker.grammarSpec(AssignTokenTypesWalker.java:713)
org.antlr.grammar.v3.AssignTokenTypesWalker.grammar_(AssignTokenTypesWalker.java:383)
org.antlr.tool.CompositeGrammar.assignTokenTypes(CompositeGrammar.java:337)
org.antlr.Tool.process(Tool.java:462)
org.deved.antlride.runtime.Tool2.main(Tool2.java:24)
5 errors
BUILD FAIL
Total time: 879 milliseconds
謝謝。