AutoCorrect

From Esolang
Jump to navigation Jump to search
This is still a work in progress. It may be changed in the future.

AutoCorrect is a golfed derivative of C, where every error in the code that the parser can find is corrected. Codes in AutoCorrect uses autocorrection as a way to remove characters that are arbitrarily unnecessary (such as closing brackets).

Autocorrecting

Autocorrection is performed when either the parser encountered a syntax error, or when a name hasn't been declared (while alternative names exists). Autocorrection should be exhaustive; it should consider every single possible corrections.

Syntax errors

On syntax errors, the parser corrects it by adding the expected character. If multiple suggestions exists, it chooses the most prioritized one (priority system is left to be implemented in the compiler), retrying with another suggestion if it's still invalid.

Undeclared names

On undefined names, the parser corrects it by choosing a name containing the same characters in the same order. For example, function name ps could be corrected to puts or fgetpos, but not pow or sprintf.

There are priorities on choosing a name: (rules written first are prioritized)

  1. Suggestions with the least corrections are prioritized. For the function name ps, puts is better than printf_s.
  2. Suggestions with the least correction chunks are prioritized. For the function name lg, log with 1 chunk is better than ilogf with 3 chunks.
  3. Variable names takes priority above functions.
  4. On functions, consider the inputs of the functions. p("Hello, world! is better corrected to puts("Hello, world!"); instead of pow("Hello, world!");
  5. By default, functions from the library stdio.h, stdlib.h, and stddef.h are prioritized, however this can be configured on the compiler.

Example codes

Since the compiler hasn't been implemented yet, these example codes might not work.

Hello, world!

m({p"Hello, world!

This possibly autocorrects to:

main(){puts("Hello, world!");}

See also