Is this string representation needed for display purpose or something else?
There is a virtual 'unparse' method defined on ItemExpr class which is the base class for value_expression. Calling that method will return the string representation by traversing over the tree. This method is used for creating text representation when needed. One thing to be careful is to not overload parser step with functionality that should preferable be done after bind step. It is also not a good idea to refer to generated structures like yytext, yyleng etc in parser. // produce an ascii-version of the object (for display or saving into a file) virtual void unparse(NAString &result, PhaseEnum phase = DEFAULT_PHASE, UnparseFormatEnum form = USER_FORMAT, TableDesc * tabId = NULL) const; anoop -----Original Message----- From: xiaozhong.w...@esgyn.cn <xiaozhong.w...@esgyn.cn> Sent: Saturday, March 10, 2018 6:35 AM To: dev@trafodion.apache.org Subject: 答复: how to get original text for value_expression in the parser I think you need to modify lex, the suffix is .ll file in EsgynDB. Zhenxin.He and Wenjun.Zhu did the similar thing as you want. You can ask them. 发送自 Windows 10 版邮件应用 发件人: Liu, Ming (Ming) 发送时间: 2018年3月10日 22:24 收件人: dev@trafodion.apache.org<mailto:dev@trafodion.apache.org> 主题: how to get original text for value_expression in the parser Hi, all, I am trying to get the text string in the parser for product 'value_experssion', but I cannot find a good way to do it for a long time without success. Does anyone know how to do that? Example, here is a production for function firstdayofyear: | TOK_FIRSTDAYOFYEAR '(' value_expression ')' { $$ = new (PARSERHEAP()) ZZZBinderFunction(ITM_FIRSTDAYOFYEAR, $3); } if the user input string for this production is "firstdayofyear ( tbl1.col1 )" I want to get the full string as "firstdayofyear (tbl1.col1)" So here is the code I tried but failed: | TOK_FIRSTDAYOFYEAR '(' value_expression ')' { NAString *utf8Str3 = unicodeToChar (ToTokvalPlusYYText(&$3)->yytext, ToTokvalPlusYYText(&$3)->yyleng, (CharInfo::CharSet) ( ComGetNameInterfaceCharSet() // CharInfo::UTF8 ), PARSERHEAP()); NAString fullstr = "firstdayofyear ( " + *utf8Str3 + ")"; $$ = new (PARSERHEAP()) ZZZBinderFunction(ITM_FIRSTDAYOFYEAR, $3); } utf8Str3 is a NULL pointer for "firstdayofyear (tbl1.col1) ", because a column will be parsed as an ItemExpr pointer, and ToTokvalPlusYYText failed to convert it and get correct yytext. I cannot find an example in the sqlparser.y for this, so ask help in the mail list. The alternative way I now use is checking if utf8Str3 is NULL, if yes, then this is not what I need, since luckily in my case, the value_expression must be a function name which can always get the correct yytext. But I hope there is a better way to do this. thanks, Ming