Introduction & Environment Setup

Lolcode – Introduction and Environment Setup ”; Previous Next LOLCODE is an esoteric programming language inspired by the funny things on the Internet. It is designed to test the boundaries of programming language design. This chapter will make you familiar with setting up the local environment for LOLCODE, installing it on Windows, and executing its script online at Tutorialspoint-codingground. Setting Up the Local Environment The LOLCODE interpreter is written in C Language. It interprets the code written in LOLCODE language on multiple platforms. The LOLCODE interpreter is known as lci, which stands for LOLCODE Interpreter. Please note that LOLCODE officially supports direct installation of interpreter for MAC operating Systems only. To install LOLCODE in your operating system, you need to follow the steps given below − Press Command+Space, and type Terminal and press enter/return key Run in Terminal app $ git clone https://github.com/justinmeza/lci.git $ cd lci $ cmake. $ make && make install Installation on Windows If you need to install LOLCODE on Windows operating system, please take these steps − First add MinGW and Python to your environment variables path. To do this, right click on My Computer, choose Properties, then select Advanced system settings. Select Environment Variables. In this box, select the PATH variable and then click Edit. Now, add “;C:MinGWbin;C:Python32” to the end of that path. Next, open the Command Prompt and navigate to the project directory using the “cd” command, for example. Run the script install.py. Executing Script Online with TutorialsPoint – codingground To execute your scripts easily and swiftly, use the codingground platform provided by TutorialsPoint. For this, go to the following link to execute your scripts online − https://www.tutorialspoint.com/execute_lolcode_online.php Print Page Previous Next Advertisements ”;

Lolcode – Quick Guide

Lolcode – Quick Guide ”; Previous Next Lolcode – Introduction and Environment Setup LOLCODE is an esoteric programming language inspired by the funny things on the Internet. It is designed to test the boundaries of programming language design. This chapter will make you familiar with setting up the local environment for LOLCODE, installing it on Windows, and executing its script online at Tutorialspoint-codingground. Setting Up the Local Environment The LOLCODE interpreter is written in C Language. It interprets the code written in LOLCODE language on multiple platforms. The LOLCODE interpreter is known as lci, which stands for LOLCODE Interpreter. Please note that LOLCODE officially supports direct installation of interpreter for MAC operating Systems only. To install LOLCODE in your operating system, you need to follow the steps given below − Press Command+Space, and type Terminal and press enter/return key Run in Terminal app $ git clone https://github.com/justinmeza/lci.git $ cd lci $ cmake. $ make && make install Installation on Windows If you need to install LOLCODE on Windows operating system, please take these steps − First add MinGW and Python to your environment variables path. To do this, right click on My Computer, choose Properties, then select Advanced system settings. Select Environment Variables. In this box, select the PATH variable and then click Edit. Now, add “;C:MinGWbin;C:Python32” to the end of that path. Next, open the Command Prompt and navigate to the project directory using the “cd” command, for example. Run the script install.py. Executing Script Online with TutorialsPoint – codingground To execute your scripts easily and swiftly, use the codingground platform provided by TutorialsPoint. For this, go to the following link to execute your scripts online − https://www.tutorialspoint.com/execute_lolcode_online.php Lolcode – Syntax The LOLCODE constructs are slang words. The following table shows the alphabetical list of constructs implemented so far − Sr.No. Construct & Usage 1 BTW It starts a single line comment. 2 DOWN <variable>!!<times> This corresponds to variable = variable – times. Note that “times” is a wut-only language extension. 3 GIMMEH <variable> 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 <label> This is another wut-only language extension and declares a label for use with SHOO 7 I HAS A <type> <variable> 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 <expr1> <operator> <expr2>?: 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 <expr> 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 <variable>!!<times> This corresponds to variables = variable + times. Here “times” is a wut-only language extension. 17 VISIBLE <expr> 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 Some examples of slang terms in LOLCODE are − HAI is hi KTHXBYE is okay, thanks, bye BTW is by the way OBTW is oh, by the way TLDR is too long; didn”t read Whitespace In most programming languages, keywords or tokens may not have spaces between them. However, in some languages, spaces are used in tokens to differentiate them. Comma The comma behaves like a newline keyword in most languages, for example, n in Java and C. You can write many commands in a single line in LOLCODE, provided that you separate them using a comma (,). Three Periods (…) The three periods (…) enables you to combine multiple lines of code into a single line or a single command by including (…) at the end of the line. This makes the compiler to treat the content of the next line as the content of previous line only. Infinite lines of code can be written together as a single command, as long as each line is ended with three periods. A comment is terminated by a newline. Please note that the line continuation (…) and (,) after the comment (BTW) are ignored by the lci. Comments Single line comments are written followed by the BTW keyword. They may occur anywhere inside a program body: it can be at the first line of program, in between the program, in between some line, or at the end of a program. All of these are valid single line comments− 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 In LOLCODE, multiple line comments are written followed by OBTW and they are ended with TLDR. This is a valid multi−line comment − 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 File Creation A LOLCODE program begins with HAI keyword and it should end with KTHXBYE. As LOLCODE uses shorthand language HAI basically stands for Hi and KTHXBYE can be remembered as “Ok, thanks, bye ”. Example HAI 1.2 I HAS A NAME VISIBLE “NAME::”! GIMMEH NAME VISIBLE “tutorialsPoint ” NAME “!” KTHXBYE Lolcode – Variables As in any other programming language, LOLCODE allows you to define variables of various types. This chapter will

Lolcode – Operators

Lolcode – Operators ”; Previous Next Operators play an important role to perform various operations on variables. This chapter brings you various operators in LOLCODE and their usage. Operators Mathematical operators depend on a prefix notation i.e. the notation that comes before the operand. When all the operators have known number of arguments or operands, then no grouping markers are necessary. In cases where operators don’t have fixed arguments or operands, the operation is closed with MKAY. An MKAY may not be used if it coincides with the end of the statement. In such cases, the EOL keyword should be used. To use unary mathematical operators , use the following syntax − <operator> <expression> The AN keyword can optionally be used to separate arguments, and apply a single operation on more than one operand, so a binary operator expression has the following syntax − <operator> <expression1> AN <expression2> Any expression containing an operator with infinite number of arguments can be expressed with the following syntax − <operator> <expression1> [[AN <expression2>] AN <expression3> …] MKAY Math Following are the basic mathematical operations in LOLCODE − SUM OF <a> AN <b> BTW This is a plus + operator DIFF OF <a> AN <n> BTW This is a minus – operator PRODUKT OF <a> AN <n> BTW This is a multiply operator * QUOSHUNT OF <a> AN <n> BTW This is a divide operator MOD OF <a> AN <n> BTW This is a modulo operator BIGGR OF <a> AN <n> BTW This is a max operator SMALLR OF <a> AN <n> BTW This is a min operator <a> and <b> can each be unique expressions in the above, so mathematical operators can be nested and grouped indefinitely. Math is performed considering arguments as integer math in the presence of two NUMBRs, but if either of the expressions is NUMBAR, then operations are considered as floating point operations. Example HAI 1.2 I HAS A m ITZ 4 I HAS A n ITZ 2 VISIBLE SUM OF m AN n BTW + VISIBLE DIFF OF m AN n BTW - VISIBLE PRODUKT OF m AN n BTW * VISIBLE QUOSHUNT OF m AN n BTW / VISIBLE MOD OF m AN n BTW modulo VISIBLE BIGGR OF m AN n BTW max VISIBLE SMALLR OF m AN n BTW min KTHXBYE The above code will produce the following output when you run it − sh- 4.3$ lci main.lo 6 2 8 2 0 4 2 Important Points − Consider the following important points related to working with mathematical operators in LOLCODE− If one or both arguments in an expression are YARN, they are treated as NUMBARs. If any of the arguments cannot be safely casted internally to a numerical type, then it fails with an error Boolean Boolean operators are applied on those values that may be true or false. Boolean operators working on TROOFs are as following − BOTH OF <m> AN <n> BTW its and operation: WIN if m = WIN and n = WIN EITHER OF <m> AN <n> BTW its or operation: FAIL iff m = FAIL, n = FAIL WON OF <m> AN <n> BTW its xor operation: FAIL if m = n NOT <m> BTW its an unary negation: WIN if m = FAIL ALL OF <m> AN <n> … MKAY BTW it will take infinite arguments and apply AND ANY OF <m> AN <n> … MKAY BTW it will take infinite arguments and apply OR. Please note that <m> and <n> in the expression syntax above are automatically cast as TROOF values if they are not already TROOF Values. Comparison When you want to compare two or more operands in LOLCODE, you can do so in any of the following methods − Method 1 You can compare two binary operands using equality operators. The syntax is shown below − BOTH SAEM <m> AN <n> BTW this will return WIN if m is equal to n DIFFRINT <m> AN <n> BTW this will return WIN if m is not equal to n Method 2 You can compare if both the values are of NUMBRs type. Remember that if either of the values are NUMBARs, then they are compared as floating point values. Method 3 You can also perform comparison using the minimum and maximum operators. The syntax is shown below − BOTH SAEM <m> AN BIGGR OF <m> AN <n> BOTH SAEM <m> AN SMALLR OF <m> AN <n> DIFFRINT <m> AN SMALLR OF <m> AN <n> DIFFRINT <m> AN BIGGR OF <m> AN <n> Example HAI 1.2 I HAS A VAR11 ITZ 7 BOTH SAEM VAR11 SMALLR OF VAR11 AN 8, O RLY? YA RLY VISIBLE “TRUE” NO WAI VISIBLE “FALSE” OIC KTHXBY You can see the following output when you execute the given code − sh- 4.3$ lci main.lo TRUE Concatenation of Values LOLCODE allows you to explicitly concatenate infinite number of YARNs using the SMOOSH…MKAY operator. For concatenation, multiple arguments can be separated with the AN operator. Example HAI 1.2 I HAS A VAR1 ITZ A YARN VAR1 R “TRUE” I HAS A VAR2 ITZ A YARN VAR2 R “ANOTHER TRUE” I HAS A VAR3 ITZ A YARN VAR3 R “ONE MORE TRUE” VISIBLE SMOOSH VAR1 ” ” VAR3 ” ” VAR2 MKAY KTHXBYE The above given code will produce the following result upon execution − sh- 4.3$ lci main.lo TRUE ONE MORE TRUE ANOTHER TRUE Type Casting Operators that work on specific types implicitly cast or convert the values of one type to other type safely.

Lolcode – Home

Lolcode Tutorial PDF Version Quick Guide Resources Job Search Discussion LOLCODE is an esoteric programming language inspired by the funny things on the Internet. LOLCODE is designed to test the boundaries of programming language design. This tutorial provides a basic level understanding of the LOLCODE programming language. Audience This tutorial is meant for people who want to explore beyond general boring programming syntax. Readers of this tutorial can learn the programming language in simple and easy ways. This tutorial will also be helpful for all those developers who want to learn the basics of LOLCODE. Prerequisites The tutorial assumes that the readers have a knowhow about programming languages. If you have worked on any other programming language, it will be easier for you to learn LOLCODE. Print Page Previous Next Advertisements ”;

Lolcode – Variables

Lolcode – Variables ”; Previous Next As in any other programming language, LOLCODE allows you to define variables of various types. This chapter will make you familiar with working with variables in LOLCODE. Scope of Variables The scope of a variable is local to the function or to the program block, i.e. a variable defined in one scope cannot be called in any other scope of the same program. Variables are accessible only after they are declared. Please note that there is no global scope of variables in LOLCODE. Naming Conventions Variable names are usually called identifiers. Here are some of the conventions for naming variables in LOLCODE − Variable identifiers may be in all CAPITAL or lowercase letters (or a mixture of the two). They can only begin with a letter and then may be followed by other letters, numbers, and underscores. LOLCODE does not allow use of spaces, dashes, or other symbols while naming a variable. Variable identifiers are case sensitive. Here are some of the rules for valid and invalid names for variables in LOLCODE− The name should always begin with an alphabet. For example, name, Name are valid. The name of a variable cannot begin with a digit. For example, 2var is invalid. The name of a variable cannot begin with a special character. A variable can contain _ or a digit anywhere inside its name, except at the starting index. For example, name2_m is a valid name. Some examples of valid names in LOLCODE are shown below − HAI 1.2 I HAS A food ITZ “111.00033” I HAS A food2 ITZ “111” I HAS A fo_od ITZ “1” VISIBLE food VISIBLE food2 VISIBLE fo_od KTHXBYE All the declaration statements in the above code are valid and will produce the following output when executed − sh-4.3$ lci main.lo 111.00033 111 1 Some examples of invalid statements and their output are given below − Example 1 HAI 1.2 I HAS A 2food ITZ “111.00033” KTHXBYE The above code will give the following output when you execute it − sh-4.3$ lci main.lo Line 2: Expected: identifier; Got: int(2). Example 2 HAI 1.2 I HAS A _food ITZ “111.00033” KTHXBYE The above code will give the following output when you execute it − sh-4.3$ lci main.lo Line 2: Unrecognized sequence at: _food ITZ “111.00033”. Example 3 HAI 1.2 I HAS A f$ood ITZ “111.00033” KTHXBYE The above code will give the following output when you execute it − sh-4.3$ lci main.lo Line 2: Unrecognized sequence at: $ood ITZ “111.00033”. Declaration and Assignment of Variables To declare a variable, LOLCODE provides a keyword “I HAS A” which is followed by the variable name. You can find below the syntax for declaring a variable. I HAS A VAR BTW VAR is empty now, You can use any name instead of var To assign the variable a value in the same statement, you can then follow the variable name with “ITZ” and then give the value you want to assign. Use the following syntax to assign a value to a variable − <variable> R <expression> Example VAR R “Green” BTW VAR is now a YARN and equals “Green” VAR R 30 BTW VAR is now a NUMBR and equals 30 You can also declare and assign variables at the same time using the following syntax− I HAS A VAR ITZ VALUE Example I HAS A NAME ITS “TUTORIALS POINT” Example HAI 1.2 BTW this is how we declare variables I HAS A food I HAS A bird BTW this is how we assign variables food R 1 bird R 5 BTW this is how initialize variables I HAS A biz ITZ “OMG!” VISIBLE food VISIBLE biz VISIBLE bird KTHXBYE The above program shows the declaration of variables and prints them. The output is − sh- 4.3$ lci main.lo 1 OMG! 5 Type Casting To convert a value of one type to another type, we use type casting. Casting a NUMBAR to a NUMBR truncates the decimal portion of the floating point number. Casting a NUMBAR to a YARN (by printing it, for example), truncates the output to a default 2 decimal places. Example HAI 1.2 I HAS A food ITZ “111.00033” VISIBLE food BTW this is how we do type casting MAEK food A NUMBAR VISIBLE food KTHXBYE The above line of code will produce the following output − sh-4.3$ lci main.lo 111.00033 111.00033 All the variables declared in a LOLCODE program are local variables and there is no global scope in this language for any variable. Print Page Previous Next Advertisements ”;