English 中文(简体)
ANTLR - 测试班在分解时没有发现错误
原标题:ANTLR - test class not found error when debugging
  • 时间:2011-10-06 07:29:48
  •  标签:
  • antlr

我正在发现试验舱的错误,即使我通过指挥使之错误。

java org.antlr。 工具。 g

在通过深海生物工程进行分解时。 我一直在网上寻找这一点,但没有成功。 你们是否知道如何解决我的问题?

增 编

www.un.org/Depts/DGACM/index_spanish.htm Edit - grammar:

grammar Expr;

prog    :   stat+ ;

stat    :   expr NEWLINE
    |   ID  =  expr NEWLINE
    |   NEWLINE
    ;

    expr    : multExpr (( +  | -  ) multExpr)*;

    multExpr: atom ( *  atom)*
        ;

    atom    : INT
        | ID
        |  (  expr  ) 
        ;

    ID : ( a .. z  | A .. Z  )+ ;
    INT :  0 .. 9  + ;
    NEWLINE: 
  ?  
  ;
    WS : (    | 	  | 
  | 
  )+ {skip();} ;

Error message:

如果与案文3*4对照,产出——“错误:找不到或装载主要类别<> 试验”。 而 试验则产生于次重/产出......

最佳回答

既然你在评论中评论说,从圣殿开始测试班的工作也失败了,这里的工作是:

import org.antlr.runtime.*;

public class Main {
  public static void main(String[] args) throws Exception {
    ExprLexer lex = new ExprLexer(new ANTLRStringStream("1 + 2 - 3 * 4 - E
"));
    CommonTokenStream tokens = new CommonTokenStream(lex);
    ExprParser parser = new ExprParser(tokens);
    parser.prog();
  }
}

现将您的ANTLR JAR (v3.3 in my example)列入与Main.javaExpr.g相同的目录,并从您的名词中管理主要类别:

java -cp antlr-3.3.jar org.antlr.Tool Expr.g
javac -cp antlr-3.3.jar *.java
java -cp .;antlr-3.3.jar Main

贵岛没有印制任何文件,这意味着教区没有任何问题。

问题回答

暂无回答




相关问题
ANTLR parser hanging at proxy.handshake call

I am attempting to get a basic ECMAScript parser working, and found a complete ANTLR grammar for ECMAScript 3, which appears to compile ok and produces the appropriate Lexer/Parser/Walker Java files. (...

Will ANTLR Help? Different Suggestion?

Before I dive into ANTLR (because it is apparently not for the faint of heart), I just want to make sure I have made the right decision regarding its usage. I want to create a grammar that will parse ...

How to use ANTLR to parse xml document

can anybody tell how to use ANTLR tool(in java) to create our own grammar for xml documents and how to parse those documents using ANTLR tool(in java)?

JavaCC Problem - Generated code doesn t find all parse errors

Just started with JavaCC. But I have a strange behaviour with it. I want to verify input int the form of tokens (letters and numbers) wich are concatenated with signs (+, -, /) and wich can contain ...

How to generate introductory recognizer using ANTLR3C?

The Definitive ANTLR Guide starts with a simple recognizer. Using grammar verbatim to target C-runtime fails because %s means something to ANTLR: $ cat T.g grammar T; options { language = ...

What s the matter with this Grammar?

grammar Test; IDHEAD: ( a .. z | A .. Z | _ ); IDTAIL: (IDHEAD | 0 .. 9 ); ID: (IDHEAD IDTAIL*); fragment TYPE: ( text | number | bool ); define: define ID as TYPE; The problem ...

热门标签