Giter Club home page Giter Club logo

lexer-parser's Introduction

🎁Lexer-Parser

用java实现的词法分析和语法分析的小程序:flags:

概述

  • 词法分析: 根据输入的字符序列,将字符序列转换为单词Token序列,识别每个字符,并给出相应的类型
  • 语法分析: 根据给定的文法,判断是否是LL(1)文法,自顶向下分析。采用预测分析法:从文法开始符S 出发,从左到右扫描源程序,每次通过向前查看 1 个字符,选择合适的产生式,生成句子的最左推导。
  • 步骤:
  1. 从文件读入文法自动区分 终结符号VT 和 非终结符号VN
  2. 消除直接左递归
  3. 生成FIRSTFOLLOW集合
  4. 判断是否是LL(1)文法
  5. 构建预测分析表
  6. 输入要分析的单词串自动输出分析过程

📺结果图

  • 词法分析

在这里插入图片描述

  • 语法分析

在这里插入图片描述

在这里插入图片描述

  • 判断是否是LL(1)文法

在这里插入图片描述

代码结构

在这里插入图片描述

使用说明

  • grammer文件夹放入F盘下,我在代码包中也附带了一个名为文法测试.txt的文件,里面有对应的四种文法以及需要输入的字符串示例。
  • 运行Main主函数,即可...

在这里插入图片描述

lexer-parser's People

Contributors

daq121 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.