help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parse input string and input file with same buffer state


From: Harsha Sharma
Subject: Re: Parse input string and input file with same buffer state
Date: Wed, 13 Dec 2017 13:31:43 +0530

On Fri, Dec 8, 2017 at 2:30 AM, Hans Åberg <address@hidden> wrote:
>
>
>> On 7 Dec 2017, at 21:14, Harsha Sharma <address@hidden> wrote:
>>
>> On Fri, Dec 8, 2017 at 1:17 AM, Hans Åberg <address@hidden> wrote:
>>>
>>>> On 7 Dec 2017, at 18:59, Harsha Sharma <address@hidden> wrote:
>>>>
>>>> I'm looking for a way to parse input string and input file (pushing
>>>> buffer state created with yy_scan_string to buffer state created with
>>>> yy_create_buffer to parse input file). It either causes segmentation
>>>> fault or parses either the string or the input file.
>>>
>>> The string pointed to (in a lexer generated by Flex) must be copied before 
>>> passed on elsewhere, as it is just a pointer in a buffer, temporarily 
>>> null-terminated.
>>>
>> This is what I'm exactly trying to do .
>
> In the .l file, the string pointed to by yytext of length yyleng must be 
> copied. Does it do that?
>
The string is copied to variable "variable".
This is the code --
b = yy_scan_string(variable, scanner); /* variable is the string to be parsed */
temp = yy_create_buffer(f, YY_BUF_SIZE, scanner); /* f is the file to
be parsed */
yypush_buffer_state(temp, scanner);

This causes segmentation fault. I want to parse both the string and file.

>> I have a string passed from
>> command line which needs to be parsed 'define test="foo"' and input
>> file references this variable.
>> Same thing can be done by prepending this line in input file 'define
>> test="foo"' but I want to have a command line option for the same.
>
> Can you read the input as a stream instead of first putting it into a string?
>
Preferably not as I want only a part of input from command line.
Thanks for your reply.

Regards,
Harsha Sharma
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]