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
358 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 115
firstChar challenge 13 114
Problem to page 4 85
Constant string is of type char *   ? 7 27
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

813 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now