PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
VCGMaker.cpp
Go to the documentation of this file.
1//* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
3// Name: src/apps/Variant.cpp
4// Purpose: Makes VCG file from a Pebl program.
5// Author: Shane T. Mueller, Ph.D.
6// Copyright: (c) 2003-2026 Shane T. Mueller <smueller@obereed.net>
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#include "../base/PNode.h"
28#include "../base/grammar.tab.hpp"
29#include "../base/VCG.h"
30
31#include "../base/Evaluator.h"
32#include "../devices/PEventLoop.h"
33
34#include <iostream>
35
36
37using std::cerr;
38using std::cout;
39using std::endl;
40
41PNode * parse(const char* filename);
42
49
50int PEBLInterpret( int argc, char **argv )
51{
52
53 PNode * tmp = NULL;
54
55 //Process the first command-line argument.
56 cerr << "Processing PEBL Source File: " << argv[1] << endl;
57 PNode * head = parse(argv[1]);
58
59 //If there are any more arguments, process them by accomodating them
60 //inside a function list.
61 for(int i = 2; i<argc; i++)
62 {
63 cerr << "Processing PEBL Source File: " << argv[i] << endl;
64
65 //Make a new node.
66 tmp = parse(argv[i]);
67
68 //Now, make a new node that contains head and tmp.
69 head = new OpNode(PEBL_FUNCTIONS, head, tmp, "Unknown file",0);
70 }
71
72
73 //Now, head should point to the top of the tree containing all of the source.
74 if(head)
75 {
76 cerr << "---------Encoding VCG GRAPH---------" << endl;
77 VCG myVCG;
78 myVCG.MakeGraph(head);
79
80 cerr << "---------Printing VCG GRAPH---------" << endl;
81 myVCG.PrintGraph();
82
83 cerr << "---------FINISHED VCG GRAPH---------" << endl;
84
85 return 0;
86 }
87
88 cerr << "Error: parsed node was empty" << endl;
89 return 1;
90}
91
92
93
94//The following is the entry point for the command-line version
95int main(int argc, char **argv)
96{
97 return PEBLInterpret(argc, argv);
98}
99
#define NULL
Definition BinReloc.cpp:317
PNode * head
Definition PEBL.cpp:220
PNode * parse()
int main(int argc, char **argv)
Definition VCGMaker.cpp:95
int PEBLInterpret(int argc, char **argv)
Definition VCGMaker.cpp:50
static const PNode * gEvalNode
static PEBLPath gPath
static PEventLoop * mEventLoop
static VariableMap gGlobalVariableMap
static FunctionMap mFunctionMap
Initiate some static member data.
Definition PNode.h:45
Definition VCG.h:44
void PrintGraph()
Definition VCG.cpp:71
void MakeGraph(const PNode *node)
Definition VCG.cpp:65