What is syntax in the context of programming languages?
Syntax is the structure of a language—the rules that describe how tokens can be combined to form valid phrases, expressions, and programs.
What is lexical structure?
Lexical structure is how characters form tokens like identifiers, keywords, literals, and operators.
What is the purpose of scanning?
Scanning groups characters into tokens and removes whitespace/comments.
What is the purpose of parsing?
Parsing checks token sequence against grammar and builds a parse tree or AST.
Difference between scanner and parser?
Scanner makes tokens; parser checks structure and builds syntax tree.
Common token categories?
Keywords, identifiers, literals, and special symbols.
What is a reserved word?
A keyword that cannot be used as an identifier.
What is a predefined identifier?
Identifier with built‑in meaning (library) but can technically be redefined.
Are true/false/null keywords in Java?
They are literals, not keywords.
Longest substring rule?
The scanner always chooses the longest sequence of characters that forms a valid token, rather than stopping early.
What are delimiters?
Whitespace/tabs/newlines separating tokens.
Indentation in Python vs C++/Java?
Python: syntactic; C++/Java: stylistic only.
What is a free‑format language?
Layout doesn’t affect syntax (Java, C++).
What is a fixed‑format language?
Column‑sensitive languages like old Fortran.
What defines tokens formally?
Regular expressions.
Basic reglar expression operations?
Concatenation, repetition, choice (|).
[a‑z] meaning?
Any lowercase letter a through z.
What does ? mean in regular expression?
Optional (0 or 1 occurrence).
What does . mean in regular expression?
. can be any type of character (excluding newline) that can be inserted into the expression
Meaning of (a|b)*c?
Any sequence of a/b ending with c.
What is a context‑free grammar?
Tells you how strings in the language can be built, using rules that replace nonterminal symbols with sequences of terminals and/or nonterminals.
What is Backus–Naur Form (BNF)?
BNF is a formal notation used to define a language’s grammar using nonterminals, terminals, and production rules.. Notation for grammars using ::= and |.
Terminals vs nonterminals?
Nonterminals define structure; terminals are actual tokens.
What is a production rule?
Replacement rule for a nonterminal.