1. SEX Inside!

Heh?

Wha?

K...

That SEX lang jagama crap dick turd thingy thing
worked out pretty fine.

I want some people to betatest it, just the language
core, but since it was designed and optimised to be
compiled with DJGPP, and all yall don't trust me with
EXEs, I listed the source in this mail.
You will HAVE to translate it to C and compile with
DJGPP, it's mandatory, or else the algorithms it uses
are about 10 times slower as they were optimised for C
output.

Here it is;
--------------CODE START----------------------------
-- The 'SEX' Programming Language
-- Severely Exaturated Xerography

-- By Mike The Spike


include get.e
without warning

-- Globals
sequence memory, code, symbols, callables
memory = {}					-- Memory used by all SEX programs
code   = {}					-- Virtual Code that makes up a SEX
program

symbols = {}				-- Literal symbols for elements in
memory
callables = {}				-- Routine ids for all built-in
functions

integer idx
idx = 1						-- Code Pointer

-- Virtual Machine Codes
procedure bitchslap(integer a, object b)
	memory[a] = b
end procedure

procedure rape(integer a, object b)
	memory[a] += b
end procedure

procedure cumshoot(integer a, object b)
	memory[a] -= b
end procedure

procedure beat(integer a, object b)
	memory[a] /= b
end procedure

procedure slap(integer a, object b)
	memory[a] *= b
end procedure

procedure scat(integer a, object b)
	memory[a] &= b
	puts(1,memory[a])
end procedure

procedure hicky(integer a, object b)
	idx = memory[a]
end procedure

procedure husband(integer a, object b)
	abort(0)		-- Fix this to read 'abort(b)'
end procedure

procedure phone(integer a, object b)
	call_proc(callables[a],{b})
end procedure

-- Built-In Library Routines
procedure spit(sequence params)
	puts(params[1],params[2])
end procedure
callables = callables & routine_id("spit")

-- Virtual Machine Code Routine Ids

constant rape_id 	  = routine_id("rape"),
		 bitchslap_id = routine_id("bitchslap"),
		 cumshoot_id  = routine_id("cumshoot"),
		 beat_id  	  = routine_id("beat"),
		 slap_id  	  = routine_id("slap"),
		 scat_id  	  = routine_id("scat"),
		 hicky_id 	  = routine_id("hicky"),
		 husband_id   = routine_id("husband"),
		 phone_id      = routine_id("phone")

-- Functions
function parse(sequence what)
object word, ret
word = ""
ret = {}

	for i = 1 to length(what) do
		if what[i] != ' ' and what[i] != '\t' and what[i] !=
'\n' then
			if what[i] != 10 then
			word = word & what[i]
			end if
		else
				ret = append(ret,word)
				word = ""
		end if
	end for
ret = append(ret,word)
return ret
end function

function id_from_symbol(sequence symbol)
-- Retrieve literal 'symbol's memory ID
	for i = 1 to length(symbols) do
		if equal(symbols[i], symbol) then
			return i
		end if
	end for
return -1
end function

function is_reserved(sequence what)
-- Check to see if 'what' is a reserved symbol
if equal(what,"rape") or equal(what,"bitchslap") or
equal(what,"hiton") or
   equal(what,"cumshoot") or equal(what,"slap") or
equal(what,"scat") or
   equal(what,"hicky") then
	return 1
else
	return 0
end if
end function

function is_digit(integer what)
-- Is ASCII character 'what' a digit?
-- NOTE: There's a faster way to do this but
-- won't work with multibyte chars.
if what = '0' or what = '1' or what = '2' or what =
'3' or 
   what = '4' or what = '5' or what = '6' or what =
'7' or
   what = '8' or what = '9' or what = '0' then
		return 1
	else
		return 0
end if
end function

function is_numerical(sequence what)
-- Is 'what' numerical?
integer tf
tf = 1
for i = 1 to length(what) do
		if not is_digit(what[i]) and what[i] != '.' then
			tf = 0
		end if
end for
return tf
end function

function resolve(sequence what)
-- Resolve token 'what' (ie. if it's a symbol, return
the data associated with it, else return value(what))
object ret
if is_reserved(what) then
	printf(1,"You used %s as a symbol!\n %s is a reserved
keyword! rename %s!",{what})
	abort(1)
end if
if what[1] = '\"' then
	return what
end if
	ret = id_from_symbol(what)
    if ret = -1 then
		printf(1,"%s hasn't being hiton! (ie.
declared)",{what})
		abort(1)
	else
		return memory[ret]
	end if
end function

function atoi(sequence what)
-- ASCII To Int/Float/Sequence
object ret
ret = value(what)
return ret[2]
end function

procedure interpret(sequence what)

-- Run SEX code 'what'

object toks, foo
toks = parse(what)

for i = 1 to length(toks) do
	if equal(toks[i],"hiton") then
		if is_reserved(toks[i+1]) then
			printf(1,"Huh? Why did you type hiton %s?\nThat's a
reserved word!",{toks[i+1]})
			abort(0)
		end if
		symbols = append(symbols,toks[i+1])
		memory = append(memory,0)
	elsif equal(toks[i],"bitchslap") then
		code = append(code,bitchslap_id)
		code = append(code,id_from_symbol(toks[i+1]))
		if is_numerical(toks[i+3]) then
			code = append(code,atoi(toks[i+3]))
			memory[id_from_symbol(toks[i+1])] = atoi(toks[i+3])
		else
			code = append(code,resolve(toks[i+3]))
		end if
	elsif equal(toks[i],"rape") then
		code = append(code,rape_id)
		code = append(code,id_from_symbol(toks[i+1]))
		if is_numerical(toks[i+3]) then
			code = append(code,atoi(toks[i+3]))
			memory[id_from_symbol(toks[i+1])] = atoi(toks[i+3])
		else
			code = append(code,resolve(toks[i+3]))
		end if
	elsif equal(toks[i],"cumshoot") then
		code = append(code,cumshoot_id)
		code = append(code,id_from_symbol(toks[i+1]))
		if is_numerical(toks[i+3]) then
			code = append(code,atoi(toks[i+3]))
		else
			code = append(code,resolve(toks[i+3]))
		end if
	elsif equal(toks[i],"beat") then
		code = append(code,beat_id)
		code = append(code,id_from_symbol(toks[i+1]))
		if is_numerical(toks[i+3]) then
			code = append(code,atoi(toks[i+3]))
		else
			code = append(code,resolve(toks[i+3]))
		end if
	elsif equal(toks[i],"slap") then
		code = append(code,slap_id)
		code = append(code,id_from_symbol(toks[i+1]))
		if is_numerical(toks[i+3]) then
			code = append(code,atoi(toks[i+3]))
		else
			code = append(code,resolve(toks[i+3]))
		end if
	elsif equal(toks[i],"scat") then
		code = append(code,scat_id)
		code = append(code,id_from_symbol(toks[i+1]))
		if is_numerical(toks[i+3]) then
			code = append(code,sprintf("%d",{atoi(toks[i+3])}))
		else
			code = append(code,resolve(toks[i+3]))
		end if
	elsif equal(toks[i],"phone") then
		code = append(code,phone_id)
		if is_numerical(toks[i+1]) then
			printf(1,"Hey! You tried to phone a number! See?:
phone %s!",{toks[i+3]})
			abort(0)
		else
			if equal(toks[i+1],"spit") then
				code = append(code,1)
				foo = {}
				for ix = i+2 to length(toks) do
					if equal(toks[ix],"hangup") then
						exit
					else
						if is_numerical(toks[ix]) then
							foo = append(foo,atoi(toks[ix]))
						else
							foo = append(foo,resolve(toks[ix]))
						end if
					end if
				end for
				code = append(code, foo)
			end if
		end if
	end if
end for
-- Make sure the last code executed is a 'husband'
instruction
code = append(code,husband_id)
code = append(code,0)
code = append(code,0)
-- Start interpreting...
while 1 do
	call_proc(code[idx],{code[idx+1],code[idx+2]})
	idx+=3
end while
print(1,toks)
end procedure


-- Temporary Interpreter Front-end
puts(1,"SEX HighSpeed Interpreter\n")
puts(1,"DOS32 Version 1.0\n")
puts(1,"\nfile name to execute? ")
object n, str, line
n = gets(0)
n = n[1..length(n)-1]
integer fptr
fptr = open(n,"r")
if fptr = -1 then
	printf(1,"\nCan't open %s...\n",{n})
	abort(0)
end if
str = ""
while 1 do
	line = gets(fptr)
	if atom(line) then exit end if
	str &= line
end while
clear_screen()

interpret(str)
puts(1,str)
if wait_key() then end if
---------------------CODE END-------------------------

Paste the above code in a .ex file and translate it to
C, then run it.

You will be prompted for a source file to execute like
in Euphoria.

This version above is for testing the
parsing/interpretation core.
Therefore, only a built-in printf routine can be
called.

An example of a SEX program you can run with above
interpreter;

hiton age
hiton name
bitchslap age with 17
bitchslap name with "Mike The Spike = "
scat name with age
phone pimp 1 name hangup

Some explenation about the aboce lines.
hiton age - declares variable  'age'
hiton name - declares variable 'name'
bitchslap age with 17 - sets var 'age' to 17
bitchslap name with "Mike_The_Spike_=_" - sets name to
string
scat name with age - concatenate 'age' to string
'name'
phone pimp 1 name hangup - 'phone' calls a built-in
function, in this case 'pimp', wich prints out a
string or number to the screen. '1' is the destination
(ie. screen) to print on, 'name' is the string to 
print. 'hangup' ends the argument list.

Note that you can not type down strings wich contain
spaces in them. This is because of some code I forgot
the rewrite from the last (more complete) version of
the parser.
That's why I replace spaces with underscores.
You should do to.


Tell me if you find any bugs, wich it should be packed
with I presume.  (I dunno...)



Mike The Spike

new topic     » topic index » view message » categorize

2. Re: SEX Inside!

Shit!
I coded in an error in a program written in my own
programming language :(
'pimp' should be 'spit'.
Do'h!

So code 'phone spit' instead of 'phone pimp'.


Mike The Spike

new topic     » goto parent     » topic index » view message » categorize

3. Re: SEX Inside!

On 5 Feb 2001, at 12:38, Mike The Spike wrote:


> constant rape_id 	  = routine_id("rape"),

Mike, have you ever had to fight off a rapist?

Kat

new topic     » goto parent     » topic index » view message » categorize

4. Re: SEX Inside!

--- Kat <gertie at PELL.NET> wrote:
> On 5 Feb 2001, at 12:38, Mike The Spike wrote:
> 
> 
> > constant rape_id 	  = routine_id("rape"),
> 
> Mike, have you ever had to fight off a rapist?
> 
> Kat

Nah...
Last time I started fighting with myself they put me
in a mental institute....

Mike The Spike
(Woops!)
>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu