csc402-ln003

csc402-ln003 - Pattern #1: Mapping Grammars to...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Pattern #1: Mapping Grammars to Recursive-Descent Recognizers Purpose: This translates a grammar to a recursive- descent recognizer that matches phrases and sentences in the language specified by the grammar. Implementation: Note, the techniques outlines here will not work for left-recursive rules, that is, rules of the form A : A B rules that refer to the non-terminal being defined by the rule with out consuming a terminal symbol. Pattern #1: Mapping Grammars to Recursive-Descent Recognizers Class Structure: Given a grammar G will construct a class for that grammar that contains the recognizer code and all of its auxiliary functions. Often this is done by extending some generic Parser class. public class G extend Parser { < token definition code > < auxiliary functions > < rule code > < startup code, refers to start symbol > } ! Pattern #1: Mapping Grammars to Recursive-Descent Recognizers Converting Tokens: If the language contains multi-character words or tokens then these...
View Full Document

This note was uploaded on 10/03/2011 for the course CSC 402 taught by Professor Staff during the Fall '09 term at Rhode Island.

Page1 / 17

csc402-ln003 - Pattern #1: Mapping Grammars to...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online