Git Product home page Git Product logo

lci's Introduction

lci - a LOLCODE interpreter written in C

NOTE: For the latest LOLCODE language features, including a standard library (CAN HAS STDIO?), networking (CAN HAS SOCKS?), strings (CAN HAS STRING?), and more, please use the future branch (see an example at https://github.com/justinmeza/httpd.lol/blob/master/httpd.lol)! The main branch is maintained for backwards compatibility with the LOLCODE 1.3 language specification (https://github.com/justinmeza/lolcode-spec/tree/master/v1.3 ), but all future development should be done on the future branch.

LICENSE

Copyright (C) 2010-2014 Justin J. Meza

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

ABOUT

lci is a LOLCODE interpreter written in C and is designed to be correct, portable, fast, and precisely documented.

  • correct: Every effort has been made to test lci's conformance to the LOLCODE language specification. Unit tests come packaged with the lci source code.
  • portable: lci follows the widely ported ANSI C specification allowing it to compile on a broad range of systems.
  • fast: Much effort has gone into producing simple and efficient code whenever possible to the extent that the above points are not compromised.
  • precisely documented: lci uses Doxygen to generate literate code documentation, browsable here.

This project's homepage is at http://lolcode.org. For help, visit http://groups.google.com/group/lci-general. To report a bug, go to http://github.com/justinmeza/lci/issues.

Created and maintained by Justin J. Meza [email protected].

PREREQUISITES

  1. You must have CMake installed (www.cmake.org). a) If you're using a Linux distro with package managment CMake should be in your repositories.

  2. Python 2.7+ or Python 2.x with the argparse module installed.

INSTALLATION: THE EASY WAY ON LINUX OR MAC OSX

  1. run the script install.py. Note that

$ ./install.py -h

will display a list of relevant install options. For example, if I wanted to install lci to the directory "/home/kurtis/opt" I would run:

$ ./install.py --prefix="/home/kurtis/opt"

INSTALLATION: THE MORE INVOLVED WAY ON LINUX OR MAC OSX

  1. Configure lci using CMake. This can be as simple as opening up the terminal, navigating to the directory containing lci and typing:

$ cmake .

You can also provide any other argument to the CMake configuration process you'd like. To enable Memory testing turn the PERFORM_MEM_TESTS option on like so:

$ cmake -DPERFORM_MEM_TESTS:BOOL=ON .

You can also use the "ccmake" command or the CMake GUI if you prefer. See the cmake documentation for more details.

  1. Build the project:

$ make

  1. Install

$ make install

  1. (Optional) Build documentation:

$ make docs

  1. (Optional) Run tests:

$ ctest

INSTALLATION ON WINDOWS

(Note that the instructions were written from the point of view of Windows 7, but in practice, any modern version will work.)

  1. Add MinGW and Python to your PATH.
  • Start > right-click Computer > Properties > Advanced system settings

    Environment Variables....

  • Select the "PATH" variable and click "Edit...".

  • Add ";C:\MinGW\bin;C:\Python32" to the end.

  1. Open an Administrator shell
  • Start > All Programs > Accessories > right-click Command Prompt

    Run as administrator.

  1. Navigate to the project directory using the "cd" command, for example,

cd C:\Users%user%\Documents\lci

  1. run the script install.py. Note that

install.py -h

will display a list of relevant install options. For example, if I wanted to install lci to the directory "C:\Program Files\lci" I would run:

install.py --prefix="C:/Program Files/lci"

(notice that forward slashes are used to separate directories.)

lci's People

Contributors

0x0dea avatar ade-ski avatar danielpronych avatar donabrams avatar gadsden0 avatar justinmeza avatar klnusbaum avatar leyarotheconquerer avatar mjreed-wbd avatar quiri avatar technion avatar timgates42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lci's Issues

NUMBAR doesn't always work with line continuation

These programs are all working as expected (printing 1.00 USD).

  • HAI 1.2
      VISIBLE 1.0...
        " USD"
    KTHXBYE
    
  • HAI 1.2
      VISIBLE 1. ...
        " USD"
    KTHXBYE
    
  • HAI 1.2
      VISIBLE 1.…
        " USD"
    KTHXBYE
    
  • As well as this one, although it prints 1 USD as it's a NUMBR.
    HAI 1.2
      VISIBLE 1...
        " USD"
    KTHXBYE
    

But the following yields test.lol:2: unknown token at: ..

HAI 1.2
  VISIBLE 1....
    " USD"
KTHXBYE

Is this intended or a bug?

'future' branch interpreter array errors

I've compiled the future branch (which I cloned with git clone --single-branch --branch future https://github.com/justinmeza/lci.git) in Ubuntu 16 through the WSL, and when I try to use arrays in accordance with the Advanced Quick Reference, it causes an error.
CMake version: 3.16.3
Make version: GNU 4.2.1 x86_64-pc-linux-gnu
lci --version: v0.11.2

Code (filename is arrayz.lol):
HAI 1.4

I HAS A array ITZ A BUKKIT

array'Z SRS 1 R 5

VISIBLE array'Z 1

KTHXBYE

Run with:
lci arrayz.lol

Error:
arrayz.lol:7: expected identifier at: 1

arrayz.lol:7: unable to delete unknown identifier type

arrayz.lol:7: expected identifier at: 1

arrayz.lol:5 unable to store variable: array

arrayz.lol:7: unable to delete unknown identifier type

Thanks!

moving future branch to master branch

RFC: let's promote the future branch to master

Some background

When I started lci, my goal was to implement the full 1.2 LOLCODE specification as accurately as possible. That version of lci is ultimately what resides on the master branch right now.

Realizing some of the limitations of the 1.2 spec – but without a formal 1.3 spec – others and I started working on implementing and experimenting with new features (like BUKKITs and so on) on the future branch.

The problem

Right now the master branch is in maintenance mode and only gets updated when bugs are fixed. On the other hand, the future branch sees more active development. It's not a ton of development :) but it's some. And besides, the future branch has some of the more interesting features including BUKKITs, file I/O, and network sockets.

The proposal

The proposal is simple: I'd like to promote the future branch to be the master branch. At the same time, I'd move the current master branch to be called the 1.2-spec branch.

This will make it a lot easier for newcomers to discover the most feature-rich version of lci.

Potential downsides

Note that the current implementation in the future branch has several changes that break compatibility with LOLCODE 1.2. This has allowed us to greatly simplify the code.

Also, there is not published specification for how the current future branch behaves. I will try and publish a 1.4 spec on the lolcode-spec project. (Note that I'm skipping 1.3 to avoid confusion with the proposed 1.3 specs that can be found on archives of the old lolcode.com site.)

Summary

Aside from the branch name change, there won't be much of a noticeable difference. Let me know if you have any thoughts. After a while, if there are no burning issues, I'll make the change.

😸

BOTH SAEM not working in loops

With this code, for exemple: http://pastebin.com/hqGcXeW7

Enter 2 times the same number, smaller than 15 (to see it's not working)

As you can see, BOTH SAEM var1 AN var2 doesn't work inside the loop.
Output:

echo@[routeurDSL]:~/Desktop/do/lolcode$ lci 2.lol
nb : 10
enter same number plz: 10
OUTSIDE LOOP, VAR=VAR?
10=10? 1
INSIDE LOOP, VAR=VAR?
10=0? 0
10=1? 0
10=2? 0
10=3? 0
10=4? 0
10=5? 0
10=6? 0
10=7? 0
10=8? 0
10=9? 0
10=10? 0
10=11? 0
10=12? 0
10=13? 0
10=14? 0
10=15? 0
MEH, DUSNT WORK,GTFO WITH VAR=NUMBER? : 15=15? 1

I DUZ STUFF

LOLCODE/lci needs the ability to shell out to run stuff on the host OS, so that I can use it to script exploits. For instance:

HAI 1.2
I HAS A THING_TO_DO
THING_TO_DO R "uname -a"
I DUZ THING_TO_DO
VISIBLE IT!
KTHXBYE

I've made the requisite changes and tested it locally, but I don't use GitHub (and I'm currently way too lazy to learn, unfortunately). I'd like to contribute this code back, nonetheless. Would you take a patch?

File I/O not working

The fopen test fails:

HAI 1.4
    CAN HAS STDIO?
    I HAS A file
    file R I IZ STDIO'Z OPEN YR "read.dat" AN YR "r" MKAY
    file R I IZ STDIO'Z OPEN YR "write.dat" AN YR "w" MKAY
    file R I IZ STDIO'Z OPEN YR "write.dat" AN YR "a" MKAY
    file R I IZ STDIO'Z OPEN YR "write.dat" AN YR "r+" MKAY
    file R I IZ STDIO'Z OPEN YR "write.dat" AN YR "w+" MKAY
    file R I IZ STDIO'Z OPEN YR "write.dat" AN YR "a+" MKAY
KTHXBYE

Saying: variable does not exist: STDIO

segfault or abort with IT in small programs

The program

HAI 1.3
    SUM OF 1 AN 2 
    VISIBLE IT 
KTHXBYE

executes fine. I'm using IT as described in the 1.2 spec on expression syntax.

However, when I try to do something more complicated involving IT, e.g.,

HAI 1.3
    SUM OF 1 AN 2 
    VISIBLE SUM OF IT AN 3 
KTHXBYE

I variously get abort traps or segfaults.

bash-3.2$ lci test.lol 
6
Segmentation fault: 11
bash-3.2$ lci test.lol 
6
lci(39953,0x7fff73c4a300) malloc: *** error for object 0x7feffae05470: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

However, this is an intermittent failure. I can't always seem to produce it. I've been able to reproduce it by modifying this test file and building up to it.

Cmake Not Able to Find Doxygen

So after I ran cmake and got lci in usr, I downloaded doxygen. However, when I ran cmake again, cmake still wasn't able to find doxygen.

String and colon

I have a string, which sometimes comes with a leading :. So I want to check for this, but right now it's not working. Here's my testing code. It doesn't matter if I get the String with GIMMEH or a file.

HAI 1.3
    CAN HAS STRING?

    I HAS A string ITZ "::hello"

    I HAS A char ITZ I IZ STRING'Z AT YR string AN YR 0 MKAY
    VISIBLE char AN " - " AN "::"

    BOTH SAEM char AN "::", O RLY?
    YA RLY
        VISIBLE "success"
    NO WAI
        VISIBLE "fail"
    OIC

    VISIBLE char AN " - " AN ":(3A)"
    BOTH SAEM char AN ":(3A)", O RLY?
    YA RLY
        VISIBLE "success"
    NO WAI
        VISIBLE "fail"
    OIC

    BTW gives error: VISIBLE ":[char]" AN " - " AN "COLON"
    BOTH SAEM ":[char]" AN "COLON", O RLY?
    YA RLY
        VISIBLE "success"
    NO WAI
        VISIBLE "fail"
    OIC

    I HAS A char2 ITZ I IZ STRING'Z AT YR string AN YR 1 MKAY
    VISIBLE char2 AN " - " AN "h"
    BOTH SAEM char2 AN "h", O RLY?
    YA RLY
        VISIBLE "success"
    NO WAI
        VISIBLE "fail"
    OIC

    I HAS A char3 ITZ "::"
    VISIBLE char3 AN " - " AN "::"
    BOTH SAEM char3 AN "::", O RLY?
    YA RLY
        VISIBLE "success"
    NO WAI
        VISIBLE "fail"
    OIC
KTHXBYE

Any idea?

Suggestion: PIPE library to allow execution of commands in LOLCODE

I ironically would like to make a lot of my dotfiles in LOLCODE, but the lack of a way to call shell commands makes that very difficult. Heres a way it could be implemented:

HAI 1.5

CAN HAS STDIO?
CAN HAS PIPE?

I HAS A pipe
pipe R I IZ PIPE'Z OPEN YR "echo Hello World"

BOTH SAEM pipe AN "Hello World"
O RLY?
    YA RLY, VISIBLE "OK"
    NO WAI, VISIBLE "SOMFING WENT WONG"
OIC

KTHXBYE

Socket/File support?

It would be interesting to make a FIEL-like BUKKIT that would be a part of the core library and specification. Maybe some calls like:

FILO = File-like object

Name Purpose C-like function
LUK Read a LETTAR, LINE, or WORD from a FILO fscanf()
SCRIBBEL Write a YARN to a FILO fprintf()
AGEIN Rewinds the FILO rewind()
HAZ creates a FILO n/a
OPEN Opens a file into a FILO fopen()
KONN Connects a socket to a FILO connect()
BIND Binds a socket to a FILO bind()

Octal NUMBR works when negative, but not positive

The following program returns -8.

HAI 1.2
  VISIBLE -010
KTHXBYE

But the following yields the error message test.lol:2: unknown token at: 010.

HAI 1.2
  VISIBLE 010
KTHXBYE

I would have expected octal input to work with neither or both.

Shebang without trailing newline causes buffer overflow (segfault)

Given an input file like

#!/usr/bin/env lci

without a trailing newline, the interpreter segfaults.

Expected: An error message instead of a crash.

The reason is the following piece of code, which doesn't check the buffer length while searching for trailing '\n' or '\r'.

lci/main.c

Lines 210 to 215 in 6762b72

/* Remove hash bang line if run as a standalone script */
if (buffer[0] == '#' && buffer[1] == '!') {
unsigned int n;
for (n = 0; buffer[n] != '\n' && buffer[n] != '\r'; n++)
buffer[n] = ' ';
}

(Note that this is a crash that only occurs on malformed input files.)

Variable created inside conditional block isn't visible in main program block

The specification says

All variable scope, as of this version, is local to the enclosing function or to the main program block. Variables are only accessible after declaration, and there is no global scope.

This makes me think that a variable should be visible within the function or main program block wherever it's defined, as long as that's above the point where it's accessed. However, the program

HAI 1.2
BOTH SAEM 1 AN 1
O RLY?
  YA RLY
    I HAS A variable ITZ "Hello World!"
    VISIBLE variable
OIC
VISIBLE variable
KTHXBYE

generates the output

Hello World!
/tmp/hello.lol:8 variable does not exist: variable

I guess the actual scope is more narrow than the enclosing function. This seems like a bug to me, either in the implementation or in the specification.

SegFault when using STDIO Library

I'm using the future branch of lci, and whenever I run a program to write a YARN to a file, I get a Segmentation Fault. The Program is below:

HAI 1.4

CAN HAS STDIO?

I HAS A var ITZ "HAI!!!1!"

I HAS A file ITZ I IZ STDIO'Z OPEN YR "/usr/lol/file.txt" AN YR "r" MKAY

I IZ STDIO'Z DIAF YR file MKAY
O RLY?
YA RLY
I IZ STDIO'Z SCRIBBEL YR file AN YR var MKAY
NO WAI
INVISIBLE "I can't open ur file!!!1!"
OIC

I IZ STDIO'Z CLOSE YR file MKAY

KTHXBYE

Error installing: There was a CMake error

Many people do the things, listed, in order to install.
They run install.py with their arguments.
They get the error Error installing: There was a CMake error.
Including me.
Please help.
I'm running Win 8.1 Pro 64-bit btw.

Colon and quotation mark conflict in strings

This program

HAI 1.2
  VISIBLE ":"::"
KTHXBYE

prints ": as expected. However,

HAI 1.2
  VISIBLE ":::""
KTHXBYE

produces the error message test.lol:2: expected token delimiter after string literal. I would have expected it to print :".

It should be mentioned that VISIBLE "::" ":"" solves the problem, but I don't see why the second version would be incorrect.

segfault

While playing with lolcode, I've isolated the segfaulting code:

HAI 1.2
I HAS A VAR ITZ 1
VAR R ":{VAR}"
VISIBLE VAR
KTHXBYE

In here, the segfault happens only when VISIBLE VAR is called. I think the problem is with this line:

VAR R "{:VAR}"

after string interpolation of VAR and overwriting self.

Reformat README to use GFM

To quickly make out code samples and for a better structure I propose to reformat the README.md to use Github-flavoured Markdown. I'd do it right away. Any thoughts?

make fails

I get 'no rule to make target -lm needed by lci'

Does this allows to embed into software as a script language?

Just a stupid question: does this interpreter has an ability to embed it into certain software to make it being a script language of it? Including of two-dimensional calls bindings where you can call C functions from LOL, and call LOL functions from C, and transfer data between both sides, etc. Absolutely the same way on how Lua is used.

Can install linux mint

When i trie to compile lci I get the following error:
`Running cmake with command:
"cmake ."
and writing results to configure.out.

Error installing: There was a CMake error
`
logs.tar.gz

Is it a bug or user error?

Build failure on future branch

I can build the main branch fine, but the lci-future branch fails to build for me. The output of make.out is as follows:

Scanning dependencies of target lci
[ 10%] Building C object CMakeFiles/lci.dir/interpreter.c.obj
[ 20%] Building C object CMakeFiles/lci.dir/lexer.c.obj
[ 30%] Building C object CMakeFiles/lci.dir/main.c.obj
C:\temp\lci-future\main.c:112:31: fatal error: readline/readline.h: No such file or directory
compilation terminated.
CMakeFiles\lci.dir\build.make:109: recipe for target 'CMakeFiles/lci.dir/main.c.obj' failed
mingw32-make[2]: *** [CMakeFiles/lci.dir/main.c.obj] Error 1
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/lci.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/lci.dir/all] Error 2
Makefile:137: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

Hopefully the project isn't totally dead - would love to see it grow :)

SIGSEV

An unclosed OBTW result in a segmation fault.

EOL doesn't replace MKAY when calling a variadic function

The following program prints 1, as expected.

HAI 1.2
  VISIBLE SUM OF 0 AN ANY OF FAIL AN WIN MKAY
KTHXBYE

However, according to the specs:

An MKAY may be omitted if it coincides with the end of the line/statement, in which case the EOL stands in for as many MKAYs as there are open variadic functions.

The way I read this, the program above should be possible to rewrite into the following.

HAI 1.2
  VISIBLE SUM OF 0 AN ANY OF FAIL AN WIN
KTHXBYE

But this quits with the error message test.lol:2: expected expression at: end of line.

Is this a bug in the specification, in the interpreter, or in my understanding of the specs?


EDIT: The description above concerns mathematical operations, but the same goes for SMOOSH, which is mentioned on its own in the specs.

The line ending may safely implicitly close the SMOOSH operator without needing an MKAY.

The following works for me.

HAI 1.2
SMOOSH "x" AN "y" MKAY
KTHXBYE

But this doesn't (expected expression at: end of line)

HAI 1.2
SMOOSH "x" AN "y"
KTHXBYE

SIGSEGV on ARMv5

Hey!

Downloaded lci, ran make and make check (all tests passed) and when I run ./lci hai.lol (with hai.lol being the example on your homepage) it just crashes with segmentation fault. What am I doing wrong?

Thanks!

strace output:

execve("./lci", ["./lci", "hai.lol"], [/* 21 vars */]) = 0
brk(0) = 0xbd000
uname({sys="Linux", node="iruel.net", ...}) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001d000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=34588, ...}) = 0
mmap2(NULL, 34588, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40026000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libm.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\3741\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=652912, ...}) = 0
mmap2(NULL, 684200, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x4002f000
mprotect(0x400cd000, 32768, PROT_NONE) = 0
mmap2(0x400d5000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x9e) = 0x400d5000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\314V\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1205684, ...}) = 0
mmap2(NULL, 1242372, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x400d7000
mprotect(0x401fa000, 28672, PROT_NONE) = 0
mmap2(0x40201000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x122) = 0x40201000
mmap2(0x40204000, 9476, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40204000
close(3) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001e000
set_tls(0x4001e8a0, 0x4001ef77, 0x4001ef78, 0x4001e8a0, 0x40025000) = 0
mprotect(0x40201000, 8192, PROT_READ) = 0
mprotect(0x400d5000, 4096, PROT_READ) = 0
mprotect(0x40024000, 4096, PROT_READ) = 0
munmap(0x40026000, 34588) = 0
brk(0) = 0xbd000
brk(0xde000) = 0xde000
open("hai.lol", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=74, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001f000
read(3, "BTW hai.lol\nCAN HAS STDIO?\nHAI 1"..., 4096) = 74
read(3, "", 4096) = 0
close(3) = 0
munmap(0x4001f000, 4096) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Segmentation fault

Loops always create a loop-scope variable and initialize it to 0

From the spec I expected to be able to count from, say, 5 to 10 like this:

I HAS A Var ITZ 5
IM IN YR Loopy UPPIN YR Var WILE DIFFRINT Var AN 10
  VISIBLE Var
IM OUTTA YR Loopy

But it starts at 0, and the outer Var is still 5 at the end. So how do I do a loop that doesn't start at 0?

[WISHLIST] Continue operator

I am sorely missing a continue operator, something that allows me to immediately go to the next iteration of a loop. At the moment I have to put everything in a O RLY? statement.

Here are my suggestions:

  • DONT CARE
  • NEVERMIND

Examples:

IM IN YR LOOP UPPIN YR N WILE DIFFRINT N 101
    BOTH SAEM MOD OF N 10 0, O RLY?, YA RLY, NEVERMIND, OIC
    BTW DO STUFF HERE WHEN N IS NOT DIVISIBLE BY 10
IM OUTTA YR LOOP

Invalid Unicode code points are accepted

U+D800 (among others) is not a valid Unicode code point according to the UTF-8 standard. However, the LOLCODE interpreter accepts ":(D800)" without a warning/error and happily writes the incorrect code point to the screen.

Wikipedia says

U+D800 to U+DFFF

The Unicode standard permanently reserves these code point values for UTF-16 encoding of the high and low surrogates, and they will never be assigned a character, so there should be no reason to encode them. The official Unicode standard says that no UTF forms, including UTF-16, can encode these code points.

However UCS-2, UTF-8, and UTF-32 can encode these code points in trivial and obvious ways, and large amounts of software does so even though the standard states that such arrangements should be treated as encoding errors. It is possible to unambiguously encode them in UTF-16 by using a code unit equal to the code point, as long as no sequence of two code units can be interpreted as a legal surrogate pair (that is, as long as a high surrogate is never followed by a low surrogate). The majority of UTF-16 encoder and decoder implementations translate between encodings as though this were the case and Windows allows such sequences in filenames.

In other words, it's not uncommon to accept these code points. Is this something that should/will be fixed, is it intentionally allowed, or is the behavior undefined? (I believe that the specification doesn't cover this.)

make fails

I get 'no rule to make target -lm needed by lci'

Function can read and modify variables in outside scope

Possibly related to #38.

The 1.2 specification says

Currently, functions do not have access to the outer/calling code block's variables.

Nevertheless, on master, the following code

HAI 1.2
  I HAS A var ITZ "foo"

  HOW IZ I func
    VISIBLE var
    var R "bar"
  IF U SAY SO

  I IZ func MKAY
  VISIBLE var
KTHXBYE

prints

foo
bar

I would have expected an error message about undefined variables.

If a function can in fact modify variables in the outside scope while the specification says that it can't, then it gets harder to track down bugs.

Assigning UPPIN variable to external variable

Consider this code:

HAI 1.2
    I HAS A FIFTY ITZ 0
    IM IN YR TEST UPPIN YR NNN WILE DIFFRINT NNN 100
        BOTH SAEM NNN 50, O RLY?
            YA RLY, FIFTY R NNN
        OIC
    IM OUTTA YR TEST
    VISIBLE FIFTY
KTHXBYE

I expect this to output 50, but I get 100.
If we change the YA RLY line to YA RLY, FIFTY R SUM OF NNN 0 we correctly get 50.
Is this a problem with scoping and variables value/reference assignment?

LIEK does not perform a deep copy

I expected LIEK to perform a deep copy of a BUKKIT type'd variable. It seems like it only copies the reference... which means there can only be one instance of my SOCIALCONSTRUCT.

Use Case: Store some state in an object, then duplicate that object in order to keep a backup of the state.

Behaviour: Modifying the copy also modifies the original

Workaround: Create a new BUKKIT (not the specific object, just a generic BUKKIT) and manually copy all the properties. The problem with that is the effort and that functions that would belong to the object have to be generalized.

HAI 1.4

OBTW
    I HAS A [var] ITZ LIEK A [other var]

    Declares a variable and copies the contents of the other variable into the newly created variable. This is only valid if the other variable is a BUKKIT.

    According to https://esolangs.org/wiki/LOLCODE

    But it does not create a deep copy
TLDR

O HAI IM SOCIALCONSTRUCT
    I HAS A PROBBERTY ITZ 100

    HOW IZ I DUPLICATIN
        I HAS A THING ITZ LIEK A SOCIALCONSTRUCT
        THING'Z PROBBERTY R ME'Z PROBBERTY
        FOUND YR THING
    IF U SAY SO

    HOW IZ I CLONINGWEIRDLY
        I HAS A THING ITZ A BUKKIT
        THING HAS A PROBBERTY ITZ ME'Z PROBBERTY
        FOUND YR THING
    IF U SAY SO
KTHX

VISIBLE SMOOSH "Original Property is " AN SOCIALCONSTRUCT'Z PROBBERTY MKAY

BTW CREATE A COPY WITH "LIEK"
I HAS A problem ITZ LIEK A SOCIALCONSTRUCT

BTW CREATE A COPY WITH "LIEK" FOLLOWED BY "R"-ASSIGNMENT OF THE PROPERTY
I HAS A sex ITZ problem IZ DUPLICATIN MKAY

BTW CREATE A COPY WITHOUT "LIEK", SIMPLY ASSIGN THE PROPERTY
I HAS A issue
issue R problem IZ CLONINGWEIRDLY MKAY

VISIBLE "------", VISIBLE ""


VISIBLE SMOOSH "problem probberty: " AN problem'Z PROBBERTY MKAY
VISIBLE SMOOSH "sex probberty: " AN sex'Z PROBBERTY MKAY
problem'Z PROBBERTY R 99
VISIBLE SMOOSH "problem probberty: " AN problem'Z PROBBERTY MKAY
VISIBLE SMOOSH "sex probberty: " AN sex'Z PROBBERTY MKAY

VISIBLE "THE VALUE OF SEX'Z PROPERTY CHANGED! BAD!"
VISIBLE ""

problem'Z PROBBERTY R 88
VISIBLE SMOOSH "problem probberty: " AN problem'Z PROBBERTY MKAY
VISIBLE SMOOSH "issue probberty: " AN issue'Z PROBBERTY MKAY

VISIBLE "THE VALUE OF ISSUE'Z PROPERTY DOESNT CHANGE! GUD!"


KTHXBYE

Failed realloc during program buffering causes segfault

Large program files and/or tight memory constraints can cause segfaults during program buffering. Expected: An exit with an error message.

A sparse file containing a LOLCODE program and trailing NULs will usually run correctly. For example, the following set of commands creates a sparse 1MB file (using something like 4kB on disk) and runs it.

echo "HAI 1.3\nVISIBLE \"hello world\"\nKTHXBYE" > program.lol
dd if=/dev/zero of=program.lol bs=1 count=0 seek=1M
lci program.lol

However, making the file 1TB causes lci to segfault.

echo "HAI 1.3\nVISIBLE \"hello world\"\nKTHXBYE" > program.lol
dd if=/dev/zero of=program.lol bs=1 count=0 seek=1T
lci program.lol

Here's the variable that keeps track of the buffer size.

lci/main.c

Line 144 in 6762b72

unsigned int size = 0;

And here's the loop that reads the input file.

lci/main.c

Lines 193 to 200 in 6762b72

while (!feof(file)) {
size += READSIZE;
buffer = realloc(buffer, sizeof(char) * size);
length += fread((buffer + size) - READSIZE,
1,
READSIZE,
file);
}

From what I can tell, two issues contribute to this behavior.

  1. The variable size is declared as unsigned int instead of as size_t. This makes it wrap around at 232 on most systems, even when more than 4GB of RAM is available. At that point, realloc is asked to resize the buffer to 0 bytes.
  2. The return value of realloc isn't checked. If the reallocation is unsuccessful, buffer is replaced with a null pointer.

If you're testing this on your own machine, you may want to limit the memory usage to avoid thrashing. I ran ulimit -v 6291456 to enforce a hard 6GB limit.

Variable resets to 0 completely randomly

I'm not sure if you can replicate this but I was trying to create a 99 bottles of beer program and I declared a variable called BEERZVAR and set it to 99. When I print it in a loop, and if I lci the program, the first thing I see when I scroll up is 0.

As you can see, I handle it by just checking if it's 0 (at the start only) and setting it to 99 manually.

Code is here, cause it's pretty long:
https://codeshare.io/f9J1h

Did I do something wrong with I HAS A BEERZVAR and BEERZVAR R 99? I know I can shorten it to I HAS A BEERZVAR ITZ 99 but it gives me the same error.

Is lolcode dead?

When are we going to get the BUKKIT and dictionary functionality? Is this project still alive?

Chained slot access on BUKKITS does not work sometimes, with no error message.

Create a simple matrix:

I HAS A MATRIZ ITZ A BUKKIT
IM IN YR LOOP UPPIN YR ROW WILE DIFFRINT ROW 5
    MATRIZ HAS A SRS ROW ITZ A BUKKIT
    IM IN YR INNERLOOP UPPIN YR COL WILE DIFFRINT COL 5
        MATRIZ'Z SRS ROW HAS A SRS COL ITZ SUM OF PRODUKT OF ROW 5 COL
    IM OUTTA YR INNERLOOP
IM OUTTA YR LOOP

Now try to print it by getting both row and column in a single statement:

IM IN YR LOOP UPPIN YR ROW WILE DIFFRINT ROW 5
    IM IN YR INNERLOOP UPPIN YR COL WILE DIFFRINT COL 5
        VISIBLE MATRIZ'Z SRS ROW'Z SRS COL " "!
    IM OUTTA YR INNERLOOP
    VISIBLE " "
IM OUTTA YR LOOP

You get nothing. No error, no wrong output, just nothing.

If we change SRS ROW to SRS SUM OF ROW 0:

IM IN YR LOOP UPPIN YR ROW WILE DIFFRINT ROW 5
    IM IN YR INNERLOOP UPPIN YR COL WILE DIFFRINT COL 5
        VISIBLE MATRIZ'Z SRS SUM OF ROW 0'Z SRS COL " "!
    IM OUTTA YR INNERLOOP
    VISIBLE " "
IM OUTTA YR LOOP

We get the correct output:

0 1 2 3 4  
5 6 7 8 9  
10 11 12 13 14  
15 16 17 18 19  
20 21 22 23 24

Does not work on replit.

Does not work on repl.it

I tried to run this code on repl.it, However, It does not seem to work. It just shows a window and nothing in it.

BTW may not appear on the same line as TLDR

The specification says that BTW may appear on the same line as other code. Nevertheless, this program

HAI 1.2
OBTW
  multi-line comment
TLDR     BTW single-line comment
KTHXBYE

exits with

test.lol:4: multiple line comment may not appear on the same line as code

Duplicate literals in Switch statment don't produce error message

With almost every other parsing error I've encountered with lci, this is the only one that doesn't produce an actual error message. We should inform the user as to why their code doesn't not work, telling them they have duplicate literals in their switch statement.

-Kurtis

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.