Types of errors at compile time and at runtime

I have this question in my homework for my Computer Languages ​​class. I'm trying to understand what everyone means, but I'm stuck.

Errors in a computer program can be classified depending on when they are detected and, if they are detected at compile time, what part the compiler detects them. Using your favorite programming language, example:

(a) Lexical error detected by the scanner.

(b) Syntax error detected by the parser.

(c) Static semantic error detected (at compile time) using semantic analysis.

(d) A dynamic semantic error detected (at runtime) by code generated by the compiler.

For (a), I think this will be correct: int char foo;

For (b), int foo(without semicolon)

For (c) and (d), I'm not sure if you are being asked.

Thanks for the help.

+3
source share
2 answers

I will do it. That's what I think:

a. int foo +; (foo + is an invalid identifier, because + is not a valid char in identifiers)

b. foo int; (A syntax error is any error when the syntax is invalid - either due to incorrect translation of words, and with incorrect spelling, and with a comma, and with a comma).

c. Static semantic error is a logical error. for example, to pass a float as an array index - arr [1.5] must be SSE.

d. , , NullReferenceException, DME. , , ( ), . , (, Cat Person DME.) - , .

, .

+3

, , , .

( )

( ) . , if 234 ) , IF INTEGER RPAREN ( , ).

, , , , , . , . , " , ". : " , , ?"


( ) ( ) , . , C Type Identifier SEMICOLON.

: " ?" : " ( ) ?"


C , . D , . , , .

, .

+3

Source: https://habr.com/ru/post/1763933/


All Articles