Unix Programming - yacc lex output

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > August 2006 > yacc lex output





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author yacc lex output
k.jayachandran@gmail.com

2006-08-31, 7:48 pm

hello all,
i'm doing a project for parsing a XML file using yacc and lex. i'm
writing grammar based on the sample xml files.
if there is an error in the grammar, i output the error using yyerror
function. but if there is no error i'm not printing anything. even when
there is no error, i see a lot of blank lines and the screen just
scrolls away.
where does this output come from

any help will be appreciated

toby

2006-08-31, 7:48 pm

k.jayachandran@gmail.com wrote:
> hello all,
> i'm doing a project for parsing a XML file using yacc and lex. i'm
> writing grammar based on the sample xml files.
> if there is an error in the grammar, i output the error using yyerror
> function. but if there is no error i'm not printing anything. even when
> there is no error, i see a lot of blank lines and the screen just
> scrolls away.
> where does this output come from


lex's default behaviour is to copy unmatched characters to output, so
perhaps unmatched whitespace is being copied. Try adding a whitespace
eating rule, or using a catchall rule such as:

.. ; /* ignore anything else */

at the end of your lexer definitions. See
http://www.telegraphics.com.au/svn/...r/trunk/lexer.l for an
example of whitespace eating and a catchall that rejects unrecognised
characters.

>
> any help will be appreciated


k.jayachandran@gmail.com

2006-08-31, 7:48 pm

wow, that's brilliant. that explains a lot. it worked.

thanks
jc
toby wrote:[vbcol=seagreen]
> k.jayachandran@gmail.com wrote:
>
> lex's default behaviour is to copy unmatched characters to output, so
> perhaps unmatched whitespace is being copied. Try adding a whitespace
> eating rule, or using a catchall rule such as:
>
> . ; /* ignore anything else */
>
> at the end of your lexer definitions. See
> http://www.telegraphics.com.au/svn/...r/trunk/lexer.l for an
> example of whitespace eating and a catchall that rejects unrecognised
> characters.
>

toby

2006-08-31, 7:48 pm

k.jayachandran@gmail.com wrote:
> wow, that's brilliant. that explains a lot. it worked.


You're welcome. I recommend 'info flex' and 'info bison' when in doubt.


--Toby
[vbcol=seagreen]
>
> thanks
> jc
> toby wrote:

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com