-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram.h
executable file
·710 lines (650 loc) · 20.6 KB
/
program.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
#ifndef __PROGRAM__
#define __PROGRAM__
/*obsahuje vsechny tridy pro prevedeni programu na strom objektu validaci a nasledne vykonani*/
#include <map>
#include <vector>
#include <stack>
#include <stdlib.h>
#include <typeinfo>
#include <string>
#include <iostream>
#include "lexan.h"
#include "exception.h"
using namespace std;
/*vycet moznych typu hodnot*/
enum TypeValue{ INT_VALUE, DOUBLE_VALUE, BOOLEAN_VALUE, STRING_VALUE, VOID_VALUE, NULL_VALUE, CLASS_VALUE, OBJECT_VALUE };
class Class;
class Block;
class Function;
class Expression;
class Declaration;
class WhileCommand;
class Function;
class Program;
class Block;
/*tridy predstavujici jednolive hodnoty pro vypis je pretizen operator <<*/
/*obecna hodnota*/
class Value{
bool lvalue;
public:
Value(){ lvalue = false; }
virtual TypeValue getType(){ return INT_VALUE; }
void setLValue(bool l){ lvalue = l; }
bool getLValue(){ return lvalue; }
};
/* kopiruje hodnotu z v do val, implementace v expression.cpp */
void copyValue(Value* v, Value* val);
class Void: public Value{
public:
virtual TypeValue getType(){ return VOID_VALUE; }
};
class Null: public Value{
public:
virtual TypeValue getType(){ return NULL_VALUE; }
friend ostream& operator<<(ostream& o, Null& n){ return o << "null"; }
};
class Boolean: public Value{
bool value;
public:
Boolean(){ value = false; }
Boolean(bool v){ value = v; }
void setValue(bool v){ value = v; }
bool getValue(){ return value; }
virtual TypeValue getType(){ return BOOLEAN_VALUE; }
friend ostream& operator<<(ostream& o, Boolean& n){ return o << (n.value?"true":"false"); }
};
class Integer: public Value{
int value;
public:
Integer(){ value = 0; }
Integer(int v){ value = v; }
void setValue(int v){ value = v; }
int getValue(){ return value; }
virtual TypeValue getType(){ return INT_VALUE; }
friend ostream& operator<<(ostream& o, Integer& n){ return o << n.value; }
};
class Double: public Value{
double value;
public:
Double(){ value = 0; }
Double(double v){ value = v; }
void setValue(double v){ value = v; }
double getValue(){ return value; }
virtual TypeValue getType(){ return DOUBLE_VALUE; }
friend ostream& operator<<(ostream& o, Double& n){ return o << n.value; }
};
class String: public Value{
string value;
public:
String(){ value = ""; }
String(char* v){ value = v; }
void setValue(const char* v){ value = v; }
const char* getValue(){ return value.c_str(); }
virtual TypeValue getType(){ return STRING_VALUE; }
friend ostream& operator<<(ostream& o, String& n){ return o << n.value; }
virtual ~String(){}
};
class Object: public Value{
/* zda je object null */
bool null;
map<string,Value*> fields;
char type[100];
/*po validaci obsahuje tridu podle type*/
Class* c;
public:
Object(char* type){ null = true; strncpy(this->type,type,100); }
virtual TypeValue getType(){ return OBJECT_VALUE; }
void setClass(Class* cl){ c = cl; }
Class* getClass(){ return c; }
bool isNull(){ return null; }
void setNull(bool n){ null = n; }
char* getTypeName(){ return type; }
/*pouziva pri vytvareni nove instance*/
void initField(char* name, Value* v){ fields[name]=v; }
/*nastavovani fieldu behem zivota instance*/
void setField(char* name, Value* v){ copyValue(v,fields[name]); }
Value* getField(char* name){ return (fields)[name]; }
/*kopirovani*/
void setValue(map<string,Value*> f){ fields = f; }
map<string,Value*> getValue(){ return fields; }
virtual ~Object(){}
};
/*pouziva se kdyz pristupujeme ke statickym clenum trid*/
class ClassValue: public Value{
Class* c;
public:
virtual TypeValue getType(){ return CLASS_VALUE; }
void setClass(Class* cl){ c = cl; }
Class* getClass(){ return c; }
};
/*obecny uzel vyrazu*/
class Node{
protected:
/*radek kde se uzel nachazi*/
int line;
/*hodnota co uzel vraci*/
Value* value;
/*indikuje zda budeme prirazovat*/
bool assignment;
public:
Node(){ value = NULL; assignment = false;}
/*overeni zda je vyraz korektni , datove typy, lvalue atd.*/
virtual Value* validate()=0;
/*vykonani*/
virtual Value* eval()=0;
void setLine(int l){ line = l; }
void setAssignment(bool a){ assignment=a; }
virtual ~Node(){
if (value!=NULL)
delete value;
}
};
class BinaryOperation: public Node{
protected:
Node* right;
Node* left;
public:
BinaryOperation(Node* left, Node* right){ this->left = left; this->right = right; }
virtual Value* validate()=0;
virtual Value* eval()=0;
~BinaryOperation(){ if (right!=NULL) delete right; if (left!=NULL) delete left; }
};
class UnaryOperation: public Node{
protected:
Node* node;
public:
UnaryOperation(Node* node){ this->node = node; }
virtual Value* validate()=0;
virtual Value* eval()=0;
~UnaryOperation(){
if (node!=NULL)
delete node;
}
};
class Constant: public Node{
public:
Constant(Value* v){ value = v; }
virtual Value* validate(){ return value; }
virtual Value* eval(){ return value; }
};
class OperatorNew: public Node{
char type[100];
vector<Node*> params;
Expression* e;
public:
OperatorNew(char* t, vector<Node*> p, Expression* ex);
virtual Value* validate();
virtual Value* eval();
~OperatorNew();
};
/*trida predstavujici pristup k promennym a to jak deklarovanym tak k polozkam objektu*/
class Variable: public UnaryOperation{
char name[100];
Expression* ex;
ClassValue* cv;
Value* createValue(Value*);
public:
Variable(Node* parentObject, char* name, Expression* e);
virtual Value* validate();
virtual Value* eval();
~Variable();
};
class FunctionCall: public UnaryOperation{
vector<Node*> params;
char name[100];
Expression* ex;
/* po validaci funkce ktera se bude volat */
Function* f;
public:
FunctionCall(Node* parent, char* n, vector<Node*> p, Expression* e);
virtual Value* validate();
virtual Value* eval();
~FunctionCall();
};
class UnaryMinus: public UnaryOperation{
public:
UnaryMinus(Node* n):UnaryOperation(n){}
virtual Value* validate();
virtual Value* eval();
};
class Negation: public UnaryOperation{
public:
Negation(Node* n):UnaryOperation(n){}
virtual Value* validate();
virtual Value* eval();
};
class Plus: public BinaryOperation{
public:
Plus(Node* l, Node* r): BinaryOperation(l,r){}
virtual Value* validate();
virtual Value* eval();
};
class Minus: public BinaryOperation{
public:
Minus(Node* l, Node* r): BinaryOperation(l,r){}
virtual Value* validate();
virtual Value* eval();
};
class Mul: public BinaryOperation{
public:
Mul(Node* l, Node* r): BinaryOperation(l,r){
}
virtual Value* validate();
virtual Value* eval();
};
class Div: public BinaryOperation{
public:
Div(Node* l, Node* r): BinaryOperation(l,r){}
virtual Value* validate();
virtual Value* eval();
};
class Equal: public BinaryOperation{
public:
Equal(Node* l, Node* r): BinaryOperation(l,r){}
virtual Value* validate();
virtual Value* eval();
};
class NotEqual: public BinaryOperation{
public:
NotEqual(Node* l, Node* r): BinaryOperation(l,r){}
virtual Value* validate();
virtual Value* eval();
};
class Greater: public BinaryOperation{
public:
Greater(Node* l, Node* r): BinaryOperation(l,r){}
virtual Value* validate();
virtual Value* eval();
};
class GreaterOrEqual: public BinaryOperation{
public:
GreaterOrEqual(Node* l, Node* r): BinaryOperation(l,r){ }
virtual Value* validate();
virtual Value* eval();
};
class Lesser: public BinaryOperation{
public:
Lesser(Node* l, Node* r): BinaryOperation(l,r){}
virtual Value* validate();
virtual Value* eval();
};
class LesserOrEqual: public BinaryOperation{
public:
LesserOrEqual(Node* l, Node* r): BinaryOperation(l,r){}
virtual Value* validate();
virtual Value* eval();
};
class And: public BinaryOperation{
public:
And(Node* l, Node* r): BinaryOperation(l,r){}
virtual Value* validate();
virtual Value* eval();
};
class Or: public BinaryOperation{
public:
Or(Node* l, Node* r): BinaryOperation(l,r){}
virtual Value* validate();
virtual Value* eval();
};
class Assignment: public BinaryOperation{
public:
Assignment(Node* l, Node* r): BinaryOperation(l,r){}
virtual Value* validate();
virtual Value* eval();
};
/*pomocna trida, pri prekladu se do ni uklada seznam parametru pro volani funkce*/
class HelperParams{
vector<Node*> params;
public:
void addParam(Node* n){ params.push_back(n); }
vector<Node*> getParams(){ return params; }
};
class Expression{
/*pokud dojde k chybe ulozi se zde*/
ParserException* error;
/* je vyraz prikaz */
bool statement;
/* pro fieldy je zde trida ve ktere jsou deklarovany */
Class* c;
/* pro lokalni a parametry funkce se nastavuje blok (funkce je take blok)*/
Block* b;
Lexan* lexan;
LexElement token;
Node* parsedExpression;
/* metody pro expanze neterminalu */
Node* Y();
Node* YC(Node* n);
Node* X();
Node* XC(Node* n);
Node* B();
Node* BC(Node* n);
Node* E();
Node* EC(Node*);
Node* T();
Node* TC(Node*);
Node* F();
Node* FC(Node*,char*);
HelperParams* F3(HelperParams*);
HelperParams* F4(HelperParams*);
Node* F5(Node*);
Node* F6(Node*);
public:
Expression();
Expression(Lexan* lexan, LexElement& token);
void setClass(Class* c){ this->c = c; }
void setBlock(Block* b){ this->b = b; }
Block* getBlock(){ return b; }
Value* eval(){ return parsedExpression->eval(); }
Value* validate(){ return parsedExpression->validate(); }
bool getStatement(){ return statement; }
void setNode(Node* n){ parsedExpression=n; }
/* najde nejblizsi deklarovanou promennou*/
Value* findValue(char* name){ return this->findValue(name,false); }
/* najde nejblizsi deklarovanou promennou, muzeme urcit zda chceme pouze localni promenne*/
Value* findValue(char* name, bool local);
/* trida ve ktere je vyraz pouzit */
Class* parentClass();
/* po dokonceni prekladu vyrazu vraci posledni token aby se mohlo navazat v prekladu programu*/
LexElement getToken(){ return token; }
ParserException* getError() { return error; }
void setError(ParserException* e){ if (error==NULL) error = e; }
~Expression(){ delete parsedExpression; }
};
/*obecny prikaz*/
class Command{
protected:
/*radek kde se nachazi*/
int line;
public:
/* vykonani */
virtual void execute()=0;
/* validace */
virtual void validate()=0;
void setLine(int l){ line = l; }
int getLine(){ return line; }
virtual ~Command(){
}
};
/*prikaz obsahujici pouze vyraz*/
class ExpressionCommand: public Command{
Expression* ex;
public:
ExpressionCommand(Expression* e){ ex = e; }
virtual void execute(){ ex->eval(); }
virtual void validate();
/*obsahuje prikaz dany vyraz pouziva se pro hledani deklaraci ktere se maji vlozit na zasobnik pri volani funkce*/
bool containExpression(Expression* e){ return ex==e; }
~ExpressionCommand(){ if(ex!=NULL) delete ex; }
};
class Declaration : public Command{
/* blok kde se deklarace nachazi*/
Block* b;
/* inicializacni vyraz */
Expression* expr;
/* kazda promenna ma svuj zasobnik ... to je luxus co :) */
stack<Value*> valStack;
/* pred validaci trida ve ktere je deklarace po ni je to trida deklarovaneho objecktu*/
Class* c;
/*identifikace typu*/
TypeValue type;
/*pokud je object tak jeho jmeno*/
char typeName[100];
/* jmeno deklarovane promenne*/
char name[100];
/* je to staticka promenna */
bool stat;
Value* val;
/*vytvari novou Value na zaklade deklarace*/
Value* createValue();
public:
Declaration(Expression* e, TypeValue tv, char* tn, char* n, bool s);
virtual void validate();
virtual void execute();
void setClass(Class* cl){ c = cl; }
void setBlock(Block* bl){ b = bl; }
char* getName(){ return name; }
bool isStatic(){ return stat; }
/*obsahuje prikaz dany vyraz pouziva se pro hledani deklaraci ktere se maji vlozit na zasobnik pri volani funkce*/
bool containExpression(Expression* e){ return expr==e; }
Expression* getExpression(){ return expr; }
/*kazda vkladani a vybirani promennych ze zasobniku pri volani funkce*/
void pushOnStack();
void popFromStack();
Value* getValue();
~Declaration(){ if(expr!=NULL) delete expr; if(val!=NULL) delete val; }
};
class Block: public Command{
/* nadrazeny blok */
Block* parent;
/* seznam deklaraci v bloku*/
vector<Declaration*> declarations;
/* seznam prikazu */
vector<Command*> commands;
public:
Block(){ parent = NULL; }
Block(Block* p){ parent = p; }
void setParentBlock(Block* b){ parent = b; }
virtual Class* getClass(){ return parent->getClass(); }
/* najde promennou, muzeme urcit zda chceme jen lokalni*/
virtual Value* findValue(char* name, bool local);
void addCommand(Command* c){ commands.push_back(c); }
virtual void validate();
virtual void execute();
/* zjistuje zda za return nejsou dalsi prikazy*/
void checkReturn();
/* zjistuje zda funkce ktera neni void ma return*/
void checkReturn2();
virtual Function* getParentFunction(){ return parent->getParentFunction(); }
/* ziskani seznamu lokalnich deklaraci, vytvorenych pred pouzitim vyrazu e*/
virtual bool getLocalDeclaration(Expression* e, vector<Declaration*>* ld);
~Block();
};
/* pouze strednik */
class EmptyCommand: public Command{
virtual void execute(){}
virtual void validate(){}
};
class IfCommand: public Command{
Command* command;
Expression* ex;
public:
IfCommand(Command* c, Expression* e){ ex = e; command = c; }
virtual void validate();
virtual void execute();
/* zjistuje zda za return nejsou dalsi prikazy*/
void checkReturn();
/* ziskani seznamu lokalnich deklaraci, vytvorenych pred pouzitim vyrazu e*/
virtual bool getLocalDeclaration(Expression* e, vector<Declaration*>* ld);
/*obsahuje prikaz dany vyraz pouziva se pro hledani deklaraci ktere se maji vlozit na zasobnik pri volani funkce*/
bool containExpression(Expression* e){ return ex==e; }
~IfCommand(){ if(command!=NULL) delete command; if(ex!=NULL) delete ex; }
};
class WhileCommand: public Command{
Command* command;
Expression* ex;
public:
WhileCommand(Command* c, Expression* e){ ex = e; command = c; }
virtual void validate();
virtual void execute();
/* zjistuje zda za return nejsou dalsi prikazy*/
void checkReturn();
/* ziskani seznamu lokalnich deklaraci, vytvorenych pred pouzitim vyrazu e*/
virtual bool getLocalDeclaration(Expression* e, vector<Declaration*>* ld);
/*obsahuje prikaz dany vyraz pouziva se pro hledani deklaraci ktere se maji vlozit na zasobnik pri volani funkce*/
bool containExpression(Expression* e){ return ex==e; }
~WhileCommand(){ if(command!=NULL) delete command; if(ex!=NULL) delete ex; }
};
class ReturnCommand: public Command{
Expression* ex;
Block* b;
public:
ReturnCommand(Expression* e, Block* bl){ b = bl; ex = e; }
virtual void validate();
virtual void execute();
/*obsahuje prikaz dany vyraz pouziva se pro hledani deklaraci ktere se maji vlozit na zasobnik pri volani funkce*/
bool containExpression(Expression* e){ return ex==e; }
~ReturnCommand(){ if(ex!=NULL) delete ex; }
};
class Function: public Block{
protected:
/*trida kde je fukce deklarovana*/
Class* c;
/* blok nasledujici za deklaraci*/
Block* block;
/*deklarovane parametry*/
vector<Declaration*> params;
/*je static*/
bool stat;
/*jmeno funkce*/
char name[100];
/* druh navratoveho typu*/
TypeValue type;
/* pokud je navratovy typ object tak jaka je to trida*/
char typeName[100];
public:
Function(){ block=NULL; c=NULL; stat = false; }
Function(vector<Declaration*> p, TypeValue tv, char* tn, char* n, bool s, Block* b);
void setClass(Class* cl){ c = cl; }
void setBlock(Block* b){ block=b; block->setParentBlock(this); }
virtual Class* getClass(){ return c; }
virtual char* getName(){ return name; }
virtual TypeValue getType(){ return type; }
char* getTypeName(){ return typeName; }
/* volani zacina na instanci Blok dokud se nedostane az sem*/
virtual Function* getParentFunction(){ return this; }
/* najde promennou, muzeme urcit zda chceme jen lokalni*/
virtual Value* findValue(char* name, bool local);
virtual void validate();
virtual void execute(){ block->execute(); }
bool isStatic(){ return stat; }
/* ziskani seznamu lokalnich deklaraci, vytvorenych pred pouzitim vyrazu e*/
virtual bool getLocalDeclaration(Expression* e, vector<Declaration*>* ld);
/* seznam "viditelnych" parametru bez implicitniho this u instancnich metod, pro validacni cast*/
vector<Value*> getValuesParams();
/* seznam vsech parametru i implicitnich, pro vykonnou cast*/
vector<Value*> getParams();
~Function();
};
class Class{
protected:
/* seznam deklaraci poli*/
vector<Declaration*> fields;
/* pred validaci jsou zde */
vector<Declaration*> preValidateFields;
/* seznam funkci */
vector<Function*> functions;
/* jmeno tridy */
char name[100];
/* program kde je pouzita */
Program* p;
public:
Class(){}
Class(char* name){ strncpy(this->name,name,100); }
void addDeclaration(Declaration* d);
void addFunction(Function* f);
virtual char* getName(){ return name; }
/* seznam deklaraci instacni nebo staticka pole */
vector<Declaration*> getDeclarations(bool stat);
/* hledani hodnot promennych*/
Value* getField(char* name){ return this->getField(name,false); }
Value* getField(char* name, bool stat);
void initStaticField();
/* hledani funkce podle parametru a jmena*/
virtual Function* getFunction(char* name, vector<Value*> values){ return getFunction(name,values,false); }
virtual Function* getFunction(char* name, vector<Value*> values, bool stat);
void setProgram(Program* pr){ p = pr; }
Program* getProgram(){ return p; }
void validateField();
void validateFunction();
virtual ~Class();
};
/* pomocna trida pro nacitani seznamu deklarovanych parametru */
class HelperParamsDeclaration{
vector<Declaration*> params;
public:
void addParam(Declaration* n){ params.push_back(n); }
vector<Declaration*> getParams(){ return params; }
};
/* knihovni funkce a tridy */
class FunctionPrintInt: public Function{
public:
FunctionPrintInt(){
params.push_back(new Declaration(NULL,OBJECT_VALUE,"Stream","this",false));
params.push_back(new Declaration(NULL,INT_VALUE,NULL,"s",false));
}
virtual void execute(){ cout<< *((Integer*)params[1]->getValue()) << endl; }
virtual void validate(){}
virtual char* getName(){ return "println"; }
};
class FunctionPrintDouble: public Function{
public:
FunctionPrintDouble(){
params.push_back(new Declaration(NULL,OBJECT_VALUE,"Stream","this",false));
params.push_back(new Declaration(NULL,DOUBLE_VALUE,NULL,"s",false));
}
virtual void execute(){ cout<< *((Double*)params[1]->getValue()) << endl; }
virtual void validate(){}
virtual char* getName(){ return "println"; }
};
class FunctionPrintBoolean: public Function{
public:
FunctionPrintBoolean(){
params.push_back(new Declaration(NULL,OBJECT_VALUE,"Stream","this",false));
params.push_back(new Declaration(NULL,BOOLEAN_VALUE,NULL,"s",false));
}
virtual void execute(){ cout<< *((Boolean*)params[1]->getValue()) << endl; }
virtual void validate(){}
virtual char* getName(){ return "println"; }
};
class FucntionPrintString: public Function{
public:
FucntionPrintString(){
params.push_back(new Declaration(NULL,OBJECT_VALUE,"Stream","this",false));
params.push_back(new Declaration(NULL,STRING_VALUE,NULL,"s",false));
}
virtual void execute(){ cout<< *((String*)params[1]->getValue()) << endl; }
virtual void validate(){}
virtual char* getName(){ return "println"; }
};
class Stream: public Class{
public:
Stream(Program* pr){
p = pr;
functions.push_back(new FunctionPrintInt());
functions.push_back(new FunctionPrintDouble());
functions.push_back(new FunctionPrintBoolean());
functions.push_back(new FucntionPrintString());
}
virtual char* getName(){ return "Stream"; }
};
class System: public Class{
public:
System(Program* pr);
virtual char* getName(){ return "System"; }
};
class Program{
/* pokud dojde k chybe pri prekladu je ulozena zde*/
ParserException* error;
Lexan* lexan;
LexElement token;
vector<Class*> classes;
void CD();
void FFD(Class*);
void FFDC(Class* c, bool stat, char* name, TypeValue type, char* typeName);
HelperParamsDeclaration* PD(HelperParamsDeclaration*);
HelperParamsDeclaration* PDC(HelperParamsDeclaration*);
Block* BO(Block*);
Command* L(Block*);
Command* D(char* name, TypeValue type, char* typeName, Block* parent);
public:
Program(char* path);
void init();
void runMain(char* className);
/* najde tridu deklarovanou v programu*/
Class* findClass(char* name);
ParserException* getError(){ return error; }
void setError(ParserException* e){ if (error==NULL) error = e; }
void validate();
~Program();
};
#endif