Practice free →
HomeGATE CSEcomputerscienceCompiler Design › A scanner usually IGNORES which characters?

A scanner usually IGNORES which characters?

Aalphabetic letters of identifiers
Bdigits within numeric literals
Cwhitespace and comment characters
Doperator characters like + or *
Answer & Solution
Correct answer: C. whitespace and comment characters
1. WHITESPACE (spaces, tabs, newlines) generally has no syntactic meaning in C-family languages. Scanner consumes and discards. 2. COMMENTS: same — consumed without producing a token. 3. EXCEPTIONS: - Python uses INDENTATION (whitespace) syntactically; the scanner must track it carefully. - String literals contain whitespace meaningfully; the scanner preserves the contents. 4. Newlines may be relevant for STATEMENT TERMINATION (e.g. JS with auto-semicolon insertion, Lua). 5. Other options name characters the scanner DOES tokenise. _Source: Bob Nystrom, "Crafting Interpreters", Ch 4.5 (Recognizing Lexemes — whitespace)._
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions