ScummVM API documentation
as_scriptnode.h
1 /*
2  AngelCode Scripting Library
3  Copyright (c) 2003-2018 Andreas Jonsson
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any
7  damages arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any
10  purpose, including commercial applications, and to alter it and
11  redistribute it freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you
14  must not claim that you wrote the original software. If you use
15  this software in a product, an acknowledgment in the product
16  documentation would be appreciated but is not required.
17 
18  2. Altered source versions must be plainly marked as such, and
19  must not be misrepresented as being the original software.
20 
21  3. This notice may not be removed or altered from any source
22  distribution.
23 
24  The original version of this library can be located at:
25  http://www.angelcode.com/angelscript/
26 
27  Andreas Jonsson
28  andreas@angelcode.com
29 */
30 
31 
32 //
33 // as_scriptnode.h
34 //
35 // A node in the script tree built by the parser for compilation
36 //
37 
38 
39 #ifndef AS_SCRIPTNODE_H
40 #define AS_SCRIPTNODE_H
41 
42 #include "as_config.h"
43 #include "as_tokendef.h"
44 
45 BEGIN_AS_NAMESPACE
46 
47 enum eScriptNode {
48  snUndefined,
49  snScript,
50  snFunction,
51  snConstant,
52  snDataType,
53  snIdentifier,
54  snParameterList,
55  snStatementBlock,
56  snDeclaration,
57  snExpressionStatement,
58  snIf,
59  snFor,
60  snWhile,
61  snReturn,
62  snExpression,
63  snExprTerm,
64  snFunctionCall,
65  snConstructCall,
66  snArgList,
67  snExprPreOp,
68  snExprPostOp,
69  snExprOperator,
70  snExprValue,
71  snBreak,
72  snContinue,
73  snDoWhile,
74  snAssignment,
75  snCondition,
76  snSwitch,
77  snCase,
78  snImport,
79  snClass,
80  snInitList,
81  snInterface,
82  snEnum,
83  snTypedef,
84  snCast,
85  snVariableAccess,
86  snFuncDef,
87  snVirtualProperty,
88  snNamespace,
89  snMixin,
90  snListPattern,
91  snNamedArgument,
92  snScope,
93  snTryCatch
94 };
95 
96 struct sToken {
97  eTokenType type;
98  size_t pos;
99  size_t length;
100 };
101 
102 class asCScriptEngine;
103 
105 public:
106  asCScriptNode(eScriptNode nodeType);
107 
108  void Destroy(asCScriptEngine *engine);
109  asCScriptNode *CreateCopy(asCScriptEngine *engine);
110 
111  void SetToken(sToken *token);
112  void AddChildLast(asCScriptNode *node);
113  void DisconnectParent();
114 
115  void UpdateSourcePos(size_t pos, size_t length);
116 
117  eScriptNode nodeType;
118  eTokenType tokenType;
119  size_t tokenPos;
120  size_t tokenLength;
121 
122  asCScriptNode *parent;
123  asCScriptNode *next;
124  asCScriptNode *prev;
125  asCScriptNode *firstChild;
126  asCScriptNode *lastChild;
127 
128 protected:
129  // Must call Destroy instead
130  ~asCScriptNode() {}
131 };
132 
133 END_AS_NAMESPACE
134 
135 #endif
Definition: as_scriptnode.h:96
Definition: as_scriptengine.h:64
Definition: as_scriptnode.h:104