DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Computer Science (http://www.daniweb.com/forums/forum14.html)
-   -   New Parser Generator (http://www.daniweb.com/forums/thread162257.html)

Rashakil Fol Dec 14th, 2008 8:52 pm
Re: New Parser Generator
 
It's not your compiler, it's you. Also, that file you linked doesn't use fgets.

Instead of using gets, you should use fgets.

But really you should use std::string functions.

frencheneesz Dec 14th, 2008 11:04 pm
Re: New Parser Generator
 
Quote:

Paste an example where fgets is behaving buggily and I can take a look.
So I actually tested it on another computer - and gets does indeed crash it. This is one of those errors that make 0 sense. I just write them off as a bug in GCC.

Rashakil Fol Dec 14th, 2008 11:59 pm
Re: New Parser Generator
 
That's extremely dumb. Compiler errors are extremely rare, and you're not going to set one off just by using gets.

frencheneesz Dec 15th, 2008 12:53 am
Re: New Parser Generator
 
Come on. Please don't insult me. Look, I fixed the file up at the link I had given you - sorry I was careless about leaving gets out.

http://www.uweb.ucsb.edu/~frenchenee...Calculator.cpp

That does use gets, and it doesn't work properly. I shouldn't have said "crash" - that was misleading. The string is not recognized by my parser for some reason, and it fails. Commenting out fgets, and using my code makes it work. I don't believe there is any logical error. This is why I assumed something was wrong with the compiler.
Quote:

Instead of using gets, you should use fgets.
Why? I would be very surprised if 'gets' didn't use 'fgets' under the covers.

frencheneesz Dec 15th, 2008 12:56 am
Re: New Parser Generator
 
Just to clarify, no offense, but I'm not actually looking for critique of my programming style. Much of this code was slapped together - I am not attempting to push it as the best example of C++ code.

Rashakil Fol Dec 15th, 2008 12:59 am
Re: New Parser Generator
 
Quote:

Originally Posted by Rashakil Fol (Post 757287)
I'll post an example of what I would consider to be a more comfortable C++ parser generator at this level of scope later tonight.

Er, tomorrow night.


All times are GMT -4. The time now is 12:22 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC