📜  Lolcode-语法

📅  最后修改于: 2020-11-03 06:58:38             🧑  作者: Mango


与其他编程语言相比,LOLCODE具有不同的语法,但是更容易记住。本章为您提供LOLCODE的基本语法。

结构体

LOLCODE构造是语。下表显示了到目前为止实现的结构的字母顺序列表-

Sr.No. Construct & Usage
1

BTW

It starts a single line comment.

2

DOWN !!

This corresponds to variable = variable – times. Note that “times” is a wut-only language extension.

3

GIMMEH

This represents the input statement.

4

GTFO

This is similar to break in other languages and provides a way to break out of a loop.

5

HAI

This corresponds to main () function in other languages. It is the program entry point in LOLCODE.

6

HEREZ

This is another wut-only language extension and declares a label for use with SHOO

7

I HAS A

This declares a variable of said type.

There are three built-in types in LOLCODE −

  • NUMBAH (int)
  • DECINUMBAH (double)
  • WORDZ (std::string)

Note that types are a wut-only language extension.

8

IM IN YR LOOP

This starts an infinite loop. The only way to exit the loop is using GTFO. Corresponds to for(;;) in other languages

9

IZ ?: Conditional structure

This is similar to if operator in other languages. Operator is one of: BIGGER THAN, SMALLER THAN, SAEM AS. Note that the ? at the end is optional.

10

KTHX

It ends a block. Corresponds to }

11

KTHXBAI

This ends a program

12

NOWAI

This corresponds to else

13

PURR

This prints argument on screen, followed by a newline. It is a wut-only language extension.

14

RELSE

This corresponds to else (if)

15

SHOO

This is another wut-only language extension, that corresponds to goto (the horror!)

16

UP !!

This corresponds to variables = variable + times. Here “times” is a wut-only language extension.

17

VISIBLE

This prints the argument on screen. Note that this does not print a newline.

18

YARLY

This denotes the start of the “true” conditional block

LOLCODE中语术语的一些示例是-

  • HAI嗨
  • KTHXBYE很好,谢谢,再见
  • BTW顺便说一句
  • 顺便说一句哦
  • TLDR太长;没看

空格

在大多数编程语言中,关键字或标记之间可能没有空格。但是,在某些语言中,标记中使用空格来区分它们。

逗号

在大多数语言中,逗号的行为就像换行符,例如Java和C中的\ n 。如果您使用逗号(,)分隔它们,则可以在LOLCODE的一行中编写许多命令。

三个时期(…)

这三个句点(…)使您可以通过在行的末尾包含(…),将多行代码组合为一行或一个命令。这使编译器仅将下一行的内容视为前一行的内容。只要每行以三个句点结尾,就可以将无数行代码作为单个命令一起编写。

注释以换行符终止。请注意,lci会忽略注释(BTW)之后的续行(…)和(,)。

评论

编写单行注释,后跟BTW关键字。它们可能出现在程序主体内的任何位置:它可以在程序的第一行,在程序之间,在某行之间或在程序的结尾。

所有这些都是有效的单行注释-

I HAS A VAL ITZ 19      BTW VAL = 19
I HAS A VAL ITZ 19,   BTW VAL = 19
I HAS A VAL ITZ 14
BTW VAR = 14

在LOLCODE中,先写多个行注释,然后是OBTW,并以TLDR结尾。

这是有效的多行注释-

I HAS A VAL ITZ 51
   OBTW this is a comment
      No it’s a two line comment
      Oops no.. it has many lines here
   TLDR

文件创建

LOLCODE程序以HAI关键字开头,应以KTHXBYE结尾。由于LOLCODE使用速记语言,HAI基本上代表Hi,而KTHXBYE可以被记住为“好,谢谢,再见”

HAI 1.2
I HAS A NAME
VISIBLE "NAME::"!
GIMMEH NAME
VISIBLE "tutorialsPoint " NAME "!"
KTHXBYE