Todos los libros

Profesional

Apps Acerca de Coach Iniciar sesión Empezar a leer

Computer Science · Glosario

¿Qué es Maximal munch, priority rule?

También llamado: maximal munch · priority rule

Definition 1.7 University Computer Science — Year 3 · Capítulo 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).
Leer en el capítulo →