SlideServe
Menu
Préférences
© SlideServe · v2026

Regular Grammars

kenneth-roach avatar
15 diapositives · 320 Views · Oct 31, 2014

Regular Grammars. Reading: 3.3. What we know so far…. FSA = Regular Language Regular Expression describes a Regular Language Every Regular Language has a Regular Expression Now, what about grammars?. Right Linear Grammars.

Regular Grammars - slide 1
01 / 15Regular Grammars
1 / 17

Télécharger la présentation

Regular 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. Regular Grammars Reading: 3.3

  2. What we know so far… • FSA = Regular Language • Regular Expression describes a Regular Language • Every Regular Language has a Regular Expression • Now, what about grammars?

  3. Right Linear Grammars • Right-linear: at most one variable on the right side of the production, must be the right-most symbol. A -> xBA -> x x is any string of terminals.

  4. Left Linear Grammars • Left-linear: at most one variable on the right side of the production, must be the left-most symbol. A -> BxA -> x x is any string of terminals.

  5. Regular Grammars • A grammar is regular if it is either left- or right-linear. • A linear grammar may have a mix of left and right productions. Its only restriction is that there is at most one symbol on the right. • All regular grammars are linear, but not all linear grammars are regular!

  6. Prove: All right-linear grammars describe regular languages • Idea: Find a way to convert any right-linear grammar into a FSA. • Terminals before a non-terminal represent arcs • Non-terminals represent non-final states. • Terminals without non-terminals following represent final states.

  7. Reg Grammar to NFA Step 1: Start variable is the initial node. S -> aD D -> abS D -> b S

  8. Reg Grammar to NFA Step 2: Each rule ending in a non-terminal is a chain of arcs followed by a non-final node. S -> aD D -> abS D -> b a D S

  9. Reg Grammar to NFA Step 2: Each rule ending in a non-terminal is a chain of arcs followed by a non-final node. S -> aD D -> abS D -> b a D S b a

  10. Reg Grammar to NFA Step 3: Each rule ending in a terminal leads to a final state. S -> aD D -> abS D -> b b a D S b a

  11. Example: Convert to a FSA • S -> aBS -> bSS -> λB -> aSB -> bB

  12. Does every regular language have a regular grammar that describes it? • Yes! Reverse the algorithm for constructing the FSA from the grammar • Every rule in δis a line in the grammar.

  13. Write a regular grammar

  14. Regular Language Wrap-up Regular expressions DFA or NFA Regular grammar

  15. Examples: • Find the grammar for the expression: aab*a • Find the regular expression for: S -> abS | bA A -> aA | b