Giter Club home page Giter Club logo

syntaxanalyzer's Introduction

编写一个语法分析程序,能对算数表达式进行LR(1)语法分析。

要求: 对给定文法的产生式进行如下编号后:

编号 产生式 0 E' -> E 1 E -> E+T 2 E -> E-T 3 E -> T 4 T -> T*F 5 T -> T/F 6 T -> F 7 F -> (E) 8 F -> num 编程实现构造该文法的LR(1)分析表。 编程实现算法4.3,构造LR(1)分析程序。 编程要求 根据注释提示,在右侧编辑器内补充代码, 要求: 使用C/C++实现

平台环境说明 编译器版本:gcc7.3.0 OS版本:Debian GNU/Linux 9

测试说明 输入格式 从标准输入(使用 cin/scanf 等输出)读入数据。

输入仅包含1行:

第1行输入为一个算术表达式。构成该算术表达式的字符有:{'n', '+', '-', '*', '/', '(', ')' } 输出格式 输出到标准输出(使用 cout/printf 等输出)中。

输出包括若干行LR(1)分析过程: 假设输出有n行,则第i行(1≤i≤n)表示分析进行到第i步,它的输出仅包含一个部分:

分析动作:归约使用的产生式编号 或 shift 或 error 或 accept(表示当前步骤应执行的动作) 注:规定第1步的分析过程为:根据分析栈中只有状态0、输入串栈顶为第一个输入字符,来产生分析动作。

用vscode老是报string的错误, 不知道怎么回事, 用VS就没事 可能要重构LR分析表, 有几个点可能真不对

syntaxanalyzer's People

Contributors

sinclairwww avatar jraaay 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.