The decision about whether an incorrect program can have the correct continuation

(The next question relates to OCaml and has examples in OCaml, but the question is very general, and probably the correct answer for any other computer language will also solve my problem. So just take this question in your favorite language.)

I want to write a function that takes an arbitrary program in OCaml as a string and decides whether the program is right or wrong, and, in the latter case, can I make it right by combining the corresponding characters at the end.

I assume that somewhere there is a language compiler, and that I can apply it and get an answer saying either "Compilation" or "Does not compile - an error in line X, character Y" (as is the case with most languages โ€‹โ€‹anyway ) In general, I would like to have a function that takes a program and returns:

  • Correct - if the line contains the correct program,
  • Erroneous - if the line contains the wrong program, which, no matter how you associate it with characters, will never become correct;
  • Incomplete - if the line contains the wrong program, which is not erroneous.

, OCaml let x = f , f . , , f, - , . let x = ; let x = 5, . , Erroneous , Incomplete - .

,

let ans = 5
let x = a

, ns, .

: , โ€‹โ€‹/? , ? , , .

( , , -, Incomplete. , , , 3 , 100 , .)

+3
1

let x = f, , un y -> y?

, , . , , /, "", , "", , ( ).

: , EOF, . . , , .

, lexing/parsing, , - , , - "", , , .

( ?) - , , . . , , . , , , .

" ". , ( ). ; " ", . , , .

: , , . Oleg .

+6

All Articles