PostgreSQL 的 语法分析调用关系

本文探讨了在使用Bison构建语法解析器时,如何通过定义宏和设置前缀来定制解析器函数yyparse的行为。解析器函数用于读取标记、执行动作,并在遇到输入结束或无法恢复的语法错误时返回。文章详细解释了不同返回值所代表的意义。

在gram.c 中,有一行:#define yyparse  base_yyparse

看gram.y 中,与此对应的是: %name-prefix="base_yy"

而看 bison 的 manual:

http://www.gnu.org/software/bison/manual/html_node/Parser-Function.html

4.1 The Parser Function yyparse

You call the function yyparse to cause parsing to occur. This function reads tokens, executes actions, and ultimately returns when it encounters end-of-input or an unrecoverable syntax error. You can also write an action which directs yyparse to return immediately without reading further.

— Function: int  yyparse ( void)

The value returned by yyparse is 0 if parsing was successful (return is due to end-of-input).

The value is 1 if parsing failed because of invalid input, i.e., input that contains a syntax error or that causes YYABORT to be invoked.

The value is 2 if parsing failed due to memory exhaustion.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值