newbie lex question: parsing Postscript

newbie lex question: parsing Postscript

Post by Ronald A. Creamer J » Tue, 06 Apr 1993 09:11:16

I'm a newcomer to the lex tool, parsing Macintosh
generated postscript files for use on a UNIX print
spooler. Things like:

  "%%Title:"[^'\r']*          {printf("%s\n", yytext);}
  "%%Creator:"[^'\r']*        {printf("%s\n", yytext);}
  "%%For:"[^'\r']*            {printf("%s\n", yytext);}

and the like I want to send to stdout, I want to skip
over the rest or send it to /dev/null. In other words,
all that I want to appear on the output are these and
only these lines.

Currently, my printfs and even the stuff I don't want
appears in the output stream.
Is there a token I can put at the bottom of all these
to trap everything else and do a noop?

sed would be my first choice, but it chokes when it
doesn't see a \n in the input stream and gives up,
(Mac Postscript end of lines are just <cr>) thus the
matching up to [^'\r']* construct.

While we're at it. If anybody can point me to any ftp
site w/ Postscript job processing routines, it would
be greatly appreciated.

___________________________Ron Creamer_______________________________

   HQ: 501 Camridge Street              | Voice  : 617/374-6000
       Cambridge, MA 02141              | FAX    : 617/374-6020


1. lex/yacc parsing: ending parse with yywrap?

I'm parsing a config file with lex/yacc, but for some reason it tries
to keep going after it reaches EOF.  It's correctly calling yywrap when
EOF is detected, but I'm closing yyin and returning 1 in yywrap and it
still keeps going.  With yydebug on it looks like:

[Lots of yydebug stmts: shifts, reads, reduces, working correctly]
yydebug: state 14, reading 0 (end-of-file)
syntax error
yydebug: error recovery discarding state 14
[Error recovery, then bails because yyparse returns 1]

I tried putting in a <<EOF>> state in the lexer, but it didn't
help, even though it was properly detected.  I must be missing
something stupid here -- help?

TIA --


WWW:       PHONE: (619) 220-0850

"Just where in the constitution does it explain this ludicrous concept of
 bills being passed into law without a presidential signature or a
 legislative override?"
     -- Charles Eicher,

2. serial line looped back

3. lex/yacc parsing question

4. file mods ??? -rwsrwsrwt

5. lex/yacc problem: parsing only part of text stream

6. Exabyte EXB-8000 series tape problem

7. yacc/lex/parsing ??

8. Shell chroot problem

9. YACC/LEX parsing help needed ../

10. newbie question - lex

11. LEX and YACC: How do I parse a new file?

12. Help : Parsing with LEX

13. Mail Header parsing with lex...