current
research | experience | about

yali: yet another lolcode interpreter

posted 3/16/2008

For reasons I'll save for a later post, I've been meaning to implement a solid piece of software in Lolcode. This is all good and well — a reasonable joke in and of itself — with exception to the fact that none of the existing parsers (that I found) were up to par for serious use. They made excellent, if buggy, imperative interpreters for simple scripts, but lacked the oomph to, say, calculate a recursive function.

Enter YALI. To stick with good computer concept nomenclature, you've got two options on this one: Yet Another Lolcode Interpreter, or YALI: Another Lolcode Interpreter, but I prefer the former (recursive acronyms are so 1990s).

YALI is implemented mostly up through Lolcode spec 1.2, probably with a few caveats. It is a Perl-based interpreter, using the beautiful Parse::RecDescent module, and is based (loosely) off of original work by Joe Drago. Notably, since YALI is an interpreted language running on top of an interpreted language (at work, we refer to it simply as “Double-VMed”), it can get really bogged down with too much code or too many variables.

YALI is my first venture into language implementation — if using Perl even allows me to call it that — so be gentle.

Keywords

Although YALI adheres closely to Lolcode spec 1.2, it's probably best to call out all available keywords, since some changes have definitely been made.

Unless otherwise stated, all statements must be delimited by newlines.

General syntax out of the way, here are the definitions for a few key terms:

Last but not least, a note on value versus reference. In YALI, all variables may be either values or arrays; consider values as leaf nodes, and arrays as branches. When a leaf node is passed to a function, it is passed by value; when a branching node is passed to a function, it is passed by reference. To pass a value by reference, use LOL 0 IN MAH array R value and pass the array instead. You cannot pass an array by value, but you can possibly rebuild a copy yourself.

Examples

Like the rest of you, I learn poorly from documentation and excellently from examples. So here we go.

HAI
  BTW Hello, world!
  VISIBLE "Hello, " N "world!"
KTHXBYE

Aww, memories.

HAI
  BTW Cheater's quine
  I HAS A quine
  GIMMEH LINEZ quine OUTTA "quine.lol"

  I HAS A loop_max ITZ ALL quine
  I HAS A loop_index ITZ 0
  IM IN YR loop
    IZ loop_index LIEK loop_max O RLY?
      YA RLY
        GTFO
    KTHX

    VISIBLE loop_index IN MAH quine
    UP loop_index!!
  KTHX
KTHXBYE

It's a cheater's quine since it's just reading its own source code and printing it out. Nothing algorithmically intriguing here, but it's a good introduction to basic syntax usage.

HAI
  OBTW
    Naive Fibonacci, with no caching
  TLDR

  HOW DUZ I fibonacci YR index
    IZ index SMALR THAN 2 ? FOUND YR 1

    LOL index R index NERF 1
    I HAS A fibs_left ITZ fibonacci YR index MKAY
    LOL index R index NERF 1
    I HAS A fibs_right ITZ fibonacci YR index MKAY

    FOUND YR fibs_left UP fibs_right
  IF U SAY SO

  I HAS A index
  VISIBLE "Watnz numbr: "!
  GIMMEH NUMBR index

  I HAS A fibs ITZ fibonacci YR index MKAY
  VISIBLE index N " fibs r " N fibs
KTHXBYE

A simple Fibonacci sequence generator (when given an index).

HAI
  OBTW
    join
    Basic array join.
  TLDR	
  HOW DUZ I join YR a AN YR b
    I HAS A count ITZ ALL a
    LOL count R count NERF 1

    IZ count SMALR THAN 0 ? FOUND YR ""

    I HAS A output ITZ ""
    IM IN YR LOOP
      LOL output R count IN MAH a N output

      IZ count BIGR THAN 0 ? LOL output R b N output
      IZ count LIEK 0 ? GTFO

      LOL count R count NERF 1
    KTHX

    FOUND YR output
  IF U SAY SO

  OBTW
    mapMult
    Toy function to demonstrate pass-by-reference.
  TLDR
  HOW DUZ I mapMult YR array AN YR factor
    I HAS A index ITZ 0
    I HAS A array_lemf ITZ ALL array

    IM IN YR loop
      IZ index LIEK array_lemf ? GTFO

      LOL index IN MAH array R index IN MAH array TIEMZ factor
      UP index!!
    KTHX
  IF U SAY SO

  I HAS A array
  I HAS A array_lemf ITZ 10
  I HAS A current_lemf
  IM IN YR loop
    LOL current_lemf R ALL array
    IZ current_lemf LIEK array_lemf ? GTFO

   LOL current_lemf IN MAH array R MEBBE 1 MEBBE array_lemf
  KTHX

  I HAS A array_join ITZ join YR array AN YR "\n" MKAY
  VISIBLE "Before:\n" N array_join
  I HAS A NUFN ITZ mapMult YR array AN YR 3 MKAY
  LOL array_join R join YR array AN YR "\n" MKAY
  VISIBLE "\n\nAfter:\n" N array_join
KTHXBYE

Just a quick toy demonstration of reference versus value.

A much more detailed, specific, practical, and complete example will follow shortly — there had to be some reason for me to implement this.

Known bugs

Sadly, the YALI implementation is imperfect. A quick list of pertinent bugs follows:

Frankly, those are probably ordered in terms of difficulty to fix (the first item being the most difficult). If you want to attack them, head from the bottom up.

Download

Update 2008-09-20:

Alex Klink has been kind enough to discover and patch a bug in variable filenames in GIMMEH. The newest version of YALI is available here: download YALI1.1!

Thanks, Alex!

If you find errors in any of the above, please let me know. Feel free to update and distribute YALI at your leisure.

All included LaTeX graphics are generated at LaTeX to png .

contemporary entries

comments

nice captcha
foo (4/1/2010 3:35:10am)
download google chrome
Cyncbuibounty (1/26/2012 5:24:56pm)
23 Jul 2010. Genealogy for Anne Boleyn, Queen Consort of England, Marchioness of Pembroke (1501 - 1536) on Geni, a free resource with over 90 million.We will shop for you with over 18 highly rated insurance companies to. Find out why AAA Members have trusted us with their insurance for over 50 years!.

super smash bros dojopdr online identify drugsage of empires iiimax sgpin mature ladieacu rite weather stationzenith english language centredressing men in skirtscambridge real estate services portland orsawing a lady in halfstrip party game storiesdigital video recorders reviewsbarnabus adkins 1810 kylisting of nextel private id numbersunsolved murders in butte montanalife insurance for over 50slearn to play the guitarhow long does implantation bleeding lastsimcity 4 full download freeorchid care after blooming18ft spectrum by fisherzone 14 small treessoft coated wheaten terrierportland pearl district livingcar program for the indigentrytkonen meaning of namecountry club estates deming nmhartwell lake front homesfour leaf clover coloring pagescity of sioux fallswas mckinley democrat or rebublicandead weight drop testersactual ghost video clips2003 subaru wrx indoor lightingnewport beach plastic surgeonprosperity in the 1920 sraymond hoffman jr milltown new jerseyfree streaming porn moviesvasco nunez de balboamap of hawaiian islandshome remedies for goutontario sheet metal group wayne petersondifferent types of hugsamazon extract file access architectstrong smelling urine in catsfree sex stories postjet engine performance measurementsamber ramsey crowley texassympathy note for someone prolonged illnessposterior reversible encephalopathy syndromeinmates on the webgive me resume examplesmakler roggenkamp l beckdownload jeopardy theme song1999 dodge 2500 wheel offsetirs form 1040 ezsomeone who knows ed okuncpt codes trigger point dry needlinghere comes the sunking's quest vi cd abandonwaretianemen square school ideological indoctrinationpowermatic drill press partsnokia n95 for salegeorg bush going nuts1970 dodge charger rthaunted places in alabamacustomer data integration detail designoregon ducks myspace football layoutfederal government salary chartfleetwood mac tour dateshandmade mens bison leather shoemotorcycle clamp on oil filter coolerworking brazzers password and usernameford motor company stocknegative effects of video gamesfour filters warren buffett charlie mungerdown periscope film wikipediachange headlight mazda 3waterproof credit card holdersceltic internet radio streamsbent leg abdominal for salemilitary needs in ww1st louis county minnesotabinge drinking and intitle college studentswindows xp easter eggsla oreja de van goghultra short female haircuts5th grade science projects ideas2009 biggest loser spoilerssubstance abuse in the familyoklahoma city community collegelife in the uk citizenlil wayne myspace layoutshistory of jazz musicdomain name dns lookupfree las vegas vacationfalling sand game 2the ice man hitmangarage sale pricing advicealternative search engines cluster researchthe ugly dachshund torrentcraig's list grasshopper mowerwhat is the perfume hoaxbath and body long islandhow to build a gatefree to midi converter software65 mustang rear seat belteric clapton twelfth night lyricsmind the gap scott jonesowen sound sun timesfree vintage porn moviesa list of german holidayshistory of olds trombonesreading pennsylvania earned income tax formskia in tacoma washingtonchamberlain garage door openersbaltimore city public schoolsbath and body works couponshow to make a latteplasti dip international msdspro travel network reviewmenapausal stop prolong bleedingwhat happened to mcllroycountertop installation in west virginiastar trek voyager castwhat are stocks and bondssecretary of state georgiaaamc mcat practice testhow to get rid of gascar emissions stations renton wasamsung a870 blue tooth versionmirror lens canon eos qualitysafe federal credit unionlist of all country singersspeed divided by frequency equalswa state l istudy italian in italycollege of physicians and surgeonsvintage oster blender 438 agrants to reduce auto theftmystery case files madame fatefree full length hot vids3rd gen 4runner ome kitpower steering box conversion mustangpacific stock transfer companyheavan must be missing an angel3 experimental short filmsg string beach girlsmortgage realtor lender refinancehow to beat a speeding ticketblack silver fur faux

20 Sep 2010. Powermatic Model 1050-A Drill Press and Rockler Drill Press Table. 110 volt, single phase, 5-speed belt-driven. Industrial quality.28 May 2008. Simply register your details and you will receive a free bowling game voucher. Please call ahead to find out time.I have started a series of making zodiac monthly forecast, which you can read in Nawa-I-Waqt (Family Magazine). 23-September-09 To 23-October-09 Forecast.10 Sep 2010. Ten alleged members of the Hells Angels were arrested along with four others during a. C'mon, ladies: you're not s'posed to get caught!.Brennan Industries, Inc. is a ONE STOP SHOP for all your your Archery needs. We cater to Schools/Government Agency & Non-Profits. .common duckweed covers a pond Algal or duckweed blooms on your pond can cut out light and oxygen from the water, which is bad for the other plants and.

how to make stained glass once in a blue moon how to become a porn star human growth hormone hgh play the world for wii quiet nights of quiet stars lyrics amy winehouse back to black johnny gonzales secrets of my love erase hard drive completely bogarts in raleigh nc nikon d300 18-200 mm lens joe feeley 61 billings montana dark my little pony art craigs list tampa bay download mcafee 7 free how to grow meth crystals credit cards for bad credit download free karaoke software wedding ring sizing chart map of colorado ski areas male country western singers what is a smart objective hey there delilah tabs hawaiian fish and game 1987 flh harley radio download free flight simulators home office design ideas how to sand concrete

Promotional Picnic Backpacks decorated with your logo, Picnic Coolers screen printed, Picnic Sets & Picnic Baskets custom embroidered by FortePromo.com. We carry all major brands of adjustable electric beds. Our North Carolina Adjustable Bed Center is the foremost source for adjustable beds; we wholesale.
dewkneesy (1/27/2012 5:57:30pm)