← 🔤 Lexical Analysis
Subtopic 6 of 6

2.6Symbol table and lexical errors

The lexer enters identifiers into the symbol table and returns a pointer as the token attribute. On an illegal character it reports the error with line number and recovers (panic mode: skip characters).

Lexer-
Symbol table(empty)
Token returned-
Error handler-
  • Source: int count; Lexer reads the identifier "count"
  • Lookup: not in the table yet, so INSERT an entry (type filled in later)
  • Return the token <id, pointer to entry #1>
  • Later "count = 3;": lookup finds #1, same pointer returned
  • Illegal character "@": report "line 7: illegal character"
  • Panic-mode recovery: skip the bad character and continue scanning

Previous year questions: Lexical Analysis (2)

PYQs are grouped by topic, so this is the full set for Lexical Analysis; try the ones that match this subtopic. Open all 2 on the topic page.