BookRags.com Literature Guides Literature
Guides
Criticism & Essays Criticism &
Essays
Questions & Answers Questions &
Answers
Lesson Plans Lesson
Plans
My Bibliography Periodic Table U.S. Presidents Shakespeare Sonnet Shake-Up
Research Anything:        
History | Encyclopedias | Films | News | Create a Bibliography | More... Login | Register | Help

Scannerless parsing

Print-Friendly
About 1 pages (322 words)

Bookmark and Share Questions on this topic? Just ask!

Lexerless parsing (also called "scannerless parsing") refers to the use of a single formalism to express both the lexical and context-free syntax used to parse a language.

Contents

Advantages

  • Only a single metasyntax is required
  • Non-regular lexical structure is handled easily
  • "Token classification" is not required (eliminating the need for "the lexer hack")
  • A clear lexer-parser distinction is not required; languages without one are handled easily (TeX, most wiki grammars, Makefiles)
  • Grammars are compositional (can be merged without human intervention) [1]
  • No "keywordification" -- keywords (such as "while" in C) can be used as identifiers anywhere that the keyword form would not be allowed

Required Extensions

Unfortunately, when parsed at the character level, most popular programming languages are no longer strictly context-free. Visser identified five key extensions to classical context-free syntax which handle almost all common non-context-free constructs arising in practice:

  • Follow restrictions, a limited form of "longest match"
  • Reject productions, a limited form of negative matching (as found in boolean grammars)
  • Preference attributes to handle the dangling else construct in C-like languages
  • Per-production transitions rather than per-nonterminal transitions in order to facilitate:
    • Associativity attributes, which prevent a self-reference in a particular production of a nonterminal from producing that same production
    • Precedence/priority rules, which prevent self-references in higher-precedence productions from producing lower-precedence productions

Implementations

  • dparser generates ANSI C code for lexerless GLR parsers
  • the SGLR component of ASF+SDF generates and interprets parse tables for lexerless grammars
  • SGLR is also a component of the Stratego/XT program transformation system
  • Spirit allows for both scannerless and scanner-based parsing

Related Material

Visser, E. (1997b). Scannerless generalized-LR parsing. Technical Report P9707, Programming Research Group, University of Amsterdam

  1. ^  since lexerless parsers handle the entire class of context-free languages, which is closed under composition.

View More Summaries on Scannerless parsing
 
Ask any question on Scannerless parsing and get it answered FAST!
Answer questions in BookRags Q&A and earn points toward
discounted or even FREE Study Guides and other BookRags products!
Learn more about BookRags Q&A
Copyrights
Scannerless parsing from Wíkipedia. ©2006 by Wíkipedia. Licensed under the GNU Free Documentation License. View a list of authors or edit this article.

Article Navigation
Join BookRagslearn moreJoin BookRags




About BookRags | Customer Service | Report an Error | Terms of Use | Privacy Policy