Giter VIP home page Giter VIP logo

compile's Introduction

递归下降分析

针对于每一个产生式进行一个函数分析

BNF

程序(E) -> begin(g) 语句串(T) end(e) #(O)

T -> 语句{;语句(X)}

X -> 赋值语句(F)

F -> ID(d) :=(m) 表达式(B)

B -> 项+项 | 项-项(C)

C -> 因子(Y)*因子 | 因子 / 因子

Y -> d | NUM(n) | B


E -> gTe#

T -> X |X;T

X -> F

F -> dmB

B -> C | C+B | C-B

C -> Y | Y*C | Y/C

Y -> d | n | B

问题分析

  1. 关于递归分析 ,Y->B中会出现见解左递归
  2. 关于 ;X循环问题以及表达式a+bc/d类似分析 开始的时候我是将T->X;X但是这样会出现多个运算,不符合文法的范围。 改成了T -> X | X;T以后就可以运行。同理下面的+-/都是相同的修改的方法

代码生成

一共有七个非终结符,所有一共有七个函数 E() T() X() F() B() C() Y()

字符串的分析问题:

  • 正则表达式分离Token流

  • 文件流形式 备注: 中间是三个空格(随意)

compile's People

Contributors

rabbitzzc avatar

Stargazers

 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.