Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

PROGBOL Implementation

Name: Anonymous 2011-12-28 18:34

Here's something for /prog/:

$dc = <<'PROGBOLDOC';

INITIAL REPORT ON THE ALGORITHMIC LANGUAGE PROGBOL
--------------------------------------------------

Every program should start with:
     __                        __
    / / __  _ __ ___   __ _   / /  (You can write comments here though)
   / / '_ \| '__/ _ \ / _` | / /
  / /| |_) | | | (_) | (_| |/ / 
 /_/ | .__/|_|  \___/ \__, /_/  
     |_|              |___/


I've taken liberty to use some of the language features in a old /prog/ thread to
make something of it. The language picks up on 4 things which have been tacked
together:

    1. Message passing OO
    2. Global user stack
    3. GOTO and COME-FROM
    4. Tail call optimization


SYNTAX
------

The syntax is a straight parse into opcodes for the "virtual machine". There's no
syntactical convention to this language, except mostly that everything is case
sensitive.


EXECUTION MODEL
---------------

Programs are stack oriented, however, unlike forth-likes which eagerly applies
words as they are pushed, appearance of a non-reserved identifier in this
language pushes an object of that name on the stack space, and messages
are sent to the last object on the stack and pops that object off the stack.
OO is message based, and the method name and arity are matched between the
messsage and a method, if such a method name and arity can't be found at
call-time, the IHBT method will handle the message (if IHBT was implemented by
that object). If the IHBT method is missing, the message is sent further up to
be handled by the objects' OP.

Calculated GOTO is available through the LISP instruction, and COME-FROM is
implemented by check during label opcode in the virtual machine.


STRUCTURE
---------

All programs start with the /prog/ ascii logo above.

ITC GRUNNUR.core;
    Includes a source file, standard files shall be GRUNNUR.*.

[def method arg1 arg2 etc] ... [/def]
    Defines a method with arguments and attaches it to the object at the top of
    the stack. Messages are matched to method name and arity, multiple methods
    can use the same name at different arity. The method name may contain
    anything but space, parens and brackets. arguments follow the variable rules
    of only lowercase letters. The top of the stack is not popped, so a
    definition block can consist of an object name, multiple chained [def]s, and
    ended with ANOVWL to pop the object.

[burokku arg1 arg2 etc] ... [/burokku]
    Defines an anonymous function, actually just shorthand for:
    "VIP SUAVE block [def apply arg1 arg2 etc] ... [/def]"
    One invokes the anonymous block with (apply arg1 arg2 etc)
    This places an anonymous object onto the stack.

[spoiler] ... [/spoiler]
    Contents within are comments.


CONTROL FLOW
------------

>>X
    Marks a line

*grabs debugger*
    Prints VM opcodes, stack and exits

CFLAGS JUST KICKED IN YO
    Increments by 1 only the instruction pointer in the virtual machine, this
    has undefined behaviour in multiple cell instructions. Integer operands that
    correspond to VM instructions will behave as those instructions.

GETOUT
    Return from method.

goto X considered harmful
    Jump to a line marked with >>X, actually shorthand for "X LISP".

ifeelkindabadaboutit:(
    Terminate program

>>X Keep it going. :)
    Pops top of stack to see if higher than 0, and if so jumps back or over
    to >>X


VARIABLES
---------

Any lowercase name is an object name, [b]only lowercase letters[/b], no upper
case, no numbers, how does he define ENTERPRISE GRADE NAMING CONVENTIONS,
Terrible!

anylowercasename
    Pushes a method local name scope object, created if it doesn't exist.
   
this anylowercasename.
    Pushes an object local name scope object, created if it doesn't exist.
    Note the period (.).
   
$anylowercasename
    Pushes a global name scope object, created if it doesn't exist. All standard
    objects ($object, $string, $number, $array) are global.

   
STACK
-----

[quote]Hello, world![/quote]
    Pushes a string literal object.

1234
    Pushes a number literal object.

(anyCase0-9Numbers_And_(Dashes)*CharsExcept-SpacenParens ...)
    A message clause, pops the last object on the stack and sends that object
    the message. Message name may contain anything but the space and parens, it
    can also contain brackets but only if the message will be handled by IHBT
    instead of a def message block. Messages that precedes right before the
    closing of the method body, and right before GETOUT instructions are tail
    call optimized.
   
(my-other [object] is-a [object])
    Swap two method local or global scope objects, NOT a message despite the
    syntax.

/read/prog/1217887165/
    Pop an object from the stack and do nothing with it. Repeated use of this
    instruction will be awkward for any but the enterprise copypaste programmer,
    so the syntactic sugar ANOVWL (short for And Nothing Of Value Was Lost) is
    provided as shorthand.

*pop-> anylowercasename*
    Pops the topmost object into a method local scope variable.
   
ABC "program"
    Run an ABC program, "program" is not a string literal, a number is popped
    from the stack to the abc accumulator, the "program" executed and then the
    accumulator after completion is pushed back onto the stack.
    http://esolangs.org/wiki/ABC

CAR, CDR, CADR, CAADR, etc.
    Expands to (car) and (cdr) message sequence in backwards order, so CDAR
    makes (car) (cdr), assuming the object it will be sent to will do something
    with them (currently nothing uses car and cdr methods).

COME-FROM >>10
    On passing by marker >>10, continue execution here.

DONTHELPHIM
    Use the top object of the stack as the exception object and throws an
    exception.

ENTERPRISE SYSCALL #X
    Serious instruction, generally a way to extend the language and VM with
    useful facilities without creating more special instructions.
   
LISP
    Pop a number from the stack and goto that number.
   
LN
    Print Newline.

NULLx#
    where # is a non-negative integer it will be replaced with 0 # times.
    Note: could perhaps be a $null object instead in a future revision.

PUT
    Performs a message send (*grabs-string*), and then issue enterprise syscall #1
    which pops and print the top object which must be a string object to standard
    output.

SUAVE parentobject
    Sets the current top object on the stack's OP (parent object) to parentobject.
    The TOAD keyword after SUAVE parentobject is reserved for future use and
    currently does nothing. parentobject must be a global scope object name without
    the $.

The Sussman
    Clears stack to a clean slate.
   
this.
    Pushes current object to stack. Only usable in method scope. Note the
    period (.).
       
VIP
    Push an anonymous object onto the stack.
   
IN B4
    ...
FU someexception ;_;
    ...
YHBT
    An exception handling block, upon an exception, the exception object thrown
    is compared with each FU until a match is found, otherwise it is propagated
    upwards to the parent exception block. Runtime halts on unhandled exceptions.


COMMON METHODS
--------------

(*grabs-string*)
    Object must push a string on stack.
(numbercruncher)
    Object must push a number on stack.
(IHBT)
    Universal message receiver, this method has 0 arity and has to pop from the
    stack the following in given order:
      1. message name as string
      2. message arity as number
      3. argn, ... arg2, arg1, etc. (note order)


ABC SUBLANGUAGE
---------------

a - Increment the accumulator
b - Decrement the accumulator
c - Output the accumulator
d - Invert accumulator
r - Set accumulator to random number 0-accumulator
n - Set accumulator to 0
$ - Toggle ASCII output mode.
l - Loop back
; - Debug.


RESERVED AND NOT IMPLEMENTED
----------------------------

EXPERT PROGRAMMER ... KTHX
    This interpreter doesn't emit assembler, so anything appearing within is
    ignored and a warning message is emitted.

nowYouHaveTwoProblems
    Concurrency will be in a later version, ideally objects would encapsulate
    process and should take advantage of the message passing concept in an
    asynchronous manner ala Erlang.

VALID PERL CODE FOLLOWS BELOW.

PROGBOLDOC

Name: Anonymous 2011-12-28 18:57

>>2'
>using perl as your VM


IHBT, this is gonna run even slower than java

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List