Giter VIP home page Giter VIP logo

clinux's Introduction

# 编译器中的词法分析模块

众所周知,编译一个程序的步骤如下: 词法分析->语法分析->语义分析->中间代码生成->目标代码生成。 由于暂且尚未学习汇编语言,无法做编译器的后端工作,而且目前非常流行的LLVM框架已经做好了后端工作,所以主做词法分析。 本项目就是关于编译器的词法分析部分,使用C++实现,用来分析一个C语言程序的内容,将函数的变量名设置为灰色,将关键字设置为绿色,将整型常量、浮点型常量、字符常量、字符串常量等设置为褐色,将运算符设置为红色。

项目中文件

  • main.cpp 词法分析主程序
  • complier.h 词法分析字典模块
  • complier.cpp 词法分析字符串存储以及TOKEN值快速识别模块
  • README.md 中文介绍
  • bin 生成可执行文件目录
  • test.txt 测试文件,可将要词法分析的代码置入其中

项目运行方式

在Windows10下用Visual Studio 2019打开运行

待优化

  • 为是项目不过于复杂,未考虑逻辑与、逻辑或、逻辑非等逻辑运算符,自增自减运算符也暂未考虑
  • 暂未完成语法分析模块

clinux's People

Contributors

tangfu-0608 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.