Shakespeare Programazio Lengoaia

Shakespeare programazio lengoaia (Shakespeare Programming Language, SPL), programazio lengoaia esoterikoa da Jon Aslund-ek eta Karl Hasselstrom-ek diseinatuta. Chef programazio lengoaia bezala, programa ez den beste zeozer iruditzeko diseinatua izan da, kasu honetan, Shakespearen idazlan bat.

Programaren hasieran agertzen diren pertsonaien zerrenda pilak deklaratzen dituzte, normalean “Romeo” edo “Juliet” izenekin. Pertsonaia hauen arteko elkarrizketak, bakoitzaren balore altuenak maneiatu, metatu (push), atera (pop) eta sarrera/irteera egiten dute. Pertsonaiek elkarren artean egiten dituzten galderak baldintza sententzia bezala jokatuko dute. Programazio modeloa, mihiztadura-lengoaiaren antzekoa da baina testu gehiagorekin.

Programazioa Shakespeare Lengoaian

Titulua

Shakespeare programa bateko lehengo lerroa ‘titulua’ deritzo. Lehen lerrotik lehen periodora dagoen guztia, konpiladoreak komentario gisa interpretatuko du.

Pertsonaiak

Atal honetan aldagaiak deklaratu egingo dira. Aldagai bakoitzak zenbaki oso bat gorde dezake itxura honekin:

Izena, Deskribapena

Non Izena aldagaiaren izena izango den eta Deskribapena ez du konpiladoreak kontuan hartuko. Konpiladoreak soilik Shakespeareren lanetan agertzen diren pertsonaiak onartuko ditu.

Ekitaldiak eta eszenak

Kode zatiak Ekitaldietan zatitzen dira, eszena batzuk izan ditzazkenak, non pertsonaiek (aldagaiak) parte hartzen duten. Ekitaldi (Act) eta eszena (Scene) bakoitza erromatar zenbaki batekin zenbakitzen dira. Bi puntuen ostean dagoen kodea komentario gisa interpretatuko da. Adibidez:

Act I: Hamlet's insults and flattery.Scene I: The insulting of Romeo.

Adibide Kodea

Kaixo mundua adibidea:

Romeo, a young man with a remarkable patience.Juliet, a likewise young woman of remarkable grace.Ophelia, a remarkable woman much in dispute with Hamlet.Hamlet, the flatterer of Andersen Insulting A/S.
                   Act I: Hamlet's insults and flattery.                   Scene I: The insulting of Romeo.[Enter Hamlet and Romeo]Hamlet:You lying stupid fatherless big smelly half-witted coward! You are asstupid as the difference between a handsome rich brave hero and thyself!Speak your mind!You are as brave as the sum of your fat little stuffed misused dustyold rotten codpiece and a beautiful fair warm peaceful sunny summer'sday. You are as healthy as the difference between the sum of thesweetest reddest rose and my father and yourself! Speak your mind!You are as cowardly as the sum of yourself and the differencebetween a big mighty proud kingdom and a horse. Speak your mind.Speak your mind![Exit Romeo]                   Scene II: The praising of Juliet.[Enter Juliet]Hamlet:Thou art as sweet as the sum of the sum of Romeo and his horse and hisblack cat! Speak thy mind![Exit Juliet]                   Scene III: The praising of Ophelia.[Enter Ophelia]Hamlet:Thou art as lovely as the product of a large rural town and my amazingbottomless embroidered purse. Speak thy mind!Thou art as loving as the product of the bluest clearest sweetest skyand the sum of a squirrel and a white horse. Thou art as beautiful asthe difference between Juliet and thyself. Speak thy mind![Exeunt Ophelia and Hamlet]
                   Act II: Behind Hamlet's back.                   Scene I: Romeo and Juliet's conversation.[Enter Romeo and Juliet]Romeo:Speak your mind. You are as worried as the sum of yourself and thedifference between my small smooth hamster and my nose. Speak yourmind!Juliet:Speak YOUR mind! You are as bad as Hamlet! You are as small as thedifference between the square of the difference between my little ponyand your big hairy hound and the cube of your sorry littlecodpiece. Speak your mind![Exit Romeo]                   Scene II: Juliet and Ophelia's conversation.[Enter Ophelia]Juliet:Thou art as good as the quotient between Romeo and the sum of a smallfurry animal and a leech. Speak your mind!Ophelia:Thou art as disgusting as the quotient between Romeo and twice thedifference between a mistletoe and an oozing infected blister! Speakyour mind![Exeunt]

Kanpo estekak