[Beginner Question]How to let the lex && yacc parsing the string? Instead of the console.

From: Wen Yi <896634148(at)qq(dot)com>
To: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: [Beginner Question]How to let the lex && yacc parsing the string? Instead of the console.
Date: 2023-06-19 07:28:50
Message-ID: tencent_2E749C829B9BB4B80B501DD06A99A903A406@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi community,
When I read the postgres's code,I want to achieve a simple scanner_init, so I decided to write a function to analyse the config(Use yacc &amp;&amp; lex)
That's means,I need to:

Raw config file -&gt; Buffer -&gt; Parse(Lex &amp;&amp; Yacc) -&gt; Complete

Now I write the lex &amp;&amp; yacc rule file, but the things confuse me is that, they all read from yyin(Always be stdin) and yyout(Always be stdout),
And I want to let them read from string, provide by a function user-defined.
Like this:(That's my design, not true)

int parse(char *string_want_to_analyse)
{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yacc_init = lex_analyse(string_want_to_analyse);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yacc_analyse(yacc_init);

}&nbsp;

Can someone provide me some advice?

Yours,
Wen Yi

Browse pgsql-general by date

  From Date Subject
Next Message Amit Kapila 2023-06-19 09:34:07 Re: Support logical replication of DDLs
Previous Message Junwang Zhao 2023-06-19 05:20:22 Re: timetz need more bytes than timestamptz