Tous les livres

Professionnel

Applis À propos Coach Connexion Commencer la lecture

Computer Science · Glossaire

Qu'est-ce que « Maximal munch, priority rule » ?

Aussi appelé : maximal munch · priority rule

Definition 1.7 University Computer Science — Year 3 · Chapitre 1 — Lexical Analysis

Maximal munch (or the longest match) is the rule that the next token is the longest prefix of the remaining input that belongs to some token class. The priority rule breaks the remaining ties: when that longest prefix belongs to several classes, the class of the rule written first wins.

Maximal munch on a4 with the rules a and a*b. Each scan reads to the end of the input hoping for a b (black arrow), then backs up to the end of the one-character token it had already accepted (red arrow, shaded token).
Maximal munch on a4a^4 with the rules a and a*b. Each scan reads to the end of the input hoping for a b (black arrow), then backs up to the end of the one-character token it had already accepted (red arrow, shaded token).
Lire dans le chapitre →