aspose file tools*
The moose likes Beginning Java and the fly likes Parsing error !! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Parsing error !!" Watch "Parsing error !!" New topic
Author

Parsing error !!

Shaan patil
Ranch Hand

Joined: Dec 22, 2007
Posts: 58
Hi,

How is parsing error different from compiler error & Runtime error or exception?

What all things can be caught in a parsing stage ?

Regards


"You cannot change the truth but truth can change you "
Paul Santa Maria
Ranch Hand

Joined: Feb 24, 2004
Posts: 236
Parsing errors are felonies, but compiler errors are just misdemeanors. Only runtime exceptions go on your driving record, though.
[ January 04, 2008: Message edited by: Paul Santa Maria ]

Paul M. Santa Maria, SCJP
Shannon Holck
Greenhorn

Joined: Jan 04, 2008
Posts: 5
Shaan,

Let me give this a shot to see if this helps you a little more.

Errors are unexpected conditions caused usually by human error, while Exceptions are conditions that the programmer should be expecting to happen and can tell the program how to handle appropriately.

Parsing error - a syntax error in your code that makes it unable to be parsed by the compiler, e.g., a missing colon or quote mark or parenthesis.

Compiler error - I'm not sure this is different from parsing error, unless you want to count these as a separate category: e.g., passing the wrong parameter types or incorrectly casting a value to the wrong type or failing to initialize a variable which you later try to use. The compiler can read your code, but the compiler should raise an error to tell you this won't work at runtime. Compilers also issue warnings, like ... you never used a variable which you declared and while it can compile, the compiler may think you should take another look at your code in case you forgot something (Eclipse does this). Of course, the term "Compiler Error" may also refer to the compiler itself failing (after all, it is a program written by a human).

Runtime error - your code works, but it doesn't work correctly. For example, the output of a program that says:
"A gameboard of 8 by 1 has been created. Start column = 5. A ship of 7 cells has been hidden on the game board."
Well, it's impossible to have a ship on my Battleship game board that starts in column 5 and is 7 cells big when the gameboard is only 8 cells wide... see what I mean? Bit of a logic problem to make sure your game pieces don't fall off!

Exception - this may happen occasionally, but our program expects it to be an exception rather than a rule. For example, my code is supposed to load a file, but the file isn't there. My code should then raise a FileNotFoundException and then handle it somewhere in a catch block, e.g., warn the user that I couldn't find the file ... tell them which file it was, where I looked for it, etc., so they understand why it occurred and can take manual intervention. A really nice programmer would let them try again.

Hope that helps!
 
Consider Paul's rocket mass heater.
 
subject: Parsing error !!