SlideServe
Menu
Préférences
© SlideServe · v2026

Grammars

williechase avatar
9 diapositives · 151 Views · Jan 03, 2020

Learn about grammars, derivations, and language construction in programming. Explore examples and concepts to understand the structure and formation of languages.

Grammars - slide 1
01 / 9Grammars
1 / 17

Télécharger la présentation

Grammars
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Grammars Module 03.2COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez

  2. We’ll Cover Grammars Derivations grammars

  3. Goal: Provide a means for describing (infinite) languages finitely. How: Define a subgraph (Σ*, →*) of (Σ*, ·). Define a start node S. Nodes reachable from S are in the language. grammars

  4. Example: Σ = {a, b} L = {anbn / n > 0} grammars a aaa a aaba a aa b aab b b a a ab aabb ε a ba bbaa a b a b bba b bb b bbab b bbb

  5. Definition: Given a vocabulary V, a production is a pair (u, v)  V* x V*, denoted u → v. u is called the left-part; v is called the right-part. Definition: Given a finite set of productions P  V* x V* the relation => (derives) is defined such that , β, u, v  V* , uβ => vβ iff u → v  P is a production. grammars

  6. Grammars (example) Productions: Sentence → NP VP NP → N NP → Adj NP N → boy N → girl Adj → the Adj → tall Adj → jealous VP → V NP V → hit V → bit Derivation: Sentence => NP VP => Adj NP VP => the NP VP => the Adj NP VP => the jealous NP VP => the jealous N VP => the jealous girl VP => the jealous girl V NP => the jealous girl hit NP => the jealous girl hit Adj NP => the jealous girl hit the NP => the jealous girl hit the N => the jealous girl hit the boy Note: English is much too complicated for this.

  7. Definition: A grammar is a 4-tuple G = (Φ, Σ, P, S), where Φ is a finite set of nonterminals, Σ is a finite set of terminals, V = Φ U Σ is the grammar’s vocabulary, S  Φ is called the start or goal symbol, and P  V* x V* is a finite set of productions. Example: Grammar for {anbn / n > 0}: G = (Φ, Σ, P, S), with Informally, Φ = {S}, Σ = {a, b}, S → aSb and P = { (S,aSb), (S,ε) } S → grammars

  8. Grammar: S → aSb Language: {anbn / n > 0} S → Derivations: S => aSb => aaSbb => aaaSbbb => aaaaSbbbb =>… ε ab aabb aaabbb aaaabbbb Normally, grammars are given by simply listing the productions. grammars => => => => =>

  9. Defined: Grammar (4-tuple) Informal grammar List of productions Derivation Grammars - Summary