PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
ParserTest.cpp
Go to the documentation of this file.
1//* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
3// Name: ParserTest.cpp
4// Purpose: This tests the parser/evaluator
5// Author: Shane T. Mueller, Ph.D.
6// Copyright: (c) 2003 Shane T. Mueller <smueller@umich.edu>
7// License: GPL 2
8//
9//
10//
11// This file is part of the PEBL project.
12//
13// PEBL is free software; you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation; either version 2 of the License, or
16// (at your option) any later version.
17//
18// PEBL is distributed in the hope that it will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21// GNU General Public License for more details.
22//
23// You should have received a copy of the GNU General Public License
24// along with PEBL; if not, write to the Free Software
25// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
28#include "../base/Evaluator.h"
29#include "../base/grammar.tab.hpp"
30#include "../base/PNode.h"
31#include "../base/Loader.h"
32#include "../base/PComplexData.h"
33#include "../base/PList.h"
34#include "../libs/PEBLObjects.h"
35#include <iostream>
36
37using std::cerr;
38using std::endl;
39
41
42int PEBLInterpret( int argc, char **argv )
43{
44
45 //This sets the video driver
46 setenv("SDL_VIDEODRIVER", "dga",1); //Requires to run with root privileges, fullscreen.
47 setenv("SDL_VIDEODRIVER", "x11",1);
48
50 FunctionMap * myFunctionMap= new FunctionMap();
51
52 PNode *node1;
53 node1=NULL;
54
55
56 //First, parse the file.
57 node1 = parse();
58 cerr << "---------Program Parsed---------" << endl;
59
60 cerr << "---------Loading Program---------" << endl;
61 //Now, load it into the environment.
62 myLoader = new Loader(myFunctionMap);
63
65
66 cerr <<"Analyzing code for functions." << endl;
67 myLoader->FindFunctions(node1);
68
69 cerr << "Loading Library functions." << endl;
71
72 cerr << "Loaded Functions: " << endl;
74
75
76
77 cerr << "Creating a PlatformEnvironment\n";
79
80
81 cerr << "---------Creating Evaluator-----" << endl;
82
83 PList * pList = new PList();
84 pList->PushFront(Variant(0));
85
86 cout << "Getting list inside list: " << *pList <<endl;
87
88 PComplexData * pcd = new PComplexData(pList);
89 Variant v = Variant(pcd);
90
91 Evaluator myEval = Evaluator(myFunctionMap, v);
92 //Now, everything should be F-I-N-E fine.
93
94 cerr << "--------Getting main function---" << endl;
96
97 if(node1)
98 {
99
100 cerr << "---------Evaluating Program-----" << endl;
101 //Execute everything
102 myEval.Evaluate(node1);
103 return 0;
104 }
105 else
106 {
107 cerr << "Error: Can't evaluate program" << endl;
108 return 1;
109 }
110
111}
112
113
114
115
116int main(int argc, char **argv)
117{
118 cout << "This testing program is deprecated.\n";
119
120 //return PEBLInterpret(argc, argv);
121 return 0;
122}
123
#define NULL
Definition BinReloc.cpp:317
Evaluator * myEval
Definition PEBL.cpp:188
Loader * myLoader
Definition PEBL.cpp:219
int main(int argc, char **argv)
int PEBLInterpret(int argc, char **argv)
PNode * parse()
This class has got everything you need to evaluate stuff.
bool Evaluate(const PNode *node)
void DumpFunctionSet()
Definition Loader.cpp:385
void LoadUserFunctions(OpNode *node)
Definition Loader.cpp:147
void LoadLibraryFunctions()
Definition Loader.cpp:195
void FindFunctions(const PNode *Node)
Definition Loader.cpp:88
PNode * GetMainPEBLFunction()
Definition Loader.cpp:372
Definition PList.h:45
Definition PNode.h:45
void MakeEnvironment(PEBLVideoMode mode, PEBLVideoDepth depth, bool windowed, bool resizeable, bool unicode)
This function instantiates the namespace-viewable.