8005-panda-lang 中文文档教程

发布于 6年前 浏览 36 项目主页 更新于 3年前

8005-Programming-Language

What the 8005 Microprocessor Instruction Set Looks like

  1. Halt
  2. Increment R0 (R0 = R0 + 1)
  3. Decrement R0 (R0 = R0 - 1)
  4. Increment R1 (R1 = R1 + 1)
  5. Decrement R1 (R1 = R1 - 1)
  6. Add (R0 = R0 + R1)
  7. Subtract (R0 = R0 - R1)
  8. Print R0
  9. Jump to addressif R0 != 0
  10. Jump to addressif R0 == 0
  11. Loadin to R0
  12. Loadin to R1
  13. Store R0 into address
  14. Store R1 into address
  15. Swap R0 and address
  16. Swap R1 and address
  17. Ring the bell!
  18. Print R0 as an ASCII character

目前,Panda 不支持将某些代码编译成其中一些指令的功能,但这已作为参考提供

Installation

Installing Panda

要安装 Panda,请执行:npm i 8005-panda-lang -g

瞧! 您已经成功安装了 Panda!

Usage

Running Panda interpreter

  • 要运行 Panda 解释器,请执行 panda

  • 要退出 Panda 解释器并从您输入的 Panda 代码中检索机器代码,请在解释器中执行 quit;

Compiling Panda files

  • Valid Panda files have the .pan file extension
  • To compile a .pan file, perform panda fileName.pan

Details

Baseline Features

  • 我的编程语言允许用户使用带有加法和减法的基本声明语句

  • 我的编译器成功地解析了用我的编程语言编写的代码并打印出所有 8005 机器码

  • 我的编程语言优雅且易于使用

  • 我的编程语言允许用户使用 print as a number 函数

The Grammar/Syntax

Keywords

  • "new" = Variable Declaration
  • "print" = Print as unsigned char
  • "printAsChar" = Prints a decimal value as it's ASCII equivalent

Operators

  • "=" = Assignment
  • "-" = Decrement
  • "+" = Increment

Terminals

  • " " = Whitespace
  • ";" = End of statement

Functions

  • "print" = Print

Documentation

HOW TO: Declarations

示例下面列出了有效变量声明的

new variableName1 = 13;
new variableName2 = variableName1;
new variableName3 = variableName1 + 3;

限制 在 Panda 中声明变量的限制 在 Panda 中声明变量

  • Inability to assign a value to more than 2 values in a binary expression
  • Only numerical values

时要记住的事情

  • 确保你没有超过 256 或小于 0 的变量,否则代码将解析但你会有错误机器代码

  • 确保您不在代码中使用浮点数

  • 确保语句的最后部分和分号之间没有空格

HOW TO: Assignments

有效变量赋值示例 下面列出了 nments

variableName1 = 13;
variableName2 = variableName1;
variableName3 = variableName1 + 3;

Panda 中的赋值限制 在 Panda 中

  • Inability to assign a value to more than 2 values in a binary expression
  • Only numerical values

分配变量时要记住的事情

  • 确保你没有超过 256 或小于 0 的变量,否则代码将解析但你会有错误的机器代码

  • 确保你不在你的代码中使用浮点数

  • 确保语句的最后部分和半尾之间没有空格###如何:分配

HOW TO: Print as Int

有效打印调用的示例列在下面

print 13;
print variable;

Panda 中打印的限制

  • Inability to print binary expressions
  • Only numerical values

注意事项在 Panda 中打印时

  • 确保您没有超过 256 或小于 0 的变量,否则代码将解析但您将有错误的机器代码

  • 确保您不在代码中使用浮点数

  • 确保没有空格在语句的最后部分和分号

HOW TO: Print Int as Char

printAsChar 调用示例

printAsChar 65;
printAsChar variable

之间 有效的

  • Inability to print binary expressions
  • Only numerical values

如下

  • 所列 d 超过 256 或小于 0 否则代码将被解析但是你将有错误的机器代码

  • 确保你不在你的代码中使用浮点数

  • 语句的最后部分和分号

Final example

test.pan

new i = 13;
print i;

i = i + 60;
printAsChar i;

确保 之间没有空格在您的终端上,执行:panda test.pan

Coming Soon

我们正在与 Panda Lang 一起做一些壮观的事情。 我们目前的重点是---条件---

8005-Programming-Language

What the 8005 Microprocessor Instruction Set Looks like

  1. Halt
  2. Increment R0 (R0 = R0 + 1)
  3. Decrement R0 (R0 = R0 - 1)
  4. Increment R1 (R1 = R1 + 1)
  5. Decrement R1 (R1 = R1 - 1)
  6. Add (R0 = R0 + R1)
  7. Subtract (R0 = R0 - R1)
  8. Print R0
  9. Jump to addressif R0 != 0
  10. Jump to addressif R0 == 0
  11. Loadin to R0
  12. Loadin to R1
  13. Store R0 into address
  14. Store R1 into address
  15. Swap R0 and address
  16. Swap R1 and address
  17. Ring the bell!
  18. Print R0 as an ASCII character

Currently, Panda does not support functionality to compile some code into some of these instructions but this has been provided as a reference

Installation

Installing Panda

To install Panda, perform: npm i 8005-panda-lang -g

Voila! You have successfully installed Panda!

Usage

Running Panda interpreter

  • To run the Panda interpreter, perform panda

  • To quit the Panda interpreter and retrieve the machine code from your inputted Panda code, perform quit; in the interpreter

Compiling Panda files

  • Valid Panda files have the .pan file extension
  • To compile a .pan file, perform panda fileName.pan

Details

Baseline Features

  • My programming language allows users to use basic declaration statements with addition and subtraction

  • My compiler successfully parses the code written in my programming language and prints out all the 8005 machine code

  • My programming language is elegant and easy to use

  • My programming language allows users to use the print as a number function

The Grammar/Syntax

Keywords

  • "new" = Variable Declaration
  • "print" = Print as unsigned char
  • "printAsChar" = Prints a decimal value as it's ASCII equivalent

Operators

  • "=" = Assignment
  • "-" = Decrement
  • "+" = Increment

Terminals

  • " " = Whitespace
  • ";" = End of statement

Functions

  • "print" = Print

Documentation

HOW TO: Declarations

Samples of valid variable declarations are listed below

new variableName1 = 13;
new variableName2 = variableName1;
new variableName3 = variableName1 + 3;

Restrictions in Panda for declaring variables

  • Inability to assign a value to more than 2 values in a binary expression
  • Only numerical values

Things to keep in mind when declaring variables in Panda

  • Make sure that you don't have variables which exceed over 256 or are under 0 otherwise the code will parse but you will have buggy machine code

  • Make sure you don't use floats in your code

  • Make sure there is no space between the last part of the statement and semi colon

HOW TO: Assignments

Samples of valid variable assignments are listed below

variableName1 = 13;
variableName2 = variableName1;
variableName3 = variableName1 + 3;

Restrictions in Panda for assignments

  • Inability to assign a value to more than 2 values in a binary expression
  • Only numerical values

Things to keep in mind when assigning variables in Panda

  • Make sure that you don't have variables which exceed over 256 or are under 0 otherwise the code will parse but you will have buggy machine code

  • Make sure you don't use floats in your code

  • Make sure there is no space between the last part of the statement and semi colo### HOW TO: Assignments

HOW TO: Print as Int

Samples of valid print calls are listed below

print 13;
print variable;

Restrictions in Panda for print

  • Inability to print binary expressions
  • Only numerical values

Things to keep in mind when printing in Panda

  • Make sure that you don't have variables which exceed over 256 or are under 0 otherwise the code will parse but you will have buggy machine code

  • Make sure you don't use floats in your code

  • Make sure there is no space between the last part of the statement and semi colon

HOW TO: Print Int as Char

Samples of valid printAsChar calls are listed below

printAsChar 65;
printAsChar variable

Restrictions in Panda for printAsChar

  • Inability to print binary expressions
  • Only numerical values

Things to keep in mind when printing as char in Panda

  • Make sure that you don't have variables which exceed over 256 or are under 0 otherwise the code will parse but you will have buggy machine code

  • Make sure you don't use floats in your code

  • Make sure there is no space between the last part of the statement and semi colon

Final example

test.pan

new i = 13;
print i;

i = i + 60;
printAsChar i;

In your terminal, perform: panda test.pan

Coming Soon

We're working on some spectacular things with Panda Lang. Our current focus at the moment is ---Conditionals---

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文