473,383 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Parser

In comp.programming I asked for advice for writing a parser. The code
someone showed me wouldn't compile. I don't know what's wrong. I just want
to write the simpliest of parsers.

int parser(FILE *in,FILE *out);

int main(void){
parser(stdin,stdout);
return0;}

Won't compile. My guess is maybe this should be written

parser(&stdin,&stdout);

But that's my opinion.

Bill

Nov 14 '05 #1
5 2089
Bill Cunningham <no****@nspam.net> scribbled the following:
In comp.programming I asked for advice for writing a parser. The code
someone showed me wouldn't compile. I don't know what's wrong. I just want
to write the simpliest of parsers. int parser(FILE *in,FILE *out); int main(void){
parser(stdin,stdout);
return0;} Won't compile. My guess is maybe this should be written parser(&stdin,&stdout); But that's my opinion.


Your opinion is wrong. stdin and stdout are of type FILE *, not of
type FILE. The reason it won't compile is the same as in your
previous post - the function parser() isn't defined anywhere, just
declared.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Remember: There are only three kinds of people - those who can count and those
who can't."
- Vampyra
Nov 14 '05 #2

"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:c5**********@oravannahka.helsinki.fi...
Bill Cunningham <no****@nspam.net> scribbled the following:
In comp.programming I asked for advice for writing a parser. The code someone showed me wouldn't compile. I don't know what's wrong. I just want to write the simpliest of parsers.

int parser(FILE *in,FILE *out);

int main(void){
parser(stdin,stdout);
return0;}

Won't compile. My guess is maybe this should be written

parser(&stdin,&stdout);

But that's my opinion.


Your opinion is wrong. stdin and stdout are of type FILE *, not of
type FILE. The reason it won't compile is the same as in your
previous post - the function parser() isn't defined anywhere, just
declared.


That won't stop a compile (but the missing #include <stdio.h>
as well as the syntax error in the 'return' statement will.)
The missing definition will prevent successful linking
though.

-Mike
Nov 14 '05 #3
Bill Cunningham wrote:
In comp.programming I asked for advice for writing a parser. The code
someone showed me wouldn't compile. I don't know what's wrong. I just want
to write the simpliest of parsers.

int parser(FILE *in,FILE *out);

int main(void){
parser(stdin,stdout);
return0;}

Won't compile. My guess is maybe this should be written

parser(&stdin,&stdout);

But that's my opinion.


And it's a bad one. The following should compile without diagnostics:

#include <stdio.h>

int parser(FILE * in, FILE * out);

int main(void)
{
parser(stdin, stdout);
return 0;
}

int parser(FILE * in, FILE * out)
{
(void) in; /* noops here to quiet */
(void) out; /* 'unused parameter' warnings. */
return 0;
}
Nov 14 '05 #4
int parser(FILE * in, FILE * out)
{
(void) in; /* noops here to quiet */
(void) out; /* 'unused parameter' warnings. */
return 0;
}

What do the voids in parenthesis mean? Are they casts? This NG always
makes me feel dumb.

Bill
Nov 14 '05 #5
"Bill Cunningham" <no****@nspam.net> writes:

Hello Bill,
int parser(FILE * in, FILE * out)
{
(void) in; /* noops here to quiet */
(void) out; /* 'unused parameter' warnings. */
return 0;
}
What do the voids in parenthesis mean? Are they casts? This NG always
makes me feel dumb.


Yes! It's a cast. A cast to void seems pretty useless, especially in
this case where the casted value isn't even used, but it's actually
quite useful here to remove the warning.

Julien
Nov 14 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Paulo Pinto | last post by:
Hi, does anyone know of a Python package that is able to load XML like the XML::Simple Perl package does? For those that don't know it, this package maps the XML file to a dictionary.
11
by: Jean de Largentaye | last post by:
Hi, I need to parse a subset of C (a header file), and generate some unit tests for the functions listed in it. I thus need to parse the code, then rewrite function calls with wrong parameters....
1
by: Karalius, Joseph | last post by:
Can anyone explain what is happening here? I haven't found any useful info on Google yet. Thanks in advance. mmagnet:/home/jkaralius/src/zopeplone/Python-2.3.5 # make gcc -pthread -c...
3
by: Himanshu Garg | last post by:
Hello, I am trying to pinpoint an apparent bug in HTML::Parser. The encoding of the text seems to change incorrectly if the locale isn't set properly. However Parser.pm in the directory...
2
by: Joel Hedlund | last post by:
Hi! I have a possibly dumb question about imports. I've written two python modules: parser.py ------------------------------------ class Parser(object): "my parser"...
5
by: thewarden | last post by:
I've come into a situation where I require to have BBCode parsed, this includes the standard tags supported by PEAR package HTML_BBCodeParser and custom BBCode tags I've added myself. My problem...
28
by: Marc Gravell | last post by:
In Linq, you can apparently get a meaningful body from and expression's .ToString(); random question - does anybody know if linq also includes a parser? It just seemed it might be a handy way to...
0
by: UncleRic | last post by:
Environment: Mac OS X (10.4.10) on MacBook Pro I'm a Perl Neophyte. I've downloaded the XML::Parser module and am attempting to install it in my working directory (referenced via PERL5LIB env): ...
18
by: Just Another Victim of the Ambient Morality | last post by:
Is pyparsing really a recursive descent parser? I ask this because there are grammars it can't parse that my recursive descent parser would parse, should I have written one. For instance: ...
0
by: arvindkgs | last post by:
Iam using c lexer that is flex generated and a c++ parser that is bison generated. i have modified the parser to acccept only string input. I am calling the parser function yyparse in a loop and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.