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
361 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

617 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