[英]JAVACC && JJTree (.jjt) Inserting || symbol into tree when parsing two tokens
For eg AB && C Tree should be like this (A || B) && (C). 例如,AB && C树应类似于(A || B)&&(C)。 this should be like this.
这应该是这样的。 I tried out but every time extra ||
我尝试了,但是每次额外|| is added like this A ||
像这样添加A || B ||
B || && C. this generates the wrong tree every time.
&& C.这每次都会生成错误的树。
Code i do it like this 代码我这样做
LOOKAHEAD((simpleTerm())+)
(
simpleTerm()
{
jjtthis.setValue("||");
}
)+
* Note simpleTerm could be <STRING> or <QuotedString> * * 注意simpleTerm可以是&ltSTRING&gt或&ltQuotedString&gt *
How can i insert || 我如何插入|| symbol into tree so it form tree like this A ||
符号变成树,这样就形成树A || B && C.?
B && C.?
How can i insert token image into tree using javacode ? 如何使用javacode将令牌图像插入树中?
Try something like the following 试试下面的东西
void Conjunction() #void :
{ }
{
Disjunction()
( "&&"
Disjunction()
{jjtThis.setValue( "&&" );} #BinOp(2)
)*
}
void Disjunction() #void :
{}
{
SimpleTerm()
(
SimpleTerm()
{jjtThis.setValue( "||" );} #BinOp(2)
)*
}
void SimpleTerm() :
{Token t ;}
{
(t=<STRING> | t=<QUOTEDSTRING>)
{jjtThis.setValue( t.image ) ;}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.