Alle boeken

Professioneel

Apps Over Coach Inloggen Begin met lezen

Computer Science · Begrippenlijst

Wat is Maximal munch, priority rule?

Ook bekend als: maximal munch · priority rule

Definition 1.7 University Computer Science — Year 3 · Hoofdstuk 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).
Lees in het hoofdstuk →