PH Logo
Logo intepreter modeled after UCB Logo.
/Users/paul/Documents/phlogo/core/BasicVerbs.cpp
00001 /*
00002  *  BasicVerbs.cpp
00003  *
00004  *  Author: Paul Hamilton
00005  *      Date: 13 Jun 2011
00006  *
00007  */
00008 
00009 #include "Verbs.h"
00010 
00011 #include "Interpreter.h"
00012 #include "Console.h"
00013 #include "World.h"
00014 #include "Thing.h"
00015 #include "Turtle.h"
00016 #include "Exceptions.h"
00017 #include "Operator.h"
00018 
00019 #include <boost/lexical_cast.hpp>
00020 #include <math.h>
00021 
00022 using namespace std;
00023 using namespace boost;
00024 
00025 namespace phlogo {
00026 
00027 void Verbs::print(TokenStream *ts) {
00028 
00029         pThing thing;
00030         _itp->getNextThing(_world, ts, &thing);
00031         _world->getConsole()->outputLine(thing->str());
00032 }
00033 
00034 void Verbs::clearscreen(TokenStream *ts) {
00035         _world->getConsole()->reset();
00036     if (_world->getTurtle())
00037         _world->getTurtle()->clear();
00038 }
00039 
00040 void Verbs::add(TokenStream *ts) {
00041     
00042     Add(_world).doOp(_itp, _world, ts);
00043 }
00044 
00045 void Verbs::sub(TokenStream *ts) {
00046     
00047     Sub(_world).doOp(_itp, _world, ts);
00048 }
00049 
00050 void Verbs::mul(TokenStream *ts) {
00051 
00052     Mul(_world).doOp(_itp, _world, ts);
00053 }
00054 
00055 void Verbs::div(TokenStream *ts) {
00056 
00057     Div(_world).doOp(_itp, _world, ts);
00058 }
00059 
00060 void Verbs::make(TokenStream *ts) {
00061 
00062         string name = getWord(ts);
00063 
00064         pThing thing;
00065         _itp->getNextThing(_world, ts, &thing);
00066 
00067         _world->setThing(name, thing, false);
00068 }
00069 
00070 void Verbs::thing(TokenStream *ts) {
00071 
00072         _world->setResult(_world->getThing(getWord(ts)));
00073 
00074 }
00075 
00076 void Verbs::output(TokenStream *ts) {
00077 
00078         _itp->getVerbs()->run(ts);
00079 
00080 }
00081 
00082 }
 All Classes Functions