Practice free →
HomeGATE CSEcomputerscienceCompiler Design › Which is a token (TYPE) emitted by a typical C-s…

Which is a token (TYPE) emitted by a typical C-style scanner?

ADECLARATION_NODE
BFUNCTION_CALL_EXPR
CLEFT_PAREN
DAST_ROOT
Answer & Solution
Correct answer: C. LEFT_PAREN
1. TOKENS are output by the SCANNER and are LEXICAL units like: - LEFT_PAREN, RIGHT_PAREN, COMMA, SEMICOLON - PLUS, MINUS, STAR, SLASH - NUMBER, STRING, IDENTIFIER - Reserved words: IF, WHILE, RETURN, etc. 2. AST nodes (DECLARATION_NODE, FUNCTION_CALL_EXPR, AST_ROOT) are produced by the PARSER, a later phase. They're NOT tokens. 3. The distinction matters: scanner deals with the syntax of CHARACTERS; parser deals with the syntax of TOKENS. 4. So LEFT_PAREN is the only token type among the choices. _Source: Bob Nystrom, "Crafting Interpreters", Ch 4.2 (Token types for Lox)._
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions