java compiler not give all error at a time -
system.out.println("first eror :: without semicolon ") // first error system.out.println("this second error :: out object not used proper :: "); //second error class testcompilation { public static void main(string []args) { system.out.println("hello no semicolon::")//first error system.out.println("hello out spell not correctely::"); //second error } }
whenever compile above code javac command in cmd gives first error means not give second error. in java language partially compiler , partially interpreter , in java first compilation happen compiler should list out errors gives me single error. why happening ? dont understand please me out problem..
i think clear question means compiler works totally ...
for create simple example understand java compiler working .
class testcompilation { public static void main(string []args) { syste.out.rintln("hello");//first error syste.out.rintln("hello");//second error (not printed @ compiler time because syntatically correct in compiler first phase) hitesh542.add(); //there no such class called hitesh542.- compiler thinks right way call method. passes first time. hitesh542.add()();//look out here.. there problem, can't call method this..so show error on first lookup. system.otu.println("hello")//second errorasdasdas if(); //look error.- basic syntax error shown @ first lookup. try{ int = 10 / 0; } //third error //so bottom line java syntatical errors checked first i.e syntax of java not classes or objects. //but obv first thing java compiler should java class first compilation on proper path. :) } }
i'd has how compilers work:
- lexical analysis performed, source code converted sequence of "tokens".
- the code parsed, compiler checks whether tokens meet language syntax. first line fail: every statement in java must ended semicolon.
- semantic analysis performed, compiler tries resolve variables, methods, etc. according list of known symbols - in java, translate classpath.
- code generated source statements translated either native bytecode or intermediate bytecode (the latter case java).
if 1 of steps fails, process must stop, because compiler cannot perform semantic analysis when code doesn't meet syntax.
Comments
Post a Comment