Topic
Syntax Analyzer
Complier Phases
What is Syntax
The arrangement of words and phrases to create meaningful sentences.
 “He wrote the program”. The arrangement of the sentence can be described using
grammar syntax of English language.
Syntax Analyzer
The parser checks the stream of words (tokens) and their parts of speech for
grammatical correctness. It determines if the input is syntactically well formed.
Syntax analyzing is also called Parsing and the phase called Parser.
The Parser
Has grammar use to check the
structure of tokens
Syntax in Programming
The analogy can be carried over to syntax of sentences in a programming language.
For example, an if-statement has the syntax.
Continue…
The parser ensures that sentences of a programming language that make up a
program abide by the syntax of the language. If there are errors, the parser will detect
them and reports them accordingly.
Grammar
A grammar is a powerful tool for describing and analyzing languages. It is a set of
rules by which valid sentences in a language are constructed. Here’s a trivial
example of English grammar
Subject, verb-phrases, adverb, verb, object
This is a university.
Computers run the world.
I never tell lies
Basics of CFG grammar
production a grammar rule that describes how to replace/exchange symbols.
nonterminal a grammar symbol that can be replaced/expanded to a sequence of
symbols.
terminal these are the symbols in a grammar that cannot be replaced by anything else.
start symbol a grammar has a single nonterminal (the start symbol) from which all
sentences derive.
derivation a sequence of applications of the rules of a grammar that produces a finished
string of terminals.
Most left and Right Derivation
If one statement can be derived by both left most derivative and right most derivative
from a given production rule called Ambiguous grammar.
Any Question

Syntax analyzer

  • 1.
  • 2.
  • 3.
    What is Syntax Thearrangement of words and phrases to create meaningful sentences.  “He wrote the program”. The arrangement of the sentence can be described using grammar syntax of English language.
  • 4.
    Syntax Analyzer The parserchecks the stream of words (tokens) and their parts of speech for grammatical correctness. It determines if the input is syntactically well formed. Syntax analyzing is also called Parsing and the phase called Parser. The Parser Has grammar use to check the structure of tokens
  • 5.
    Syntax in Programming Theanalogy can be carried over to syntax of sentences in a programming language. For example, an if-statement has the syntax.
  • 6.
    Continue… The parser ensuresthat sentences of a programming language that make up a program abide by the syntax of the language. If there are errors, the parser will detect them and reports them accordingly.
  • 7.
    Grammar A grammar isa powerful tool for describing and analyzing languages. It is a set of rules by which valid sentences in a language are constructed. Here’s a trivial example of English grammar Subject, verb-phrases, adverb, verb, object This is a university. Computers run the world. I never tell lies
  • 8.
    Basics of CFGgrammar production a grammar rule that describes how to replace/exchange symbols. nonterminal a grammar symbol that can be replaced/expanded to a sequence of symbols. terminal these are the symbols in a grammar that cannot be replaced by anything else. start symbol a grammar has a single nonterminal (the start symbol) from which all sentences derive. derivation a sequence of applications of the rules of a grammar that produces a finished string of terminals.
  • 14.
    Most left andRight Derivation If one statement can be derived by both left most derivative and right most derivative from a given production rule called Ambiguous grammar.
  • 15.