lex help

lex help

Post by John Price-Wilk » Sun, 20 Dec 1992 03:07:15



My apologies if this is misdirected, but I could use some basic help with  
lex.  I'm writing a filter for a tagged file and have done all of the  
basic routines (i.e., the routines my *basic* skills will cover).  Some of  
the tagging I'm trying to cover looks like the following:
        <doc name="Opera" author="Anselmus">
but sometimes they're like:
        <doc author="Anselmus">
and sometimes like:
        <doc name="Opera">
They are always one of the three, and the contents of the quotes are of  
variable length, often containing spaces.  I'd like to render them as:
        Name:  Opera
        Author:  Anselmus
(or the corresponding versions with only one of the elements).  There's  
another variation on this theme, where the hierarchical tag scheme "<divN"  
is used, so that I encounter
        <div1 name="Opera" author="Anselmus">
as well as
        <div2 name="Opera" author="Anselmus">
and so on, through div4.  My first and most immediate concern is to get a  
lex routine that will take care of each instance (e.g,. a <doc tag that  
has any one of the three configurations -- both author and name, or either  
author or name), but an ideal solution would be to have something that did  
a <doc or any <divN as well.  I'd be much obliged if someone would show me  
the light on this.  Replying to me personally would be swell.

John Price-Wilkin

 
 
 

1. LEX help...

I'm trying to interface lex output with C++, including the redefining of
input() and unput(c) to affect the cin stream.  Has anybody done this before?
I'm using cin.putback for unput and I'm not sure it's working correctly.
Here's the code I've got for them...

#undef input()
char input(void) {
        char c = cin.get();
        if (cin) return c;
        else return 0;

#undef unput()
void unput(char c) {
        if (c=='\n') yylineno--;
        cin.putback(c);

--

Electrical Engineering/Computer Science         Sofware Engineering Section
University of Missouri at Rolla                 U.S. Geological Survey

2. Need X-platform backup

3. 2nd call -- lex help!!

4. Advanced Power Managment for Linux

5. regex in lex help, please

6. to install X; where to find tars and whats needed

7. lex help!!

8. vi editor and Workshop

9. Lex maximum - Error when compiling with "lex"

10. Help: Can't get lex to work ???

11. lex! Help please.

12. Need help with lex and yacc

13. YACC/LEX parsing help needed ../