Correct Syntax Error

From Esolang
Jump to navigation Jump to search

A language that has a well-defined syntax, but the semantics are that any program that has correct syntax will result in a Correct Syntax Error.

However, a program that has only invalid syntax will do something. This something should not be well-defined, and undocumented. Its up to the implementation of the interpreter or compiler to determine what to do with incorrect syntax. The more incorrect syntax, the more your program will do. It probably won't do what you want it to do, but programming in any language is like that in my experience.


Example

The syntax of the language could be the same as C. But any valid C is rejected by the compiler.

So this code:

#include <stdio.h>
void main () {
    printf("Hello Word.\n");
}

will result in a Correct Syntax Error (from line 1 through line 4).

But illegal C, for example:

#stdio.h
=voidmain))
  99print('Hello World[--
'
23

might print Hello World, or do something else entirely. But it won't throw any correct syntax errors.

Implementation

The reference implementation of the interpreter/compiler is full of syntax errors.


Another idea

The actual code that's executed depends on the error message -- maybe something like brainfuck, but with an opcode per ascii character, and it's run from the error output of the compiler. Maybe it *is* brainfuck, and each character spat out by the compiler is mod 8. Can use #ifdef to check which compiler is being run and generate error message accordingly.

Related

The Ↄ language