Coder Social home page Coder Social logo

tiny-plus-compiler's Introduction

TINY-PLUS Compiler(TPC)


Build Status

文件说明

文件名/文件夹名 文件功能
dist/ GUI
test/ 测试文件源码
TPC-GUI/ GUI源代码

使用方法

构建TPC可执行文件

mkdir build
cd build
cmake ..
make

编译TNY文件

./TPC <Filename>

编译结果说明

后缀名 说明
.scan 词法分析结果
.tree 语法分析结果
.symbol 符号表
.code 四元式中间代码

文法的定义

程序 -> 语句序列
语句序列 -> 语句 ; 语句
语句 -> if 语句 | repeat 语句 | assign 语句 | read 语句 | write 语句
if 语句 -> if 表达式 then 语句序列 end | if 表达式 then 语句序列 else 语句序列 end
repeat 语句 -> repeat 语句序列 until 表达式
assign 语句 -> 标识符 := 表达式
read 语句 -> read 标识符
write 语句 -> write 表达式
表达式 -> 简单表达式 | 简单表达式 {<, >, =, <=, >=, <>} 简单表达式
简单表达式 -> 加数 | 加数 {+, -} 加数
加数 -> 因数 | 因数 {*, /} 因数
因数 -> ( 表达式 ) | 数字 | 标识符
标识符 -> 字母的串
数字 -> 数字的串

Token 列表

保留字 Token
if IF
then THEN
else ELSE
repeat REPEAT
until UNTIL
read READ
write WRITE
end END
运算符 Token
+ PLUS
- MINUS
* TIMES
/ OVER
= EQ
<> NOTEQ
< LT
> GT
<= LTEQ
>= GTEQ
( LPAREN
) RPAREN
; SEMI
:= ASSIGN
标识符 Token
数字 NUM
标识符 ID

tiny-plus-compiler's People

Contributors

bye-lemon avatar

Stargazers

 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.