lyc0930 / MiniPython-Interpreter

Yacc & lex codes of Principles and Techniques of Compiler's lab in the fall semester of junior (USTC 2019 fall)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MiniPython-Interpreter

编译原理与技术课程实验

Principles and Techniques of Compiler

郑启龙老师编译原理与技术课程的实验,使用yacc与lex开发了一个交互式的迷你Python解释器。

Function

  1. 包含:
    • 数值(INTREAL)
    • 串(STRING_LITERAL)
    • 列表(List)
    • 无类型(NoneType) 等数据类型及变量定义
  2. 包含以上类型间加+-*/ //幂乘**等基本运算
  3. 支持取列表元素、取列表切片以及相关赋值等操作
  4. 支持列表的方法
    • append()
    • count()
    • extend()
    • index()
    • insert()
    • pop()
    • remove()
    • reverse()
  5. 支持内置函数调用
    • len()
    • list()
    • print()
    • range()
    • type()
    • quit()
  6. 终端设计
    • 左右方向键移动光标
    • 上下方向键调出输入历史
    • Ctrl + C实现键盘中断
    • Tab实现自动补全

Environment

  • Windows Subsystem for Linux: Ubuntu 18.04 LTS
$ uname -r
4.4.0-18362-Microsoft
  • bison 3.0.4
$ bison --version
bison (GNU Bison) 3.0.4
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  • flex 2.6.4
$ flex --version
flex 2.6.4

How to Build & Run

yacc -d minipy-lab.y
lex minipy-lab.l
g++ y.tab.c
./a.out

or use Make:

make all

To make clean:

make clean

Timeline

  • 10月底:完成相关数据结构(属性)的设计并提交备查
  • 11月底:检查实验
  • 12.11:在教室完成了实验汇报

Members

Reference

About

Yacc & lex codes of Principles and Techniques of Compiler's lab in the fall semester of junior (USTC 2019 fall)

License:GNU General Public License v3.0


Languages

Language:C 63.9%Language:Yacc 35.5%Language:Lex 0.6%Language:Makefile 0.1%