stacky
Download
Skip this Video
Download Presentation
Stacky

Loading in 2 Seconds...

play fullscreen
1 / 15

Stacky - PowerPoint PPT Presentation


  • 90 Views
  • Uploaded on

Stacky. By Andrew Horn And Ryan Kluck. Language Features. The basic data structure that this language utilizes is a stack Each function gets its own stack All variables are assigned memory locations All operations and functions can only be evaluated by being pushed onto the stack.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Stacky' - nellie


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
stacky
Stacky

By

Andrew Horn

And

Ryan Kluck

language features
Language Features

The basic data structure that this language utilizes is a stack

Each function gets its own stack

All variables are assigned memory locations

All operations and functions can only be evaluated by being pushed onto the stack

types of arguments
Types of Arguments

Integers

Function calls

Memory calls

Operator calls

Condition calls

things you can push
Things you can push

Numbers

Functions

Function declarations (lambda expressions)

Operators (including conditionals)

push(1,2,3);

push(:swap);

push(func::{return 0});

push(1,2,+);

push(1,2,<);

return statements
Return Statements

A return statement pushes the returned values back onto the stack the returning function was called from in the order specified in the return statement

The code on the right pushes 2 and 5 onto the stack, then calls swap which returns [5,2] which is concatenated onto the end of the stack in main

func:swap:2{

return(0,1);

}

func:main:{

push(2,5);

push(:swap);

}

basic syntax
Basic Syntax

The example on the right is a properly formatted program that push 1 onto the stack in main, and then pushes the copy function onto the stack

Copy pops 1 parameter off the main stack and returns that element and a copy of that element.

Both the original element and the copy are pushed onto the main stack

func:copy:1{

return(0,0);

}

func:main:{

push(1);

push(:copy);

}

access to the stack
Access To The Stack

A called function may access any number of values from the stack

Any values passed to a function will be popped from the stack

memory
Memory

Memory locations can be assigned to hold any argument as variable

The code on the right pushes swap onto the stack, and then pops it off and stores it in memory.

Then it pushes 1,2,3, and 4 onto the stack

It then pops 4 off the stack and stores it in memory location 1, and pulls swap in from memory location 0

func:swap:2{

return(0,1);

}

func:main:{

push(:swap,>[0]);

push(1,2,3,4,>[1],<[0]);

}

functions
Functions

A function is declared by func:<functionName>:<number of parameters>{}

If number of parameters is not present this value is 0 by default

The number of parameters is how many parameters are popped off of the stack when the function is pushed onto the stack

func:swap:2{

return(0,1);

}

func:two:{

push(2);

return(0);

}

functions continued
Functions Continued

If a function is pushed onto a stack without enough parameters for the function to run, it will remain on stack until it can run, is popped off, or the main function terminates

func:swap:2{

return(0,1);

}

func:main:{

push(1);

push(:swap);

push(2);

push(:swap);

}

if statements
If Statements

An if statement peeks at the values in the stack without popping them

If statements are post fix

The code on the right tests if location the second element in the stack is greater than the top element and if so swaps them

func:main:{

push(2,1);

if(1 0 >){

push(:swap);

}

}

while loops
While Loops

While loops test if a stack location is 0 and iterate until this happens

The code on the right pops values off the stack with each iteration, until the top value is 0

func:pop:1{}

func:main:{

push(0,2,3,4);

while(0){

push(:pop);

}

}

while loops continued
While Loops Continued

While loops can also use conditionals

The code on the right tests if the top two elements on the stack are equal, and if not keeps popping elements off until this condition is met

func:pop:1{}

func:main:{

push(1,2,2,3,4);

while(0 1 !=){

push(:pop);

}

}

potential future improvements
Potential Future Improvements

Strings (should be implemented as a list of characters on the stack)

Lazy evaluation

Overloading

SQL

ad