Top-down parsing

A compiler parses input from a programming language to assembly language or an internal representation by matching the incoming symbols to Backus-Naur form production rules. An LL parser, also called a top-bottom parser or top-down parser, applies each production rule to the incoming symbols by working from the left-most symbol yielded on a production rule and then proceeding to the next production rule for each non-terminal symbol encountered. In this way the parsing starts on the Left of the result side (right side) of the production rule and evaluates non-terminals from the Left first and, thus, proceeds down the parse tree for each new non-terminal before continuing to the next symbol for a production rule.
e.g.

  • A->aBC
  • B->c|cd
  • C->df|eg

would match A->aB and attempt to match B->c|cd next. Then C->df|eg would be tried. As one may expect, some languages are more ambiguous than others. For a non-ambiguous language in which all productions for a non-terminal produce distinct strings: the string produced by one production will not start with the same symbol as the string produced by another production. A non-ambiguous language may be parsed by an LL(1) grammar where the (1) signifies the parser reads ahead one token at a time. For an ambiguous language to be parsed by an LL parser, the parser must lookahead >1 symbol, e.g. LL(3).
The common solution is to use an LR parser (a.k.a. bottom-up or shift-reduce parser).

See Also

Template:Compu-lang-stub

Navigation
  • Home Page (https://academickids.com/)
  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (https://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (https://academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (https://academickids.com/encyclopedia/index.php/Clipart)
  • Geography (https://academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (https:/academickids.com/encyclopedia/index.php/Countries)
    • Maps (https://academickids.com/encyclopedia/index.php/Maps)
    • Flags (https://academickids.com/encyclopedia/index.php/Flags)
    • Continents (https://academickids.com/encyclopedia/index.php/Continents)
  • History (https://academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (https://academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (https://academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (https://academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (https://academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (https://academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (https://academickids.com/encyclopedia/index.php/Timelines)
    • United States (https://academickids.com/encyclopedia/index.php/United_States)
    • Wars (https://academickids.com/encyclopedia/index.php/Wars)
    • World History (https://academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (https://academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (https://academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (https://academickids.com/encyclopedia/index.php/Reference)
  • Science (https://academickids.com/encyclopedia/index.php/Science)
    • Animals (https://academickids.com/encyclopedia/index.php/Animals)
    • Aviation (https://academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (https://academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (https://academickids.com/encyclopedia/index.php/Earth)
    • Inventions (https://academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (https://academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (https://academickids.com/encyclopedia/index.php/Plants)
    • Scientists (https://academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (https://academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (https://academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (https://academickids.com/encyclopedia/index.php/Economics)
    • Government (https://academickids.com/encyclopedia/index.php/Government)
    • Religion (https://academickids.com/encyclopedia/index.php/Religion)
    • Holidays (https://academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (https://academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (https://academickids.com/encyclopedia/index.php/Planets)
  • Sports (https://academickids.com/encyclopedia/index.php/Sports)
  • Timelines (https://academickids.com/encyclopedia/index.php/Timelines)
  • Weather (https://academickids.com/encyclopedia/index.php/Weather)
  • US States (https://academickids.com/encyclopedia/index.php/US_States)

Information

  • Contact Us (https://academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (https://classroomclipart.com)
Toolbox
Personal tools