[Beginner Question]How to let the lex && yacc parsing the string? Instead of the console. - Mailing list pgsql-general

From Wen Yi
Subject [Beginner Question]How to let the lex && yacc parsing the string? Instead of the console.
Date
Msg-id tencent_2E749C829B9BB4B80B501DD06A99A903A406@qq.com
Whole thread Raw
List 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 && lex)
That's means,I need to:

Raw config file -> Buffer -> Parse(Lex && Yacc) -> Complete

Now I write the lex && 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)
{
      yacc_init = lex_analyse(string_want_to_analyse);
      yacc_analyse(yacc_init);

Can someone provide me some advice?

Yours,
Wen Yi

pgsql-general by date:

Previous
From: Junwang Zhao
Date:
Subject: Re: timetz need more bytes than timestamptz
Next
From: Evgeny Morozov
Date:
Subject: Re: "PANIC: could not open critical system index 2662" - twice