Global Information Lookup Global Information

LR parser information


In computer science, LR parsers are a type of bottom-up parser that analyse deterministic context-free languages in linear time.[1] There are several variants of LR parsers: SLR parsers, LALR parsers, canonical LR(1) parsers, minimal LR(1) parsers, and generalized LR parsers (GLR parsers). LR parsers can be generated by a parser generator from a formal grammar defining the syntax of the language to be parsed. They are widely used for the processing of computer languages.

An LR parser (left-to-right, rightmost derivation in reverse) reads input text from left to right without backing up (this is true for most parsers), and produces a rightmost derivation in reverse: it does a bottom-up parse – not a top-down LL parse or ad-hoc parse. The name "LR" is often followed by a numeric qualifier, as in "LR(1)" or sometimes "LR(k)". To avoid backtracking or guessing, the LR parser is allowed to peek ahead at k lookahead input symbols before deciding how to parse earlier symbols. Typically k is 1 and is not mentioned. The name "LR" is often preceded by other qualifiers, as in "SLR" and "LALR". The "LR(k)" notation for a grammar was suggested by Knuth to stand for "translatable from left to right with bound k."[1]

LR parsers are deterministic; they produce a single correct parse without guesswork or backtracking, in linear time. This is ideal for computer languages, but LR parsers are not suited for human languages which need more flexible but inevitably slower methods. Some methods which can parse arbitrary context-free languages (e.g., Cocke–Younger–Kasami, Earley, GLR) have worst-case performance of O(n3) time. Other methods which backtrack or yield multiple parses may even take exponential time when they guess badly.[2]

The above properties of L, R, and k are actually shared by all shift-reduce parsers, including precedence parsers. But by convention, the LR name stands for the form of parsing invented by Donald Knuth, and excludes the earlier, less powerful precedence methods (for example Operator-precedence parser).[1] LR parsers can handle a larger range of languages and grammars than precedence parsers or top-down LL parsing.[3] This is because the LR parser waits until it has seen an entire instance of some grammar pattern before committing to what it has found. An LL parser has to decide or guess what it is seeing much sooner, when it has only seen the leftmost input symbol of that pattern.

  1. ^ a b c Knuth, D. E. (July 1965). "On the translation of languages from left to right". Information and Control. 8 (6): 607–639. doi:10.1016/S0019-9958(65)90426-2.
  2. ^ Aho, Alfred V.; Ullman, Jeffrey D. (1972). The Theory of Parsing, Translation, and Compiling (Volume 1: Parsing.) (Repr. ed.). Englewood Cliffs, NJ: Prentice Hall. ISBN 978-0139145568.
  3. ^ Language theoretic comparison of LL and LR grammars

and 23 Related for: LR parser information

Request time (Page generated in 0.9682 seconds.)

LR parser

Last Update:

LR parsers are a type of bottom-up parser that analyse deterministic context-free languages in linear time. There are several variants of LR parsers:...

Word Count : 8128

Canonical LR parser

Last Update:

parsers[citation needed], is being offered by several parser generators. Like most parsers, the LR(1) parser is automatically generated by compiler-compilers...

Word Count : 2253

Simple LR parser

Last Update:

Simple LR or SLR parser is a type of LR parser with small parse tables and a relatively simple parser generator algorithm. As with other types of LR(1) parser...

Word Count : 825

LALR parser

Last Update:

grammar for a computer language. An LALR parser is a simplified version of a canonical LR parser. The LALR parser was invented by Frank DeRemer in his 1969...

Word Count : 1483

Parsing

Last Update:

Canonical LR parser LALR (look-ahead LR) parser Operator-precedence parser SLR (Simple LR) parser Simple precedence parser Packrat parser: a linear time...

Word Count : 4857

GLR parser

Last Update:

A GLR parser (generalized left-to-right rightmost derivation parser) is an extension of an LR parser algorithm to handle non-deterministic and ambiguous...

Word Count : 850

Comparison of parser generators

Last Update:

2023-11-30. "The Lezer Parser System". "Building a ShopifyQL Code Editor". Shopify. Retrieved 2023-12-06. "Sponsoring the Lezer parser system | Tines". www...

Word Count : 1106

Parsing expression grammar

Last Update:

some inputs, the depth of the parse tree can be proportional to the input size, so both an LR parser and a packrat parser will appear to have the same...

Word Count : 6426

Earley parser

Last Update:

In computer science, the Earley parser is an algorithm for parsing strings that belong to a given context-free language, though (depending on the variant)...

Word Count : 1997

LALR parser generator

Last Update:

lookahead LR parser (LALR) generator is a software tool that reads a context-free grammar (CFG) and creates an LALR parser which is capable of parsing files...

Word Count : 789

LL parser

Last Update:

computer science, an LL parser (Left-to-right, leftmost derivation) is a top-down parser for a restricted context-free language. It parses the input from Left...

Word Count : 4363

History of compiler construction

Last Update:

LR parser is a parser that reads input from Left to right (as it would appear if visually displayed) and produces a Rightmost derivation. The term LR(k)...

Word Count : 6356

LR

Last Update:

top-level domain for Liberia Little Rock, Arkansas, United States LR parser, a type of parser in computer science Lexical resource, a database consisting of...

Word Count : 220

LL grammar

Last Update:

parsed by an LL parser, which parses the input from Left to right, and constructs a Leftmost derivation of the sentence (hence LL, compared with LR parser...

Word Count : 1997

Dangling else

Last Update:

ambiguity: If the parser is produced by an SLR, LR(1) or LALR LR parser generator, the programmer will often rely on the generated parser feature of preferring...

Word Count : 1236

Recursive ascent parser

Last Update:

recursive ascent parsing is a technique for implementing an LR parser which uses mutually-recursive functions rather than tables. Thus, the parser is directly...

Word Count : 2004

SGLR

Last Update:

stands for Seminole Gulf Railway Scannerless Generalized LR Parser describes a Generalized LR parser without a separate Scanner aka. Lexical analysis Steeple...

Word Count : 57

SLR grammar

Last Update:

Simple LR parser. SLR grammars are a superset of all LR(0) grammars and a subset of all LALR(1) and LR(1) grammars. When processed by an SLR parser, an SLR...

Word Count : 684

Recursive descent parser

Last Update:

In computer science, a recursive descent parser is a kind of top-down parser built from a set of mutually recursive procedures (or a non-recursive equivalent)...

Word Count : 1119

GNU Bison

Last Update:

and %parse-param declarations. %{ /* * Parser.y file * To generate the parser run: "bison Parser.y" */ #include "Expression.h" #include "Parser.h" #include...

Word Count : 2306

SLR

Last Update:

algorithm Sending loudness rating for microphones Simple LR parser (Simple Left-to-right parser) Single-lens reflex camera See also: Digital single-lens...

Word Count : 146

List of algorithms

Last Update:

Canonical LR parser LALR (look-ahead LR) parser Operator-precedence parser SLR (Simple LR) parser Simple precedence parser Packrat parser: a linear time...

Word Count : 7843

Packrat parser

Last Update:

The Packrat parser is a type of parser that shares similarities with the recursive descent parser in its construction. However, it differs because it...

Word Count : 1860

PDF Search Engine © AllGlobal.net