as_scriptnode.h 2.6 KB

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