Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
363 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 750 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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 viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

688 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