7 Qs · since 2011 · 7 marks · 0.3 marks/paperStandard yield
Lexical Analysis in GATE CS is consistently tested as a 1-mark foundational topic covering tokenization mechanics, formal automaton models, error classification, and compiler data… Guide
char *str1 = "Hello; /* Statement S1 */
char *str2 = "Hello;"; /* Statement S2 */
int *str3 = "Hello"; /* Statement S3 */
Which of the following options is/are correct?id for an identifier in a programming language, using extended regular expressions:
…Topic guide
Lexical Analysis in GATE CS is consistently tested as a 1-mark foundational topic covering tokenization mechanics, formal automaton models, error classification, and compiler data structure lifecycle. Recent years have shifted from purely definitional phase-matching questions toward practical token segmentation using the maximal munch rule and formal construction of NFA/DFA models from regular expressions.
Token Counting with Maximal Munch (Longest Match)
common · NAT · 1 marks · 2026
Given regular expression definitions for tokens (identifiers, numbers, whitespace) and an input string, compute the exact number of tokens recognized by applying greedy prefix matching.
Error Classification Across Compiler Phases
occasional · MSQ · 1 marks · 2026
Given snippets of code with errors (e.g., unclosed string literals, invalid identifiers, type mismatches, missing brackets), classify which phase detects which error (Lexical, Syntactic, or Semantic).
Automata and Regular Expressions for Tokens
common · MCQ · 1 marks · 2023, 2011
Mapping token definitions (extended regular expressions) to corresponding Finite State Automata (NFA with -transitions or DFA) or identifying the theoretical power needed (FSA).
Role of Lexer and Symbol Table Interactions
common · MCQ · 1 marks · 2025, 2024, 2011
Conceptual verification of the lexical analyzer's duties (keyword identification, token stream generation) and symbol table management (creation at lexical phase, persistence across code generation).
Identifier Regular Definition
Used to specify valid identifier lexical patterns and evaluate corresponding NFA/DFA transitions.
Maximal Munch Token Split
Used when scanning an input stream without whitespace delimiters where a prefix matches one token class and the remainder starts a new token (e.g., splitting `23mm` into `number` 23 and `id` mm).
Transition from direct recall questions (e.g., matching phases or identifying FSA as the formal model) to constructive and evaluation-based questions (tracing maximal munch splits and NFA transitions).
2026, 2023, 2011
Introduction of error localization across phases using MSQ format and token-counting using NAT format.
2026
Easy items test theoretical models (FSA), symbol table lifecycle, standard phase matching, or straightforward error identification. Medium items test edge cases in token segmentation under greedy scanning (maximal munch) involving adjacent alphanumeric strings or recognizing precise NFA state transitions.