Lexical Analysis & State Diagrams

Assignment 2: Lexical Analysis & State Diagrams
Lexical Analysis (Overview):
Lexical analysis is the process of converting a sequence of characters from source program into a sequence of tokens. A lexical analyzer is a pattern matcher for character strings:
?A lexical analyzer is a “front-end” for the parser
?A lexical analyzer identifies substrings of the source program that belong together.
?A program which performs lexical analysis is termed as a lexical analyzer (lexer), tokenizer or scanner.

There are three approaches to building a lexical analyzer:

1.Write a formal description of the tokens and use a software tool that constructs a table-driven lexical analyzer from such a description
2.Design a state diagram that describes the tokens and write a program that implements the state diagram

代写Lexical Analysis作业、代做C++课程设计作业
3.Design a state diagram that describes the tokens and hand construct a table-driven implementation of the state diagram

Overview: For this assignment, you will design a state diagram that describes the tokens and write a program that implements the state diagram which recognizes a specific form of C-based comments: those that begin with /* and end with */
Requirements:

1.Design/present a state diagram which recognizes this form of C-based comments: those that begin with /* and end with */

2.In the programming language of your choice, write and test code which implements the state diagram of this problem (recognizes the C style comments described above)

3.Discussion report (written formally in full sentences):

a.Introduce the assignment/the problem to be solved
b.Briefly discuss the steps you took and decisions you made to start and solve this problem
c.Answer: did the state diagram help you design the code? Briefly explain your answer.
d.Concludes the report: wrap up the report (summary of assignment and what you did to meet the requirements

4.Deliverables: You will submit a single Word or PDF document which includes:
a.The written discussion elements found in #3 (in the above section)
b.Your state diagram (all components of the diagram must be clearly readable)
c.Video of your program .(the working URL to the video should be listed in the report document; at the end of the report):
i. compiling
ii. Showing the program run from start to finish with the output of the solution for three test cases
d.List (working URLs are sufficient) all resources used to complete this work (you are expected to explore at least two sources)
e.Text of your code copied at the end of the report
5.Expectations:
a.Compiling errors: Your solution must compile

b.Readability. Your code should meet basic readability principles:
i.Separate each component/part with white space.
ii.Align everything in a meaningful way.
c.Comments: you must include enough comments to ensure that the code is described in sufficient detail such that anyone else looking at the code can easily understand the design and the purpose of the code.
d.All code and work associated with this assignment is your own work/written by you.
Resources/reading on compilers, lexical analysis, etc.

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:[email protected]

微信:codehelp

原文地址:https://www.cnblogs.com/python34/p/11622597.html

时间: 2024-10-07 13:34:56

Lexical Analysis & State Diagrams的相关文章

编译原理之Lexical Analysis(js实现)

// 实验存档 效果图: 代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Lexical_Analysis</title> <link href="https://fonts.googleapis.com/css?family=Noto+Serif+SC" rel="stylesheet"&

UML state diagrams with draw.io

https://about.draw.io/uml-state-diagrams-with-draw-io/ State diagrams have been used in programming to describe the various possible states that a system can be in for decades. They also quickly show which states lead to each other, and what triggers

cs262 Programming Languages(2)Lexical Analysis

这一讲重要的内容从13-Specifying Tokens开始.但是一开始就出现了这么个东西: def t_RANGLES(token) r'>' return token 前面完全没提怎么来的,看着有点迷糊,特别是r'>'这个,这是什么语法,于是第一次就放弃了.后来知道是在用PLY这个库,也看到文档中是这么说的: When a function is used, the regular expression rule is specified in the function document

SQLChop、SQLWall(Druid)、PHP Syntax Parser Analysis

catalog 1. introduction 2. sqlchop sourcecode analysis 3. SQLWall(Druid) 4. PHP Syntax Parser 1. introduction SQLCHOP, This awesome new tool, sqlchop, is a new SQL injection detection engine, using a pipeline of smart recursive decoding, lexical anal

Important Programming Concepts (Even on Embedded Systems) Part V: State Machines

Earlier articles in this series: Part I: Idempotence Part II: Immutability Part III: Volatility Part IV: Singletons Oh, hell, this article just had to be about state machines, didn’t it? State machines! Those damned little circles and arrows and q’s.

Method, apparatus, and system for speculative abort control mechanisms

An apparatus and method is described herein for providing robust speculative code section abort control mechanisms. Hardware is able to track speculative code region abort events, conditions, and/or scenarios, such as an explicit abort instruction, a

斯坦福CS课程列表

http://exploredegrees.stanford.edu/coursedescriptions/cs/ CS 101. Introduction to Computing Principles. 3-5 Units. Introduces the essential ideas of computing: data representation, algorithms, programming "code", computer hardware, networking, s

Python著名的lib和开发框架(均为转载)

第一,https://github.com/vinta/awesome-python Awesome Python A curated list of awesome Python frameworks, libraries, software and resources. Inspired by awesome-php. Awesome Python Admin Panels Algorithms and Design Patterns Anti-spam Asset Management A

[转载]浏览器的工作原理:新式网络浏览器幕后揭秘

原文地址 序言 这是一篇全面介绍 WebKit 和 Gecko 内部操作的入门文章,是以色列开发人员塔利·加希尔大量研究的成果.在过去的几年中,她查阅了所有公开发布的关于浏览器内部机制的数据(请参见资源),并花了很多时间来研读网络浏览器的源代码.她写道: 在 IE 占据 90% 市场份额的年代,我们除了把浏览器当成一个"黑箱",什么也做不了.但是现在,开放源代码的浏览器拥有了过半的市场份额,因此,是时候来揭开神秘的面纱,一探网络浏览器的内幕了.呃,里面只有数以百万行计的 C++ 代码.