Start learning →

Which formalism is most commonly used to specify the LEXICAL structure of programming language tokens?

ATuring machines
BContext-free grammars
CRegular expressions
DPredicate logic
Answer & Solution
Correct answer: C. Regular expressions
1. Lexical structure is REGULAR: tokens like identifiers, numbers, keywords can be described by REGULAR EXPRESSIONS. 2. Regex → NFA → DFA. The DFA becomes the scanner table. 3. Tools like lex, flex, ANTLR use this exact pipeline. 4. Context-free grammars (option B) are used for SYNTAX (parser), not lexical analysis. Turing machines and predicate logic are far more powerful than needed for tokenisation. _Source: Bob Nystrom, "Crafting Interpreters", Ch 4.3 (Regular Languages and Expressions)._
Practise this question with Quill — GATE CSE →

Keep practising Compiler Design

Browse all Compiler Design questions for GATE CSE, or explore more Computer Science topics.

Start a Compiler Design lesson →
Related questions