Download presentation
Presentation is loading. Please wait.
1
CSE4100 Programming Language Translation
Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University of Connecticut 371 Fairfield Way, Unit 2155 Storrs, Connecticut (860)
2
Course Goals Provide a Practical Introduction to Compiler Concepts and Their Construction Focus on Both Theory and Practice Theory Demonstrates Strong Mathematical Basis of Compilers Practice Provides Experimental Framework for Illustrating Theory Exposure to Research Problems and Real-World Experiences One of True Ancestors of Computing Binds Their(REs and CFGs) to Lexical Analysis & Parsing
3
Course Philosophy Introduction to Fundamental Compiler Concepts
Promotion of Knowledge-Acquisition, Self-Learning, and Independence Rapid Evolution of Computing Always Must Keep Skills Up-to-Date “Learn how to Learn” Team Work and Cooperative Problem Solving Relevance of Compiler Concepts in Computing Computer Science Theory Software Engineering Operating Systems Practical Exposure to Compiler Writing Tools
4
Textbooks and Class Materials
One Required Texts … Compilers: Principles, Techniques and Tools, Aho, et al., 1st edition, Addison-Wesley 2nd edition OK – but lacking some examples and lots of extra material we don’t do CSE4100 Web Site at … All Course Notes Available On-Line Other Class Materials
5
Weekly Topic Coverage 1 Week: Introduction/Overview Ch 1,2
1.5 Wks: Lexical Analysis & Language Theory Ch 3 2.5 Wks: Grammars Top-Down Parsing Ch 3.5 Wks: Bottom-Up Parsing Ch 1.5 Wks: Syntax Directed Translation Ch 5, 4.9 2 Wks: Type Checking, Run- Ch Time Environment, Ch Code Generation, & Ch Optimization Ch 9, 10 2 Wks: Semester Project 1 Wk: Exams
6
Percentages Breakdown for Course Projects and Exams
Projects - Individual and Team (40-50% of Grade) 3 Part Semester Project Individual (Projs 1 and 2) and Team (2 and 3) Exams (40-50% of Grade) Midterm and Final – ITE334/338 Open Book, Open Notes, Web Access Homeworks (0-10%) Throughout the Semester - In Class also If no credit, Up to 2 Bonus Pts. Per Handed in Assignment Must Pass Both Projects And Exams to PASS!!! Note: All Subject to Change – Use Breakdown that Most Benefits Students
7
Course Projects Using Flex and Bison
Initial Parts Work Individually Later Parts Work in Teams of at Least 2 Utilize Compiler Writing Tools Self-Learning and Knowledge Acquisition All Programming Projects Will be Demonstrated by the Team for Correctness and Grading Evaluation Project Topic will be … Latex Text Processing Language and Generation of Formatted Text
8
Flex and Bison Strongly Recommend their Usage in SoE Linux Environment
All Students have Linux Access (via SoE Acct) Flex and Bison Available on: Cselin101.engr.uconn.edu to cselin121.engr.uconn.edu Need a Remote SSH Package to Access
9
Semester Project – Fall 2017
What is Latex? Text Processing Language Embed Commands into Ascii File Opposite of Word’s WYSIWYG Geared Towards Publishing – Particularly Prior to Newer Versions of Work Very Powerful Text Formatting Language Invented by Computer Scientist Donald Knuth Famous for: The Art of Computer Programming
10
What is LaTeX? Text Processing Language
Used Extensively in Publication Venues ACM, IEEE CS, Other Journals Embed Text Processing Commands in Text Use Text Editor ( s, vi) One Popular Implementation: MikTex – Primarily PC Based A Good PC Implementation TeXworks Many Linux Implementations as Well (free)
11
Semester Project – Fall 2017 – Three Parts
Part I: Three tasks on Lexical Analysis and Grammars Using Flex design a Lexical Analyzer for Latex Design and develop a context free grammar (CFG) for a subset of Latex. Calculate FIRST and FOLLOW for a grammar provided after deliverable Part Ib Part II: Two tasks on Grammar Analysis/Development Analyze CFG in Bison for errors and rewrite grammar Design, implement, and test the common CFG using Flex and Bison Part III: Three tasks on Syntax Directed Translation Automatically generates formatted ASCII text and/or HTML/XML from an input Latex source file Advanced capabilities for nested blocks, full blown verbatim, and type and error checking Provide documentation in Latex that is run through both MikTex and your Part III
12
Project Part I Has Three Tasks
Task 1: Oct 4: Design and implement a lexical analyzer using the flex generator on the Linux boxes that is able to identify all lexical tokens for the latex subset. Task 2: Oct 11: Design and develop a context free grammar (CFG) for a subset of Latex. Task 3: Oct 16: Calculate FIRST and FOLLOW for a grammar provided after deliverable Part I, Task 2.
13
latex.all.txt BASIC LATEX COMMANDS/OPTIONS
The following discusses the Latex commands and options which will be supported in our text processor. TEXT THAT IS SHOWN IN ALL CAPITAL LETTERS CORRESPONDS TO TOKENS WHICH HAVE MANY DIFFERENT OPTIONS. 1. Section, Subsections, and Table of Contents Commands Examples or Explanation \section{STRING} \section{Introduction} \subsection{STRING} \subsection{A Text Processor} \subsection{Legal Latex Commands} \section{Using Latex} \tableofcontents Generate a table of contents with page numbers Specifically, it would generate: 1 Introduction 1.1 A Text Processor 1.2 Legal Latex Commands 2 Using Latex
14
latex.all.txt 2. Formatting Commands That Effect The Overall Document
Commands Examples or Explanation \renewcommand{\baselinestretch}{INTEGER} Establish the spacing 1 is single, 2 is double, etc. \pagenumbering{STYLE} STYLE is either arabic, roman, alph, Roman, or Alph arabic numbers pages using 1, 2, 3, ... etc. roman numbers pages using i, ii, iii, ... etc. alph numbers pages using a, b, c, ... etc. Roman numbers pages using I, II, III, ... etc. Alph numbers pages using A, B, C, ... etc. \arabic{COUNTER} COUNTER indicates the initial value of page numbers \roman{COUNTER} COUNTER indicates the initial value of page numbers \alph{COUNTER} COUNTER indicates the initial value of page numbers In this case, counter must be <= 26. \Roman{COUNTER} COUNTER indicates the initial value of page numbers \Alph{COUNTER} COUNTER indicates the initial value of page numbers \vspace{INTEGER} Insert an INTEGER number of blank lines \hspace{INTEGER} Insert an INTEGER number of blank spaces \rm Change the font to roman \it Change the font to italics or underline When the \rm or \it commands are used within curly braces, i.e., {\it The Huskies win again!}, only the text within the braces is affected. Otherwise, the command switches the mode of printing from that point on in the text.
15
latex.all.txt 3. Using Backslash to Indicate a Character Rather Than a Command. The backslash character (\) is used to tell Latex that the next character should be treated as a character and not as a command. The backslash is used with the following characters: $ & % # { } _ Without the backslash, each character has a special meaning, i.e., % is for a comment that is ignored during text processing, & divides column entries of tables, etc. With a backslash, i.e., \%, the character is interpreted as itself.
16
latex.all.txt 4. Begin/End Blocks - Centering and Verbatim
Begin/end blocks are used within Latex to identify a scope over which a given command applies. They are best illustrated with examples. \begin{verbatim} The verbatim option displays the text exactly Four Score and as it appears within the input file. Seven Years Ago Our Forefathers \end{verbatim} \begin{center} The center option centers the entire block of Four Score and\\ text as a single unit. The \\ are used to Seven Years\\ signal the end of a line. \end{center} This produces the output: Four Score and Without the second \\, after Seven Years, the output would be: Seven Years Ago Our Forefathers
17
latex.all.txt Commands can be combined, such as:
\begin{center} This combination centers the entire block, \begin{verbatim} exactly as it appears, without changing Four Score and the indentation within each line. Seven Years Ago Our Forefathers \end{verbatim} \end{center} The output in this case would be: Four Score and
18
latex.all.txt 5. Begin/End Blocks - single and Lists
Begin/end blocks can also be utilized to construct lists of items automatically. For example, the following input and commands: \begin{single} \begin{itemize} \item Lexical Analyzer uses DFAs and NFAs \item Parsing using CFGs \item Code Generation uses templates and also makes extensive use of syntax-directed translation via attribute grammars \end{itemize} \end{single} \noindent These are some of the phases for compilation that we'll study over the course of the semester. Produces the output: - Lexical Analyzer uses DFAs and NFAs - Parsing uses CFGs - Code Generation uses templates and also makes extensive use of syntax-directed translation via attribute grammars. The command \noindent is used to make sure that a new paragraph is not started after the list has completed, which would occur as a default.
19
latex.all.txt The enumerate option is similar, but generates numbers for each item: \begin{enumerate} \item Lexical Analyzer uses DFAs and NFAs \item Parsing using CFGs \item Code Generation uses templates and also makes extensive use of syntax-directed translation via attribute grammars \end{enumerate} Notice that without the single begin/end block, the following output is produced: 1. Lexical Analyzer uses DFAs and NFAs 2. Parsing uses CFGs 3. Code Generation uses templates and also makes extensive use of syntax-directed translation via attribute grammars.
20
Latex.input.txt \begin{document} \pagenumbering{arabic} \arabic{5}
\renewcommand{\baselinestretch}{2} \tableofcontents \section{Introduction} This is an example of text that would be transformed into a paragraph in latex. Blank lines between text in the input cause a new paragraph to be generated. When the blank line occurs after a section, no indentation of the paragraph is performed. However, all other blanks, would result in a five space indent of the paragraph. \subsection{A Text Processor} A text processor is a very useful tool, since it allows us to develop formatted documents that are easy to read.
21
Latex.input.txt \subsection{Legal Latex Commands}
We have seen that there are many different Latex commands, that can be used in many different ways. However, sometimes, we wish to use a character to mean itself, and override its Latex interpretation. For example, to use curly braces, we employ the backslash a set of integers. \section{Using Latex} Finally, there are many other useful commands that involve begin/end blocks, that establish an environment. These blocks behave in a similar fashion to begin/end blocks in a programming language, since they set a scope. We have discussed a number of examples. It is important to note, even at this early stage, that lists may be created within lists, allowing the nesting of blocks and environments. \end{document}
22
latexout.txt 1 Introduction This is an example of text that would
be transformed into a paragraph in latex. Blank lines between text in the input cause a new paragraph to be generated. When the blank line occurs after a section, no indentation of the paragraph is performed. However, all other blanks, would result in a five 2.1 A Text Processor A text processor is a very useful tool, since it allows us to develop formatted documents that are easy to
23
latexout.txt 2.2 Legal Latex Commands We have seen that there are many
different Latex commands, that can be used in many different ways. However, sometimes, we wish to use a character to mean itself, and override its Latex interpretation. For example, to use curly braces, we employ the backslash a 2 Using Latex Finally, there are many other useful commands that involve begin end blocks, that establish an environment. These blocks behave in a similar fashion to begin end blocks in a programming language, since they set a scope. We have discussed a number of examples. It is important to note, even at this early stage, that lists may be created within lists, allowing the nesting of WHY DOESN’T PRINT IT ALL OUT?
24
latextoc.txt 1 Introduction ---------- PAGE 5
2.1 A Text Processor PAGE 5 2.2 Legal Latex Commands PAGE 5 2 Using Latex PAGE 5
25
Cheating/Collaboration
Not Tolerated in Any Form!!! Severe Penalties are Likely!!! See University of Connecticut Student Conduct Code All Homeworks/Some Project Represent Individual Effort! Remaining Projects Represent Team Effort Cooperative Problem Solving and Sharing Code is NOT Permitted and Will Likely Lead to Fs! Electronic Information is More Accessible!
26
Lateness Policies/Exams
Late Assignments (Projects) will Not be Accepted Except with Prior Permission or Emergencies Prior Permission: Contact the Instructor Three Days Before the Due Date Emergencies: Illness, Death in the Family, etc. Contact S. Demurjian at ITE254, x6-4818, by or via the CSE Office, UTEB250, x6-3719 A Late Assignment is Recorded as a Zero Grade Assignment Due Date Means Start of Class!!! Makeup on Absent Exam at Instructor’s Discretion
27
Class Attendance and Computing
Attendance in Class is … Responsibility of each Student May Result in Missing Hint/Clarification/Error on Class Project Change in Due Date or Exam Date Not All Information Makes it to Web! Computing for Class is … Linux Based Take Files with You! Your Responsibility to Protect Your Files
28
Statement on Final Exam from Associate Dean of Students
Final exam week for Fall 2017 takes place from Monday, December 11th through Sunday, December 17, Students are required to be available for their exam during the stated time. If you have a conflict with this time, you must visit the Dean of Students Office to discuss the possibility of rescheduling this exam. Please note that vacations, previously purchased tickets or reservations, social events, misreading the exam schedule and over-sleeping are not viable excuses for missing a final exam. If you think that your situation warrants permission to reschedule, please contact the Dean of Students Office with any questions. Thank you in advance for your cooperation.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.