English 中文(简体)
在产生《欧洲刑法》时,寻找非常简单的《欧洲航空和航天新一代公约》错误处理范例
原标题:Seeking very simple ANTLR error handling example when generating C code
  • 时间:2010-01-05 01:59:40
  •  标签:
  • antlr
  • antlr3

我想制定《刑法》。 我不会从投入文件中读到一行(例如,汇编者可能)。 相反,随着时间的推移,我将对用户的投入进行分类。

我宁愿发现并处理法尔/帕瑟的不良投入,例如,

/* lexer tokens */
foo : "FOO";
bar : "BAR";
baz : "BAZ";
/* grammar*/
grammar : foo "=" BAZ 
        | foo "=" BAR 
        | <some non-existent Antrl-else> :  {printf(stderr, "bad input
");}
        ;

科索沃,如果我能够把它排在地盘/地盘上,那么似乎像我需要使用<条码>,显示识别码(<>>/代码>,但如何?

谁能把我放在一个非常简单的例子上,这个例子可以产生C代码,并显示一些错误处理无效投入的情况?

感谢!


Ok, bounty, yippee!

但是,只有真正的、工作上的答案,要有真正的、工作守则。 没有轮椅的“使用方法X()”。

最佳回答

在 Java处理一个承认例外,就好:

grammar X;

// ...

@rulecatch{
  catch(RecognitionException rex) {
    // do something
  }
}

// parser rules

// lexer rules 

换言之,在<条码>@rule submissions{......>}栏内仅添加一些海关编码。

问题回答

http://www.antlr.org/api/C/struct_a_n_t_l_r3__b_a_s_e__r_e_e_e_c_o_g_n_i_z_e_r_struct.html#b9e9f3d92b4a40a68a877c9689b60f99” rel=“noreferer”>: 编码> 在你感兴趣的情况下,担任这一职务,并且是C管理时间的一部分。

如果你想看到如何利用这一职能的实例,请查阅。 虽然这部法典是C和C++的,但你应当能够研究你们需要的东西。





相关问题
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 ...

热门标签