From Esolang
Jump to navigation Jump to search

ExtendedPig is an extension of Pig and its derivatives by User:BoundedBeans.

ExtendedPig can contain multiple commands, unlike Pig. Each command should go on its own line. The file extension is .epig.

The command follows the form: (argument 1)(command)(argument 2)

There should be no spaces between any of the parts.


NORMALPIG - Pig command
DEADPIG - DeadPig command
DEAFPIG - DeafPig command, no-op, useful for comments
SICKPIG - SickPig command
QUINEPIG - QuinePig command, output only the current line to the file
WHOLECODEPIG - Output the entire code to the file
IMPORTPIG - Take the two arguments as filenames. Run a random one of those as ExtendedPig code. This is a source of randomness, use the same file twice to import normally.
            (Once the file is done running, go back to running normal code. Think of it as the other file being inserted into the main code.)
BRAINPIG - Use the 2nd argument as Brainfuck code, output the result to the file with the filename of the 1st argument. This is a source of conditionals and looping.
           (Uses console input for the comma)\
APPENDPIG - appends to the file instead of deleting content, other than that, works like NORMALPIG

Special arguments

Arguments can have special syntax.


<"i"> - can be inserted in either argument to replace a specific part of a string with user input.
        You can also format it like <"I","string 1", "string 2", "etc."> to let the user input a number,
        which will correspond to the zero-based index of the argument chosen, excluding "I".
<"iconstant"> - same as input, but first argument is an identifier string (you can still have options,
                they just come afterwards). If two inputs have the same identifier string, only one
                will be used. The identifier string list should be kept when importing files.
                The options can be different each time, keeping the same input number as the index accessed.
<"p"> - replace with "PIG", allowing you to use it in file names and written text
<"oa"> - replace with open angle bracket; only for non-filename arguments
<"ca"> - replace with closed angle bracket; only for non-filename arguments
<"q"> - replace with double quotes; only for non-filename arguments
<"fileread", "file name", "begin index", "end index"> -
        replace the relevant arguments to read from a non-ExtendedPig file into an argument.
        The indexes can be replaced with negative numbers for reading from the end, or "START" or "END", 
        or "MARKER:" concatenated with a string to search for to go to directly after for a begin index,
        or directly before for an end index.

Special filenames

>>output - direct to STDOUT instead of a file
>>error - direct to STDERR instead of a file

Coding strategies


You can use a file as a variable, write to it normally, and read from it using <"fileread" etc.>. You can use conditionals by importing other code files based on what's read from the variable.

Appending but non-NORMALPIG

There is a definite way to append things to files, but only if they aren't quines, death notices, or sick noises. Luckily, we can write to a different file using another style, then read from that file using <"fileread" etc.> in an APPENDPIG command.


Hello World

>>outputNORMALPIGHello World!

Print "PIG"



>>outputQUINEPIG This is a quine


_.txtDEAFPIG: This is a comment
_DEAFPIG: May not work on all systems
>>outputDEAFPIG: Should work most of the time
A.txtDEAFPIG Should work everywhere
_.txtBRAINPIG [If _.txt is already an existing empty file and this text contains matched square brackets.]


(3 files, named "Main.epig", "0.epig", and "1.epig")


<"iconstant", "truth", "0", "1">.epigIMPORTPIG<"iconstant", "truth", "0", "1">.epig





Bitwise Cyclic Tag Interpreter

This means ExtendedPig is a Turing-complete extension of a programming language not even usable for programming at all (Pig).


_.txtDEAFPIG: This should make sure that if the queue is empty, the program effectively halts.
errorcatch.txtNORMALPIG<"fileread", "queue.txt", "0", "1">
c.txtNORMALPIG<"fileread", "productions.txt", "0", "1"> 
productions.txtAPPENDPIG<"fileread", "c.txt", "0", "1">
a<"fileread", "c.txt", "0", "1">.epigIMPORTPIGa<"fileread", "c.txt", "0", "1">.epig


queue.txtNORMALPIG<"fileread", "queue.txt", "1", "END">


c.txtNORMALPIG<"fileread", "productions.txt", "0", "1"> 
productions.txtAPPENDPIG<"fileread", "c.txt", "0", "1">
b<"fileread", "c.txt", "0", "1">.epigIMPORTPIGb<"fileread", "c.txt", "0", "1">.epig


c0<"fileread", "queue.txt", "0", "1">.epigIMPORTPIGc0<"fileread", "queue.txt", "0", "1">.epig





c1<"fileread", "queue.txt", "0", "1">.epigIMPORTPIGc1<"fileread", "queue.txt", "0", "1">.epig




See also