Lecture 11 Notes

the symbol the characters in the buffer are converted

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview:  ¥ #  ¢ % ¢ ¢ ¡ ¡ ¡ ¡ £ § ¥©   ¥ #¢ © §      ¢ ¥  ¦ ¢  ¥¢ ¥¢ ¥¢  ¥    ¥¢ ¢ ¥£  ¥ §© ¢     ¢  #  ¢ ¥© ¡    ¥    § § #  ¨ Demo: here I’ve put in a module and opened it in DrScheme. generates a scanning procedure. You’ll probably only need it for testing. First argument is the lexical specification, second is the grammar (that’s empty here). ¡  ¦¥ ¥©  ¥   © ¦ ¥ ¡  # ¢ ¥   ¦¢© ¤ 2.4.4 Testing the scanner Don’t have to worry about keywords when writing a lexical specification: the parser-generator will add those automatically. ¦¥¦¥¦ ¡  £ # ¦  ¨£ # § ¦  ¦  ¥ ¦§¦      § ¦¤¤ ¥£¡ ¢ © ¦¥¦§¦      ¡  ¦ ¤ ¡ §  § £¡ ' ¢ ¨¥ ¤¤ ¢ ¡ ¤ ¥© ¦¥¦¥¦     ¥  ¨¥ ¢ ¨¦¢¤ § §¥£¡ ¦   ©  ¦ § ¤ ¥©     ¨ ¢    ¤  ¢ ¢  ¢  ¢ £¡¢  ¡     ¤  ¡  ¥ © £#  ¥ ¢  ¥   ¢ #§#§  ¢   £¡§¢ ¢ ¢  ¥    ¢ ¡  ¢ % ¤ In SLLGEN, scanners are specified by regular expressions, which are written as lists in Scheme. Here’s our example: SLLGEN is a package for generating scanners and parsers in Scheme. 2.4.3 Specifying scanners in SLLGEN 2.4.5 The SLLGEN scanner specification language ¦  §    § # © ¡ % ¢  © ¡ %  ¢  ¡    ¢ ¢   ©    ¡    ¥¥  ¢  ¥ ¢  ¡ ¢ § ¢ ¦£ ¥¤ ¦    ¢  ¢ § ¦ ¤ $% #"  ¤ !¥  ¤ © § ¦¥ §  ¦ ¤ ¢ § ¤§ ©¤ ¨ ¨! $ ¦ ¦ ¦©   ¦ ¦ ¦ ¦ § The second part of the specification is a sequence of regular expressions, because the top level of a regexp in a scanner is almost always a concatenation. Each regular expression in the sequence follows the obvious Scheme-like syntax: we use and for union and concatenation, and for Kleene star. § £¡ ¨¥ ¤¤    ¥ §  ¡§ The base cases for the regular expressions are Scheme strings, negation (of a character, not a string– see our example), and four predefined testers: (matches any letter), (matches any digit), (matches any Scheme whites(matches any character). pace character...
View Full Document

This document was uploaded on 03/17/2014 for the course CSG 111 at Northeastern.

Ask a homework question - tutors are online