Lecture 11 Notes

253 running

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: ¥ § ¦©  ¡     © % %  ¦  % ¦¥¦ ¤§£#'©   ¦  %    ¤¦ '   © ¥ §  ¦©  ¡  %  ¦¦ §¥¦ ¤ ¥ ¦¥¦ ¤  ¦¤¥§ ¤  ¥  #    ©  ¦ ¥¦ ¤  ¦¤ ¥  ¥  #  ¤    © §  ¦©  ¡  %  ¦ ¤  ¨# © §£ ' ¥  #    ©   ¥  #    ©  ©¦©  ¡   % ¥  #    ©  #    ©  #    ©      ©  ¥       '   ¢  ¢  # "© ¢  ¢ ¡¤ ¥ ¢  ¥    ¢ ©¡ ¢¢ © ¢¢ © ¥¤  ¦© ¢  ' §¨£ ¢  ©  ¢  ¦¤¤ ¢ ¡¢ © ¢ © ¢ # §  ¢  ¥    ¢ ©  ¥ ¥ # ©  £ #  £ # §  ¤¦ Example: Output of parser is a tree, called parse tree or abstract syntax tree (AST). Mostly we’ll call these AST’s. Parsing is organizing the sequence of tokens into hierarchical syntactic structures such as expressions, statements, and blocks. This is like organizing (diagramming) an English sentence into clauses, etc. Refer to this as the syntactic or grammatical structure of the language. 2.5 Parsing ¦¥¦ §¦§  18 ¦¥¦¥¦§¦¥¦ ¤ £  ¦ ¤ ¨¢   ¡  © ¡¥  ¡ % ¢ ¦  ¦ ¤ ¨¢   ¡  ©  ¡¥  % % ¢  ¦ # "© ¢   ¡  ©    %      ©  ¢  ¦© ¢   ¥© % ¥ # ¤  ¦  ¦ ¤ ¥ ¢   ¡  % %  ¥  #    © ¦¤¢ £ ¢   ¢  #    ©  ¤ ¦© ¢   ¥ © %  #    ©  ¥  §  §    #  ¦ ¡¢ ¥¨¢    ¡  © % ¢  ¥  ¥ ¢ ¡  © ¢ ¡  © ¢   ¡    ¡   ¢    © ¢ © ¢ ¡   © ¢  ¢  §   § ¡¡  ¥  ¦ ¢ £ ¡ ¤ % &¢ ¤ ¥¢ % § %  ¢¤ ¢ £ ¦§  § ¤ ¥¢ % ¥£  ¢  ¥ ¥  ¡¡ begin x := foo; while x do x := (x + bar) end var-exp var-exp var-exp assign-statement var-exp sum-exp assign-statement while-statement compound-statement 2.5.1 Specification via context-free grammars We’ve seen lots of grammars so far. These are called context-free grammars. (Why context-free? To find out, go take automata theory). Our example, ¥ ¤¤  ¡ ¢  ¥£ ¡ Statement Statement Expression Statement Identifier Expression Identifier Express...
View Full Document

Ask a homework question - tutors are online