ccompiler-errorslexical-analysis

What can create a lexical error in C?


Besides not closing a comment /*..., what constitutes a lexical error in C?


Solution

  • Here are some:

     "abc<EOF>
    

    where EOF is the end of the file. In fact, EOF in the middle of many lexemes should produce errors:

     0x<EOF>
    

    I assume that using bad escapes in strings is illegal:

      "ab\qcd"
    

    Probably trouble with floating point exponents

     1e+%
    

    Arguably, you shouldn't have stuff at the end of a preprocessor directive:

    #if x   %