ANTLR: Is there a simple example?

前端 未结 5 1365
借酒劲吻你
借酒劲吻你 2020-11-22 10:06

I\'d like to get started with ANTLR, but after spending a few hours reviewing the examples at the antlr.org site, I still can\'t get a clear understanding of the grammar to

5条回答
  •  -上瘾入骨i
    2020-11-22 10:44

    version 4.7.1 was slightly different : for import:

    import org.antlr.v4.runtime.*;
    

    for the main segment - note the CharStreams:

    CharStream in = CharStreams.fromString("12*(5-6)");
    ExpLexer lexer = new ExpLexer(in);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    ExpParser parser = new ExpParser(tokens);
    

提交回复
热议问题