Lecture 11 Notes

This is possible though relatively unlikely in this

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: , or as a lexical class, an error will be reported); strings are literal strings.     ¢¦ ¥    '   Important: The parser must be able to figure out which production to use knowing only (1) what non-terminal it’s looking for and (2) the first symbol (token) of the string being parsed. Grammars in this form are called LL(1) grammars (SLLGEN stands for Scheme LL(1) parser GENerator). This will be good enough for our purposes. SLLGEN will warn you if your grammar does not meet this restriction. 23  ©   ¡   ¢ ¤ ¢  © The production name is a symbol which becomes the variant of the . ’s and ¨" © ¡ © $#!¢¢¨ ¦¤ §¥£ ¡ ¢ 2.5.5 ’s §¥£¡ ¨¦¤¤ An is a Kleene star in the grammar: it matches an abitrary number of repetitions of its entry. Example: Change our grammar to say ¦  ¥  ¦  ¦  ¥  #  ¤  ©  ¥   ¥  #    © § ¥¦£¤¤ ¡ ¢ ¥ ¥ ¡ ## ¡ ¤¨¥$¦ §  #  ¦  "§  # £ ¢     © §¢ ¢  ¥    ¢ ¢  ¡ ¦ ¡¡ §¦ ¢¢¡ This makes a compound statement a sequence of (an arbitrary number of) semicolonterminated statements. Such a statement might be represented by a diagram like begin <statement> ; end §¥£¡ ¨¦¤¤ This generates a single field in the AST, which will contain a list of the data for the thing inside the . § £¡ ¨¥ ¤¤ 24 25 has 1 data field, which contains a list of the statements ¦¥¦¥§¦ ¥ ¦ ¦¥¦ ¤ £ ¡ ¦§ ¥¦ ¦§  ¦   ¦ ¤ ¨¢   ¡  © ¡¥  % ¢  ¦ ¤ ¨¢   ¡  ©  ¡¥  % ¢  ¦ ¤ ¨¢   ¡  ©  ¡¥  % ¢  ¥  § ¥¢  ¤ ¤ £ ¡ ¦ ¡ ## ¡  ¥¦ ¤¨¥$¦ ¦ ¢  ' % ¥ ¥ ¥  ¥ § ' ¦§  ¤ ¥¢ ¢ %  ¤ # # # # ¤ ¥¢ The inside the begin-end.   ¥  #    ©  ¥  §  §   #    ©  ¤  ¦© ¥©    ©  ¤  ¦© ¥©    ©  ¤  © © ¥    ©  ¥  §   ¥  £ %  ¢    ¢   ¢    §  ¢ # ¡ © ¤  ¡© ¡© ¡©    ¢ ¢ ¢ ¢ ¡  ©  ¢ ¥ §© ¢ ¢    ¡ ¤© ¡¤   ¥  ¡  © ¦ ¤ ¨# ¢ ¥   ¦¢© ¢ ¡ © ¢  ¥ ¥©  ¥     ¢ ¢   Here’s another example: © ¦¦ ¤ ¥¥¦ ¥ §  ¦©  ¡     ¦ # © ©   % % ¢ ¦ ¥ §  ¦©  ¡   ¦  ¦ # © ©    ¤ % % ¢  ¦ # "©   % ¢ ¦ ¥¦ ¤  ¨£ # ©  ¦ ¤ ¥ ¡ § '  % ¢  ¦ ¤ ¥ ¡ % ¢ © ¤ ¥ § ¦©  ¡  %  © ¥ § ¦©  ¡  %      ¤¦ ¥     '   ¢ ©¦©  ¡%  ¥  #    ©  ¤ ¦© ¢  ¥ © ¤  § £ # ©   ¥  #    ©  ¤ ¦© ¢  ¥ © '  ¥  #    ©  ¤  ¦© ¢  ¥©   ¥  #    ©   © ¦¤¢ £¡¢   ¥ #   ¢  ¦©  ¡     ¥  #    © ¦¤¢ ©    % ¢ £¡¢   ¥  #    © ¦¤¤ ¡¢  ¢  ©¢  ¥  #    ©   ¥  §  §  ¢  # ¢   ¥  #    ©  ¥  §  §  ¢  # ¤  ¥  #    ©   ¥  #    ©       ¤¦ ¥    ¢ '        ¤¦ ¥   ¤ § ¢ © ¢ ¥   ¦¦© ¢  ' ¤ ¤ © ©...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online