Git Product home page Git Product logo

fun's Introduction

一、分割单词

Token 对象

  • 单词的数据结构
  • 有标识符(Identifier)、整型量(Number)、字符串量(String)

正则表达式定义单词

  • 整型:[0-9]
  • 标识符:[A-Z_a-z][A-Z_a-z0-9]*
  • final: [A-Z_a-z][A-Z_a-z0-9]*|==|<=|>=|&&|\|\||p{Punct}

借助java.util.regex 设计分析器

  • 依赖java正则库,速度比自己手动实现性能更好
  • Lexer类是一个词法分析器,构造函数接受一个java.io.Reader对象,根据需要逐行读取源代码
  • regexPat 保存正则表达式
  • read从源代码逐一获取单词,peek用于预读单词。peek(1) 等于调用两次read

定义抽象语法树

  • 用于分析表达式
  • ASTLeaf是叶子节点类,所有的接点接点都继承ASTree
  • ASTList是非叶子节点

fun's People

Contributors

miaoihan avatar

Stargazers

 avatar

Watchers

 avatar  avatar

fun's Issues

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.