Programming Language Syntax - Exam Notes
Programming Language Syntax - Exam Notes
1. Introduction to Syntax
● Syntax refers to the structure and rules governing valid program statements.
● It is essential for defining the correct form of a programming language.
● Key Components:
○ Alphabets: Characters allowed in a language.
○ Tokens: Smallest units of meaning (e.g., keywords, identifiers, operators).
○ Grammars: Rules defining how tokens combine to form valid constructs.
2. Lexical Analysis
●
5. Parsing Techniques
6. Ambiguity in Grammars
Example:
expr -> expr + expr | expr * expr | id
●
● Solution:
○ Define operator precedence & associativity explicitly.
○ Use transformations to remove ambiguity.