ScummVM API documentation
grammar.h
1
/* ScummVM - Graphic Adventure Engine
2
*
3
* ScummVM is the legal property of its developers, whose names
4
* are too numerous to list here. Please refer to the COPYRIGHT
5
* file distributed with this source distribution.
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*
20
*/
21
22
#ifndef PRIVATE_GRAMMAR_H
23
#define PRIVATE_GRAMMAR_H
24
25
#include "common/str.h"
26
#include "common/hash-str.h"
27
#include "common/hash-ptr.h"
28
#include "common/queue.h"
29
#include "common/list.h"
30
#include "common/array.h"
31
#include "common/rect.h"
32
33
#include "private/symbol.h"
34
35
#define NSTACK 256
36
#define NPROG 10000
37
38
namespace
Private {
39
40
typedef
struct
Datum
{
/* interpreter stack type */
41
short
type;
42
union
{
43
int
val;
44
const
char
*str;
45
Symbol
*sym;
46
Common::Rect
*rect;
47
} u;
48
}
Datum
;
49
50
typedef
struct
Arg
{
51
int
n;
52
int (** inst)();
53
}
Arg
;
54
55
typedef
int (* Inst)();
/* machine instruction */
56
#define STOP (Inst) 0
57
58
typedef
Common::HashMap<void *, Common::String *>
PtrToName
;
59
60
void
initInsts();
61
void
initFuncs();
62
63
namespace
Settings {
64
65
typedef
struct
Setting
{
66
Datum
stack[NSTACK];
/* the stack */
67
Inst prog[NPROG];
/* the machine */
68
}
Setting
;
69
70
typedef
Common::HashMap<Common::String, Setting *>
SettingMap
;
71
72
class
SettingMaps
{
73
public
:
74
SettingMaps
();
75
~SettingMaps
();
76
77
Setting
*_setting;
78
SettingMap
_map;
79
80
void
init();
81
void
save(
const
char
*);
82
void
load(
const
Common::String
&);
83
84
private
:
85
Common::Array<Setting *>
_settings;
86
};
87
88
extern
SettingMaps
*g_setts;
89
90
}
91
92
// Funtions
93
94
typedef
Common::Array<Datum>
ArgArray
;
95
void
call(
const
char
*,
const
ArgArray
&);
96
97
// Code Generation and Execution
98
99
namespace
Gen {
100
101
class
VM
{
102
public
:
103
Datum
*_stack;
/* the stack */
104
Datum
*_stackp;
/* next free spot on stack */
105
106
Inst *_progp;
/* next free spot for code generation */
107
Inst *_prog;
/* the machine */
108
Inst *_pc;
/* program counter during execution */
109
void
run();
/* run the virtual machine */
110
};
111
112
extern
VM
*g_vm;
113
114
Datum
pop();
115
int
push(
const
Datum
&);
116
117
Inst *code(
const
Inst &);
118
int
eval();
119
int
add();
120
int
negate();
121
int
power();
122
int
assign();
123
int
bltin();
124
int
varpush();
125
int
constpush();
126
int
strpush();
127
int
funcpush();
128
int
print();
129
int
ifcode();
130
int
fail();
131
int
lt();
132
int
gt();
133
int
le();
134
int
ge();
135
int
eq();
136
int
ne();
137
int
randbool();
138
139
// Code Execution
140
141
void
execute(Inst *);
142
143
}
144
145
}
// End of namespace Private
146
147
#endif
Common::Array
Definition:
array.h:52
Common::HashMap
Definition:
hashmap.h:85
Common::String
Definition:
str.h:59
Private::Gen::VM
Definition:
grammar.h:101
Private::Settings::SettingMaps
Definition:
grammar.h:72
Common::Rect
Definition:
rect.h:536
Private::Arg
Definition:
grammar.h:50
Private::Datum
Definition:
grammar.h:40
Private::Settings::Setting
Definition:
grammar.h:65
Private::Symbol
Definition:
symbol.h:35
engines
private
grammar.h
Generated on Sat Oct 24 2026 09:22:48 for ScummVM API documentation by
1.9.4