Solved

How to mention in the lex grammar to give the input as a char[] and get output as char[]?

Posted on 2008-09-29
2
359 Views
Last Modified: 2013-11-18
I have written a lex grammar which takes the input from stdin and output to stdout. But I want to pass the input as char[] (eg: char *input_buffer, int input_length) and get output as char[] (eg: char *output_buffer, int output_length). Anyone please help me out this.
0
Comment
Question by:anton_shiban
  • 2
2 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 250 total points
ID: 22603481
The obvious way would be to create a file with the string, and then feed that to the scanner (similar for output).

Alternatively, you could re-define the input() function (or the YY_INPUT macro for flex) to get your input from the string instead of the file stream.
There's no such thing for output though. But generally, the output of a scanner is fed to a parser (generated by yacc for example), so that shouldn't be an issue ... right ?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 22749530
May I ask why you gave a B grade ? That usually means that something was missing in the answer and/or that something is still unclear. If so, please feel free to ask for clarification where needed.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
squareUp  challenge 22 174
changeXy challenge 13 89
Excel file not created as expected 7 79
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 58
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question