SlideShare a Scribd company logo
1 of 19
Describing Syntax
Lesson 6
MANOLO L. GIRON
RMTU
Structure of Programming Language
Syntax
• Is the form of its expressions, statements, and program units.
For example the syntax of a Java while statement is
• while (boolean_expr) statement
Structure of Programming Language
Semantics
• Is the meaning of those expressions, statements, and program
units.
For example the syntax of a Java while statement is
• while (boolean_expr) statement
• The semantics of this statement form is that when the current value of the Boolean
expression is true, the embedded statement is executed. Otherwise, control
continues after the while construct. Then control implicitly returns to the Boolean
expression to repeat the process.
Structure of Programming Language
• Sentences or statement. The strings of a language
Example
index = 2 * count + 17
• Lexemes. Small units.
• Token. a category of its lexemes.
Structure of Programming Language
Example statement or sentence
index = 2 * count + 17
Lexemes Tokens
Index identifier
= equal_sign
2 int_literal
* mult_op
Count identifier
+ plus_op
17 int_literal
; semicolon
Structure of Programming Language
Formal Methods of Describing Syntax
• Metalanguage. is a language that is used to describe another language.
• BNF(Backus-Naur Form) is a metalanguage for programming languages.
Example
A simple Java assignment statement.
The actual definition of <assign> can be given by;
<assign> →<var> =<expression>
Structure of Programming Language
<assign> →<var> =<expression>
• (LHS) The text on the left side of the arrow.
• (RHS) consists of some mixture of tokens, lexemes, and references to other
abstractions.
Structure of Programming Language
• The abstractions in a BNF description, or grammar, are often called
nonterminal symbols, or simply nonterminals.
• The lexemes and tokens of the rules are called terminal symbols, or simply
terminals.
• A BNF description, or grammar, is a collection of rules.
Structure of Programming Language
• Nonterminal symbols can have two or more distinct definitions, representing
two or more possible syntactic forms in the language.
• Multiple definitions can be written as a single rule, with the different definitions
separated by the symbol|, meaning logical OR.
• Java if statement can be described with the rules;
• <if_stmt> → if (<logic_expr> ) <stmt>
• <if_stmt> → if (<logic_expr> )<stmt> else<stmt>
• or with the rule
• <if_stmt> → if (<logic_expr> )<stmt>
|if (<logic_expr> )<stmt> else<stmt>
In these rules, <stmt> represents either a single statement or a compound
statement.
Structure of Programming Language
Describing Lists
• Variable-length lists in mathematics are often written using an ellipsis (. . .);
• BNF does not include the ellipsis, so an alternative method is required for
describing lists of syntactic elements in programming languages.
• For BNF, the alternative is recursion.
• A rule is recursive if its LHS appears in its RHS. The following rules illustrate how
recursion is used to describe lists:
• <ident_list> →identifier
|identifier, <ident_list>
• This defines <ident_list> as either a single token (identifier) or an identifier
followed by a comma and another instance of <ident_list>.
Structure of Programming Language
Grammars and Derivations
• A grammar is a generative device for defining languages.
• The sentences of the language are generated through a sequence of
applications of the rules, beginning with a special nonterminal of the
grammar called the start symbol.
• This sequence of rule applications is called a derivation.
Structure of Programming Language
EXAMPLE
• A Grammar for a Small Language
<program> → begin<stmt_list> end
<stmt_list> →<stmt>
|<stmt> ;<stmt_list>
<stmt> →<var> =<expression>
<var> → A | B | C
<expression> →<var> +<var>
|<var> –<var>
|<var>
Structure of Programming Language
Derivations
• In this derivation, the replaced nonterminal is always the leftmost
nonterminal in the previous sentential form.
• The derivation continues until the sentential form contains no non terminals.
• That sentential form, consisting of only terminals, or lexemes, is the
generated sentence.
Structure of Programming Language
A derivation of a program in this language follows:
<program> => begin<stmt_list> end
=> begin <stmt> ;<stmt_list> end
=> begin <var> =<expression> ;<stmt_list> end
=> begin A =<expression> ;<stmt_list> end
=> begin A =<var> +<var> ;<stmt_list> end
=> begin A = B +<var> ;<stmt_list> end
=> begin A = B + C ;<stmt_list> end
=> begin A = B + C ;<stmt> end
=> begin A = B + C ;<var> =<expression> end
=> begin A = B + C ; B =<expression> end
=> begin A = B + C ; B =<var> end
=> begin A = B + C ; B = C end
Structure of Programming Language
EXAMPLE
• A Grammar for Simple Assignment Statements
<assign> →<id>= <expr>
<id> → A | B | C
<expr> →<id>+ <expr>
|<id>* <expr>
| ( <expr>)
|<id>
Structure of Programming Language
For example, the statement
A = B * ( A + C )
The leftmost derivation:
<assign> =><id> =<expr>
=> A = <expr>
=> A = <id> *<expr>
=> A = B * <expr>
=> A = B * ( <expr>)
=> A = B * ( <id> +<expr>)
=> A = B * ( A + <expr>)
=> A = B * ( A + <id>)
=> A = B * ( A + C )
Structure of Programming Language
Parse Trees
• One of the most attractive features of grammars is that they naturally
describe the hierarchical syntactic structure of the sentences of the languages
they define.
• These hierarchical structures are called parse trees.
Structure of Programming Language
A parse tree for the simple statement
A = B * (A + C)
Structure of Programming Language
REFERENCES
• CONCEPTS OF
PROGRAMMING LANGUAGES
TENTH EDITION
ROBERT W. SEBESTA
Structure of Programming Language

More Related Content

What's hot

System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
Manoj Patil
 
Software Requirements in Software Engineering SE5
Software Requirements in Software Engineering SE5Software Requirements in Software Engineering SE5
Software Requirements in Software Engineering SE5
koolkampus
 

What's hot (20)

Introduction Programming Languages
Introduction Programming LanguagesIntroduction Programming Languages
Introduction Programming Languages
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
 
Software Engineering concept
Software Engineering concept Software Engineering concept
Software Engineering concept
 
Language processors
Language processorsLanguage processors
Language processors
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?
 
Machine Translation
Machine TranslationMachine Translation
Machine Translation
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
 
Software Requirements in Software Engineering SE5
Software Requirements in Software Engineering SE5Software Requirements in Software Engineering SE5
Software Requirements in Software Engineering SE5
 
Introduction to Programming Languages
Introduction to Programming LanguagesIntroduction to Programming Languages
Introduction to Programming Languages
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 
Programming paradigm
Programming paradigmProgramming paradigm
Programming paradigm
 
Software engineering rogers pressman chapter 7
Software engineering rogers pressman chapter 7Software engineering rogers pressman chapter 7
Software engineering rogers pressman chapter 7
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler Design
 
Assembly language
Assembly languageAssembly language
Assembly language
 
Generations Of Programming Languages
Generations Of Programming LanguagesGenerations Of Programming Languages
Generations Of Programming Languages
 
Linker and Loader
Linker and Loader Linker and Loader
Linker and Loader
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
5 Names, bindings,Typechecking and Scopes
5 Names, bindings,Typechecking and Scopes5 Names, bindings,Typechecking and Scopes
5 Names, bindings,Typechecking and Scopes
 
software cost factor
software cost factorsoftware cost factor
software cost factor
 

Similar to 6. describing syntax and semantics

Chapter Three(1)
Chapter Three(1)Chapter Three(1)
Chapter Three(1)
bolovv
 
match the following attributes to the parts of a compilerstrips ou.pdf
match the following attributes to the parts of a compilerstrips ou.pdfmatch the following attributes to the parts of a compilerstrips ou.pdf
match the following attributes to the parts of a compilerstrips ou.pdf
arpitaeron555
 
Unit-1 PPL PPTvvhvmmmmmmmmmmmmmmmmmmmmmm
Unit-1 PPL PPTvvhvmmmmmmmmmmmmmmmmmmmmmmUnit-1 PPL PPTvvhvmmmmmmmmmmmmmmmmmmmmmm
Unit-1 PPL PPTvvhvmmmmmmmmmmmmmmmmmmmmmm
DhruvKushwaha12
 
System Programming Unit III
System Programming Unit IIISystem Programming Unit III
System Programming Unit III
Manoj Patil
 

Similar to 6. describing syntax and semantics (20)

CH 2.pptx
CH 2.pptxCH 2.pptx
CH 2.pptx
 
8074448.ppt
8074448.ppt8074448.ppt
8074448.ppt
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
CS-4337_03_Chapter3- syntax and semantics.pdf
CS-4337_03_Chapter3- syntax and semantics.pdfCS-4337_03_Chapter3- syntax and semantics.pdf
CS-4337_03_Chapter3- syntax and semantics.pdf
 
Chapter Three(1)
Chapter Three(1)Chapter Three(1)
Chapter Three(1)
 
Computational model language and grammar bnf
Computational model language and grammar bnfComputational model language and grammar bnf
Computational model language and grammar bnf
 
match the following attributes to the parts of a compilerstrips ou.pdf
match the following attributes to the parts of a compilerstrips ou.pdfmatch the following attributes to the parts of a compilerstrips ou.pdf
match the following attributes to the parts of a compilerstrips ou.pdf
 
Syntax
SyntaxSyntax
Syntax
 
Unit-1 PPL PPTvvhvmmmmmmmmmmmmmmmmmmmmmm
Unit-1 PPL PPTvvhvmmmmmmmmmmmmmmmmmmmmmmUnit-1 PPL PPTvvhvmmmmmmmmmmmmmmmmmmmmmm
Unit-1 PPL PPTvvhvmmmmmmmmmmmmmmmmmmmmmm
 
3a. Context Free Grammar.pdf
3a. Context Free Grammar.pdf3a. Context Free Grammar.pdf
3a. Context Free Grammar.pdf
 
UNIT 1 part II.ppt
UNIT 1 part II.pptUNIT 1 part II.ppt
UNIT 1 part II.ppt
 
Lexical1
Lexical1Lexical1
Lexical1
 
sabesta3.ppt
sabesta3.pptsabesta3.ppt
sabesta3.ppt
 
System Programming Unit III
System Programming Unit IIISystem Programming Unit III
System Programming Unit III
 
Plc part 2
Plc  part 2Plc  part 2
Plc part 2
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
role of lexical anaysis
role of lexical anaysisrole of lexical anaysis
role of lexical anaysis
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
Parsing
ParsingParsing
Parsing
 

More from Zambales National High School

More from Zambales National High School (20)

8. digital integrated circuit
8. digital integrated circuit8. digital integrated circuit
8. digital integrated circuit
 
7. transformer and diode
7. transformer and diode7. transformer and diode
7. transformer and diode
 
5. resistor and capacitor application
5. resistor and capacitor application5. resistor and capacitor application
5. resistor and capacitor application
 
6. transistor
6. transistor6. transistor
6. transistor
 
4. resistor and capacitor
4. resistor and capacitor4. resistor and capacitor
4. resistor and capacitor
 
2. Basic Electronics Circuit
2. Basic Electronics Circuit2. Basic Electronics Circuit
2. Basic Electronics Circuit
 
3. basic electrical and electronic symbol
3. basic electrical and electronic symbol3. basic electrical and electronic symbol
3. basic electrical and electronic symbol
 
11. abstraction and capsulation
11. abstraction and capsulation11. abstraction and capsulation
11. abstraction and capsulation
 
10. sub program
10. sub program10. sub program
10. sub program
 
9. control statement
9. control statement9. control statement
9. control statement
 
8. data types
8. data types8. data types
8. data types
 
7. name binding and scopes
7. name binding and scopes7. name binding and scopes
7. name binding and scopes
 
5. evolution
5. evolution5. evolution
5. evolution
 
4. processor
4. processor4. processor
4. processor
 
3. criteria
3. criteria3. criteria
3. criteria
 
2. pl domain
2. pl domain2. pl domain
2. pl domain
 
1. reason why study spl
1. reason why study spl1. reason why study spl
1. reason why study spl
 
18. the components of the system unit
18. the components of the system unit18. the components of the system unit
18. the components of the system unit
 
17. software for home, personal, and educational
17. software for home, personal, and educational17. software for home, personal, and educational
17. software for home, personal, and educational
 
16. graphics and multimedia software
16. graphics and multimedia software16. graphics and multimedia software
16. graphics and multimedia software
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 

Recently uploaded (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 

6. describing syntax and semantics

  • 1. Describing Syntax Lesson 6 MANOLO L. GIRON RMTU Structure of Programming Language
  • 2. Syntax • Is the form of its expressions, statements, and program units. For example the syntax of a Java while statement is • while (boolean_expr) statement Structure of Programming Language
  • 3. Semantics • Is the meaning of those expressions, statements, and program units. For example the syntax of a Java while statement is • while (boolean_expr) statement • The semantics of this statement form is that when the current value of the Boolean expression is true, the embedded statement is executed. Otherwise, control continues after the while construct. Then control implicitly returns to the Boolean expression to repeat the process. Structure of Programming Language
  • 4. • Sentences or statement. The strings of a language Example index = 2 * count + 17 • Lexemes. Small units. • Token. a category of its lexemes. Structure of Programming Language
  • 5. Example statement or sentence index = 2 * count + 17 Lexemes Tokens Index identifier = equal_sign 2 int_literal * mult_op Count identifier + plus_op 17 int_literal ; semicolon Structure of Programming Language
  • 6. Formal Methods of Describing Syntax • Metalanguage. is a language that is used to describe another language. • BNF(Backus-Naur Form) is a metalanguage for programming languages. Example A simple Java assignment statement. The actual definition of <assign> can be given by; <assign> →<var> =<expression> Structure of Programming Language
  • 7. <assign> →<var> =<expression> • (LHS) The text on the left side of the arrow. • (RHS) consists of some mixture of tokens, lexemes, and references to other abstractions. Structure of Programming Language
  • 8. • The abstractions in a BNF description, or grammar, are often called nonterminal symbols, or simply nonterminals. • The lexemes and tokens of the rules are called terminal symbols, or simply terminals. • A BNF description, or grammar, is a collection of rules. Structure of Programming Language
  • 9. • Nonterminal symbols can have two or more distinct definitions, representing two or more possible syntactic forms in the language. • Multiple definitions can be written as a single rule, with the different definitions separated by the symbol|, meaning logical OR. • Java if statement can be described with the rules; • <if_stmt> → if (<logic_expr> ) <stmt> • <if_stmt> → if (<logic_expr> )<stmt> else<stmt> • or with the rule • <if_stmt> → if (<logic_expr> )<stmt> |if (<logic_expr> )<stmt> else<stmt> In these rules, <stmt> represents either a single statement or a compound statement. Structure of Programming Language
  • 10. Describing Lists • Variable-length lists in mathematics are often written using an ellipsis (. . .); • BNF does not include the ellipsis, so an alternative method is required for describing lists of syntactic elements in programming languages. • For BNF, the alternative is recursion. • A rule is recursive if its LHS appears in its RHS. The following rules illustrate how recursion is used to describe lists: • <ident_list> →identifier |identifier, <ident_list> • This defines <ident_list> as either a single token (identifier) or an identifier followed by a comma and another instance of <ident_list>. Structure of Programming Language
  • 11. Grammars and Derivations • A grammar is a generative device for defining languages. • The sentences of the language are generated through a sequence of applications of the rules, beginning with a special nonterminal of the grammar called the start symbol. • This sequence of rule applications is called a derivation. Structure of Programming Language
  • 12. EXAMPLE • A Grammar for a Small Language <program> → begin<stmt_list> end <stmt_list> →<stmt> |<stmt> ;<stmt_list> <stmt> →<var> =<expression> <var> → A | B | C <expression> →<var> +<var> |<var> –<var> |<var> Structure of Programming Language
  • 13. Derivations • In this derivation, the replaced nonterminal is always the leftmost nonterminal in the previous sentential form. • The derivation continues until the sentential form contains no non terminals. • That sentential form, consisting of only terminals, or lexemes, is the generated sentence. Structure of Programming Language
  • 14. A derivation of a program in this language follows: <program> => begin<stmt_list> end => begin <stmt> ;<stmt_list> end => begin <var> =<expression> ;<stmt_list> end => begin A =<expression> ;<stmt_list> end => begin A =<var> +<var> ;<stmt_list> end => begin A = B +<var> ;<stmt_list> end => begin A = B + C ;<stmt_list> end => begin A = B + C ;<stmt> end => begin A = B + C ;<var> =<expression> end => begin A = B + C ; B =<expression> end => begin A = B + C ; B =<var> end => begin A = B + C ; B = C end Structure of Programming Language
  • 15. EXAMPLE • A Grammar for Simple Assignment Statements <assign> →<id>= <expr> <id> → A | B | C <expr> →<id>+ <expr> |<id>* <expr> | ( <expr>) |<id> Structure of Programming Language
  • 16. For example, the statement A = B * ( A + C ) The leftmost derivation: <assign> =><id> =<expr> => A = <expr> => A = <id> *<expr> => A = B * <expr> => A = B * ( <expr>) => A = B * ( <id> +<expr>) => A = B * ( A + <expr>) => A = B * ( A + <id>) => A = B * ( A + C ) Structure of Programming Language
  • 17. Parse Trees • One of the most attractive features of grammars is that they naturally describe the hierarchical syntactic structure of the sentences of the languages they define. • These hierarchical structures are called parse trees. Structure of Programming Language
  • 18. A parse tree for the simple statement A = B * (A + C) Structure of Programming Language
  • 19. REFERENCES • CONCEPTS OF PROGRAMMING LANGUAGES TENTH EDITION ROBERT W. SEBESTA Structure of Programming Language