Skip to content

Milefer7/Lexical-Analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

词法分析器

📖 Preview预览

  • 主窗口

    image-20240531090344115

  • 词法分析过程展示

    image-20240531090303721

项目结构

结构

├── README.md
├── be
│   ├── code
│   │   └── resp.go
│   ├── controller
│   │   └── controller.go
│   ├── dao
│   │   └── mysql
│   │       ├── alphabets.go
│   │       ├── delimiters.go
│   │       ├── init.go
│   │       ├── keywords.go
│   │       └── words.go
│   ├── go.mod
│   ├── go.sum
│   ├── main.go
│   ├── model
│   │   ├── alphabets.go
│   │   ├── analysis.go
│   │   ├── delimiters.go
│   │   ├── keywords.go
│   │   └── words.go
│   ├── router
│   │   └── router.go
│   ├── service
│   │   ├── alphabets.go
│   │   ├── analysis.go
│   │   ├── delimiters.go
│   │   ├── keywords.go
│   │   ├── words.go
│   │   └── ws.go
│   └── utils
├── fe
│   ├── babel.config.js
│   ├── jsconfig.json
│   ├── package-lock.json
│   ├── package.json
│   ├── public
│   │   ├── favicon.ico
│   │   └── index.html
│   ├── src
│   │   ├── App.vue
│   │   ├── assets
│   │   │   └── dfa.png
│   │   ├── components
│   │   │   ├── ButtonPanel.vue
│   │   │   ├── CharTable.vue
│   │   │   ├── DFA.vue
│   │   │   ├── DelimeterTable.vue
│   │   │   ├── KeywordTable.vue
│   │   │   ├── ParsingProcess.vue
│   │   │   ├── SyntaxRules.vue
│   │   │   └── TokenClassification.vue
│   │   ├── main.js
│   │   ├── router.js
│   │   └── views
│   │       ├── HomeView.vue
│   │       └── PopupView.vue
│   └── vue.config.js

解释

  • image-20240531174922111

准备

环境准备

  • Go
  • npm
  • MySQL
  • Linux

配置数据库

  • 需在自行在根目录配置.env文件

    DSN_LOCAL="加入你的数据库相关信息DSN"

  • 写入数据库示例

    相关功能未完善,需要用api测试工具手动写入数据库,统一用post方法,在body里用json格式传送

    • 关键词写入:http://127.0.0.1:8080/keywords

      [
          { "id": 1, "keyword": "program" },
          { "id": 2, "keyword": "function" },
          { "id": 3, "keyword": "procedure" },
          { "id": 4, "keyword": "array" },
          { "id": 5, "keyword": "const" },
          { "id": 6, "keyword": "file" },
          { "id": 7, "keyword": "record" },
          { "id": 8, "keyword": "set" },
          { "id": 9, "keyword": "type" },
          { "id": 10, "keyword": "var" },
          { "id": 11, "keyword": "case" },
          { "id": 12, "keyword": "of" },
          { "id": 13, "keyword": "begin" },
          { "id": 14, "keyword": "end" },
          { "id": 15, "keyword": "do" },
          { "id": 16, "keyword": "if" },
          { "id": 17, "keyword": "else" },
          { "id": 18, "keyword": "for" },
          { "id": 19, "keyword": "repeat" },
          { "id": 20, "keyword": "then" },
          { "id": 21, "keyword": "while" },
          { "id": 22, "keyword": "with" },
          { "id": 23, "keyword": "string" },
          { "id": 24, "keyword": "integer" },
          { "id": 25, "keyword": "class" },
          { "id": 26, "keyword": "not" },
          { "id": 27, "keyword": "read" },
          { "id": 28, "keyword": "write" }
      ]
    • 分界符写入 http://127.0.0.1:8080/delimiters

      • [
            { "id": 1, "name": "+" },
            { "id": 2, "name": "-" },
            { "id": 3, "name": "*" },
            { "id": 4, "name": "/" },
            { "id": 5, "name": "(" },
            { "id": 6, "name": ")" },
            { "id": 7, "name": "[" },
            { "id": 8, "name": "]" },
            { "id": 9, "name": ";" },
            { "id": 10, "name": "=" },
            { "id": 11, "name": "<" },
            { "id": 12, "name": ":" }
        ]
    • 字符表写入 http://127.0.0.1:8080

      • [
            { "key": 1, "value": "a" },
            { "key": 2, "value": "b" },
            { "key": 3, "value": "c" },
            { "key": 4, "value": "d" },
            { "key": 5, "value": "e" },
            { "key": 6, "value": "f" },
            { "key": 7, "value": "g" },
            { "key": 8, "value": "h" },
            { "key": 9, "value": "i" },
            { "key": 10, "value": "j" },
            { "key": 11, "value": "k" },
            { "key": 12, "value": "l" },
            { "key": 13, "value": "m" },
            { "key": 14, "value": "n" },
            { "key": 15, "value": "o" },
            { "key": 16, "value": "p" },
            { "key": 17, "value": "q" },
            { "key": 18, "value": "r" },
            { "key": 19, "value": "s" },
            { "key": 20, "value": "t" },
            { "key": 21, "value": "u" },
            { "key": 22, "value": "v" },
            { "key": 23, "value": "w" },
            { "key": 24, "value": "x" },
            { "key": 25, "value": "y" },
            { "key": 26, "value": "z" },
            { "key": 27, "value": "A" },
            { "key": 28, "value": "B" },
            { "key": 29, "value": "C" },
            { "key": 30, "value": "D" },
            { "key": 31, "value": "E" },
            { "key": 32, "value": "F" },
            { "key": 33, "value": "G" },
            { "key": 34, "value": "H" },
            { "key": 35, "value": "I" },
            { "key": 36, "value": "J" },
            { "key": 37, "value": "K" },
            { "key": 38, "value": "L" },
            { "key": 39, "value": "M" },
            { "key": 40, "value": "N" },
            { "key": 41, "value": "O" },
            { "key": 42, "value": "P" },
            { "key": 43, "value": "Q" },
            { "key": 44, "value": "R" },
            { "key": 45, "value": "S" },
            { "key": 46, "value": "T" },
            { "key": 47, "value": "U" },
            { "key": 48, "value": "V" },
            { "key": 49, "value": "W" },
            { "key": 50, "value": "X" },
            { "key": 51, "value": "Y" },
            { "key": 52, "value": "Z" },
            { "key": 53, "value": "0" },
            { "key": 54, "value": "1" },
            { "key": 55, "value": "2" },
            { "key": 56, "value": "3" },
            { "key": 57, "value": "4" },
            { "key": 58, "value": "5" },
            { "key": 59, "value": "6" },
            { "key": 60, "value": "7" },
            { "key": 61, "value": "8" },
            { "key": 62, "value": "9" },
            { "key": 63, "value": "+" },
            { "key": 64, "value": "-" },
            { "key": 65, "value": "*" },
            { "key": 66, "value": "/" },
            { "key": 67, "value": "<" },
            { "key": 68, "value": "=" },
            { "key": 69, "value": "(" },
            { "key": 70, "value": ")" },
            { "key": 71, "value": "[" },
            { "key": 72, "value": "]" },
            { "key": 73, "value": "{" },
            { "key": 74, "value": "}" },
            { "key": 75, "value": ":" },
            { "key": 76, "value": "." },
            { "key": 77, "value": ";" },
            { "key": 78, "value": "'" },
            { "key": 79, "value": " " }
        ]
    • 单词写入 http://127.0.0.1:8080

      • [
            { "id": 1, "name": "标识符", "word": "ID" },
            { "id": 2, "name": "保留字/关键字", "word": "标识符子集,内部表示" },
            { "id": 3, "name": "无符号整数", "word": "INTC" },
            { "id": 4, "name": "单字符分界符", "word": "一位长度界限符" },
            { "id": 5, "name": "双字符分界符", "word": ":=" },
            { "id": 6, "name": "注释头符", "word": "{" },
            { "id": 7, "name": "注释尾符", "word": "}" },
            { "id": 8, "name": "字符串起始、结束符", "word": "" },
            { "id": 9, "name": "数组下标界限符", "word": ".." }
        ]

运行

  • 在根目录下执行 start.sh即可执行

贡献者

协议