CSE322 LEFT & RIGHT LINEAR REGULAR GRAMMAR

Slides:



Advertisements
Similar presentations
Lecture 11 Context-Free Grammar. Definition A context-free grammar (CFG) G is a quadruple (V, Σ, R, S) where V: a set of non-terminal symbols Σ: a set.
Advertisements

1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
Grammars, constituency and order A grammar describes the legal strings of a language in terms of constituency and order. For example, a grammar for a fragment.
Costas Busch - RPI1 Grammars. Costas Busch - RPI2 Grammars Grammars express languages Example: the English language.
Courtesy Costas Busch - RPI
1 Grammars. 2 Grammars express languages Example: the English language.
1 Reverse of a Regular Language. 2 Theorem: The reverse of a regular language is a regular language Proof idea: Construct NFA that accepts : invert the.
Chapter 3: Formal Translation Models
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
Prof. Busch - LSU1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:
Prof. Busch - LSU1 Context-Free Languages. Prof. Busch - LSU2 Regular Languages Context-Free Languages.
Context-free Grammars
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
Fall 2005Costas Busch - RPI1 Context-Free Languages.
Fall 2003Costas Busch - RPI1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:
Context-Free Languages Hinrich Schütze CIS, LMU, Slides based on RPI CSCI 2400 Thanks to Costas Busch.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 5 Mälardalen University 2005.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
Languages & Grammars. Grammars  A set of rules which govern the structure of a language Fritz Fritz The dog The dog ate ate left left.
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
Grammars A grammar is a 4-tuple G = (V, T, P, S) where 1)V is a set of nonterminal symbols (also called variables or syntactic categories) 2)T is a finite.
Three Basic Concepts Languages Grammars Automata.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
Regular Grammars Reading: 3.3. What we know so far…  FSA = Regular Language  Regular Expression describes a Regular Language  Every Regular Language.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2007.
How YACC is constructed. How Yacc works To construct a parsing machine for arithmetic expressions, a special case considered to simplify the account of.
Costas Busch - LSU1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:
CSE 202 – Formal Languages and Automata Theory 1 REGULAR EXPRESSION.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2006.
Akram Salah ISSR Basic Concepts Languages Grammar Automata (Automaton)
Chapter 3 – Describing Syntax CSCE 343. Syntax vs. Semantics Syntax: The form or structure of the expressions, statements, and program units. Semantics:
1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:
5. Context-Free Grammars and Languages
Chapter 3 – Describing Syntax
Grammars.
CONTEXT-FREE LANGUAGES
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
Context-Free Languages
Parsing and Parser Parsing methods: top-down & bottom-up
Fall Compiler Principles Context-free Grammars Refresher
Chapter 3 – Describing Syntax
Concepts of Programming Languages
Recap lecture 33 Example of trees, Polish Notation, examples, Ambiguous CFG, example,
Linear Bounded Automata LBAs
NPDAs Accept Context-Free Languages
Context free grammar.
CS314 – Section 5 Recitation 3
CSE322 The Chomsky Hierarchy
Regular Grammar.
5. Context-Free Grammars and Languages
Context-Free Grammars (CFG’s)
Thinking about grammars
CS21 Decidability and Tractability
Programming Languages
Pumping Lemma for Context-free Languages
Linear Algebra Lecture 3.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Theory of Computation Lecture #
Fall Compiler Principles Context-free Grammars Refresher
Plan for Lecture Review code and trace output
Compiler Construction
Applications of Regular Closure
Thinking about grammars
Context Free Grammars-II
The Chomsky Hierarchy Costas Busch - LSU.
Context-Free Languages
Presentation transcript:

CSE322 LEFT & RIGHT LINEAR REGULAR GRAMMAR Lecture #18

Grammars

Grammars Grammars express languages Example: the English language

A derivation of “the boy walks”:

A derivation of “a dog runs”:

Language of the grammar: L = { “a boy runs”, “a boy walks”, “the boy runs”, “the boy walks”, “a dog runs”, “a dog walks”, “the dog runs”, “the dog walks” }

Notation Variable or Non-terminal Terminal Production rule

Another Example Grammar: Derivation of sentence :

Grammar: Derivation of sentence :

Other derivations:

Language of the grammar

More Notation Grammar Set of variables Set of terminal symbols Start variable Set of Production rules

Example Grammar :

More Notation Sentential Form: A sentence that contains variables and terminals Example: Sentential Forms sentence

We write: Instead of:

In general we write: If:

By default:

Example Grammar Derivations

Example Grammar Derivations

Another Grammar Example Derivations:

More Derivations

Language of a Grammar For a grammar with start variable : String of terminals

Example For grammar : Since:

A Convenient Notation

Linear Grammars

Linear Grammars Grammars with at most one variable at the right side of a production Examples:

A Non-Linear Grammar Grammar :

Another Linear Grammar

Right-Linear Grammars All productions have form: Example: or

Left-Linear Grammars All productions have form: Example: or

Regular Grammars

Regular Grammars A regular grammar is any right-linear or left-linear grammar Examples:

Observation Regular grammars generate regular languages Examples:

Regular Grammars Generate Regular Languages

Theorem Languages Generated by Regular Grammars Regular Languages

Theorem - Part 1 Languages Generated by Regular Languages Regular Grammars Regular Languages Any regular grammar generates a regular language

Theorem - Part 2 Languages Generated by Regular Languages Regular Grammars Regular Languages Any regular language is generated by a regular grammar