@woosh/meep-engine 2.48.22 → 2.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/editor/ecs/component/editors/three/BufferGeometryEditor.js +1 -1
  2. package/editor/ecs/component/editors/three/MeshEditor.js +1 -1
  3. package/editor/tools/GridPaintTool.js +1 -1
  4. package/editor/tools/SelectionTool.js +1 -1
  5. package/editor/tools/paint/TerrainPaintTool.js +1 -1
  6. package/editor/view/GridPickCoordinateView.js +1 -1
  7. package/editor/view/library/MeshLibraryView.js +1 -1
  8. package/package.json +1 -1
  9. package/src/core/UUID.js +2 -0
  10. package/src/core/assert.js +4 -1
  11. package/src/core/binary/32BitEncoder.js +1 -1
  12. package/src/core/binary/ctz32.js +1 -1
  13. package/src/core/binary/operations/bitCount.spec.js +19 -0
  14. package/src/core/binary/uint82float.spec.js +7 -0
  15. package/src/core/bvh2/LeafNode.js +2 -2
  16. package/src/core/bvh2/Node.d.ts +1 -1
  17. package/src/core/bvh2/Node.js +1 -1
  18. package/src/core/bvh2/NodeValidator.js +1 -1
  19. package/src/core/bvh2/bvh3/EBBVHLeafProxy.js +3 -0
  20. package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +5 -4
  21. package/src/core/bvh2/serialization/deserializeBinaryNode.js +1 -1
  22. package/src/core/bvh2/serialization/deserializeBinaryNodeFromBinaryBuffer.js +2 -2
  23. package/src/core/bvh2/serialization/serializeBinaryNode.js +1 -1
  24. package/src/core/bvh2/serialization/serializeBinaryNodeToBinaryBuffer.js +2 -2
  25. package/src/core/bvh2/transform/RotationOptimizer.spec.js +161 -155
  26. package/src/core/cache/Cache.js +4 -2
  27. package/src/core/codegen/LineBuilder.js +15 -3
  28. package/src/core/codegen/LineBuilder.spec.js +7 -0
  29. package/src/core/collection/HashMap.js +491 -236
  30. package/src/core/collection/HashMap.spec.js +110 -1
  31. package/src/core/collection/array/{typedArrayToDataType.js → typed/typedArrayToDataType.js} +1 -1
  32. package/src/core/collection/array/weightedRandomFromArray.spec.js +20 -0
  33. package/src/core/collection/heap/Uint32Heap.js +1 -0
  34. package/src/core/debug/matchers/AnyOf.js +1 -2
  35. package/src/core/events/signal/Signal.js +7 -5
  36. package/src/core/events/signal/SignalBinding.js +56 -54
  37. package/src/core/events/signal/SignalFlags.js +7 -0
  38. package/src/core/function/Functions.js +1 -1
  39. package/src/core/geom/{Rectangle.js → 2d/Rectangle.js} +5 -5
  40. package/src/core/geom/{AABB2.js → 2d/aabb/AABB2.js} +10 -78
  41. package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.js +19 -0
  42. package/src/core/geom/2d/aabb/aabb2_compute_overlap.js +42 -0
  43. package/src/core/geom/2d/aabb/aabb2_contains.js +23 -0
  44. package/src/core/geom/2d/aabb/aabb2_distance_sqr_to_point.js +25 -0
  45. package/src/core/geom/2d/aabb/aabb2_distance_to_point.js +17 -0
  46. package/src/core/geom/2d/aabb/aabb2_distance_to_point.spec.js +17 -0
  47. package/src/core/geom/2d/aabb/aabb2_overlap_exists.js +18 -0
  48. package/src/core/geom/2d/aabb/aabb2_signed_distance_sqr_to_point.js +45 -0
  49. package/src/core/geom/2d/aabb/aabb2_signed_distance_sqr_to_point.spec.js +40 -0
  50. package/src/core/geom/2d/aabb/aabb2_signed_distance_to_point.js +27 -0
  51. package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +4 -0
  52. package/src/core/geom/2d/quad-tree/PointQuadTree.js +3 -0
  53. package/src/core/geom/2d/quad-tree/QuadTreeDatum.js +1 -1
  54. package/src/core/geom/2d/quad-tree/QuadTreeNode.js +3 -3
  55. package/src/core/geom/2d/quad-tree/qt_collect_by_circle.js +6 -8
  56. package/src/core/geom/2d/quad-tree/qt_match_data_by_circle.js +3 -3
  57. package/src/core/geom/2d/quad-tree/qt_query_data_nearest_to_point.js +8 -10
  58. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/AABB3.d.ts +1 -1
  59. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/AABB3.js +13 -13
  60. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/AABB3.spec.js +1 -1
  61. package/src/core/geom/3d/aabb/aabb3_compute_plane_side.js +17 -15
  62. package/src/core/geom/3d/aabb/aabb3_compute_plane_side.spec.js +25 -0
  63. package/src/core/geom/3d/aabb/aabb3_detailed_volume_intersection.js +1 -1
  64. package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +3 -0
  65. package/src/core/geom/3d/aabb/aabb3_from_v3_array.spec.js +32 -0
  66. package/src/core/geom/3d/aabb/aabb3_intersects_aabb3.spec.js +115 -0
  67. package/src/core/geom/3d/aabb/aabb3_raycast.js +6 -1
  68. package/src/core/geom/3d/aabb/aabb3_signed_distance_sqr_to_point.js +13 -9
  69. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/serializeAABB3Encoded_v0.js +6 -6
  70. package/src/core/geom/3d/{CircleMath.js → compute_circle_bounding_box.js} +1 -1
  71. package/src/core/geom/3d/decompose_matrix_4_array.js +18 -19
  72. package/src/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
  73. package/src/{engine/graphics/ecs/mesh-v2 → core/geom/3d/matrix}/allocate_transform_m4.js +1 -1
  74. package/src/core/geom/3d/normal/hemioct/decode_hemioct_to_unit.js +26 -0
  75. package/src/core/geom/3d/normal/hemioct/encode_unit3_hemioct.js +0 -26
  76. package/src/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +2 -1
  77. package/src/core/geom/3d/plane/computePlaneLineIntersection.js +51 -0
  78. package/src/core/geom/3d/plane/computePlanePlaneIntersection.js +77 -0
  79. package/src/core/geom/3d/plane/computePlaneRayIntersection.js +55 -0
  80. package/src/core/geom/3d/plane/plane3_computeLineSegmentIntersection.js +50 -0
  81. package/src/core/geom/3d/plane/planeRayIntersection.js +14 -0
  82. package/src/core/geom/3d/{tetrahedra/in_sphere_fast.js → sphere/in_sphere3d_fast.js} +1 -1
  83. package/src/core/geom/3d/{tetrahedra/in_sphere_robust.js → sphere/in_sphere3d_robust.js} +1 -1
  84. package/src/core/geom/3d/sphere/sphere_array_intersects_point.js +2 -2
  85. package/src/core/geom/3d/sphere/{sphereIntersectsPoint.js → sphere_intersects_point.js} +7 -4
  86. package/src/core/geom/3d/sphere/sphere_intersects_point.spec.js +134 -0
  87. package/src/core/geom/3d/sphere/sphere_intersects_ray.spec.js +49 -0
  88. package/src/core/geom/3d/sphere/sphere_radius_sqr_from_v3_array_transformed.js +11 -7
  89. package/src/core/geom/3d/tetrahedra/delaunay/{debug_validate_mesh.js → debug/debug_validate_mesh.js} +1 -1
  90. package/src/core/geom/3d/tetrahedra/delaunay/{push_boundary_with_validation.js → debug/push_boundary_with_validation.js} +1 -1
  91. package/src/core/geom/3d/tetrahedra/delaunay/{validate_cavity_boundary.js → debug/validate_cavity_boundary.js} +2 -2
  92. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_cavity.js +2 -2
  93. package/src/core/geom/3d/triangle/computeTriangleRayIntersection.js +0 -164
  94. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +87 -0
  95. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +81 -0
  96. package/src/core/geom/{GeometryMath.js → 3d/triangle/rayTriangleIntersection.js} +7 -3
  97. package/src/core/geom/ConicRay.js +160 -152
  98. package/src/core/geom/Matrix4.js +2 -0
  99. package/src/core/geom/Quaternion.js +19 -1
  100. package/src/core/geom/packing/max-rect/MaxRectangles.js +5 -215
  101. package/src/core/geom/packing/max-rect/cost/costByBestShortSide.js +11 -0
  102. package/src/core/geom/packing/max-rect/cost/costByRemainingArea.js +14 -0
  103. package/src/core/geom/packing/max-rect/cutArea.js +79 -0
  104. package/src/core/geom/packing/max-rect/findBestContainer.js +58 -0
  105. package/src/core/geom/packing/max-rect/packOneBox.js +49 -0
  106. package/src/core/geom/v3_dot.js +1 -1
  107. package/src/core/graph/GraphUtils.js +1 -1
  108. package/src/core/graph/build_face_graph_from_mesh.js +1 -3
  109. package/src/core/graph/layout/CircleLayout.js +3 -3
  110. package/src/core/graph/layout/{BoxLayouter.js → box/BoxLayouter.js} +6 -50
  111. package/src/core/graph/layout/box/applyCentralGravityAABB2.js +29 -0
  112. package/src/core/json/resolvePath.spec.js +14 -0
  113. package/src/core/land/reactive/{compiler/ReactiveCompiler.spec.js → compileReactiveExpression.spec.js} +17 -17
  114. package/src/core/math/random/MersenneTwister.spec.js +19 -0
  115. package/src/core/math/random/randomGaussian.spec.js +9 -0
  116. package/src/core/math/statistics/computeStatisticalMean.js +2 -2
  117. package/src/core/model/node-graph/visual/NodeVisualData.js +1 -1
  118. package/src/core/model/reactive/model/arithmetic/ReactiveAdd.js +1 -1
  119. package/src/core/model/reactive/model/arithmetic/ReactiveDivide.js +3 -1
  120. package/src/core/model/reactive/model/arithmetic/ReactiveMultiply.js +1 -1
  121. package/src/core/model/reactive/model/arithmetic/ReactiveNegate.js +3 -1
  122. package/src/core/model/reactive/model/arithmetic/ReactiveSubtract.js +1 -1
  123. package/src/core/model/reactive/model/comparative/ReactiveEquals.js +1 -1
  124. package/src/core/model/reactive/model/comparative/ReactiveGreaterThan.js +3 -1
  125. package/src/core/model/reactive/model/comparative/ReactiveGreaterThanOrEqual.js +3 -1
  126. package/src/core/model/reactive/model/comparative/ReactiveLessThan.js +3 -1
  127. package/src/core/model/reactive/model/comparative/ReactiveLessThanOrEqual.js +3 -1
  128. package/src/core/model/reactive/model/comparative/ReactiveNotEquals.js +1 -1
  129. package/src/core/model/reactive/model/logic/ReactiveAnd.js +1 -1
  130. package/src/core/model/reactive/model/logic/ReactiveNot.js +3 -1
  131. package/src/core/model/reactive/model/logic/ReactiveOr.js +1 -1
  132. package/src/core/primitives/numbers/computeHashFloat.spec.js +7 -0
  133. package/src/core/process/task/util/iteratorTask.js +3 -1
  134. package/src/engine/animation/curve/AnimationCurve.js +34 -5
  135. package/src/engine/animation/curve/AnimationCurve.spec.js +100 -0
  136. package/src/engine/asset/AssetTransformer.js +1 -0
  137. package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
  138. package/src/engine/asset/loaders/image/ImageRGBADataLoader.js +2 -2
  139. package/src/engine/asset/preloader/Preloader.js +3 -3
  140. package/src/engine/computeStridedIntegerArrayHash.js +4 -2
  141. package/src/engine/ecs/components/Renderable.d.ts +2 -2
  142. package/src/engine/ecs/components/Renderable.js +1 -1
  143. package/src/{ecs → engine/ecs}/grid/pick.js +4 -4
  144. package/src/engine/ecs/gui/position/ViewportPositionSystem.js +1 -1
  145. package/src/engine/ecs/parent/entity_node_compute_bounding_box.js +1 -1
  146. package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +1 -18
  147. package/src/engine/ecs/systems/MotionSystem.js +7 -1
  148. package/src/engine/ecs/systems/SynchronizePositionSystem.js +8 -2
  149. package/src/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
  150. package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +2 -2
  151. package/src/engine/ecs/tooltip/TooltipComponentSystem.js +1 -1
  152. package/src/engine/ecs/transform/Transform.js +1 -1
  153. package/src/engine/graphics/camera/makeScreenScissorFrustum.d.ts +1 -1
  154. package/src/engine/graphics/camera/makeScreenScissorFrustum.js +3 -3
  155. package/src/engine/graphics/camera/testClippingPlaneComputation.js +13 -13
  156. package/src/engine/graphics/ecs/camera/Camera.js +1 -1
  157. package/src/engine/graphics/ecs/light/LightSystem.js +1 -1
  158. package/src/engine/graphics/ecs/mesh/Mesh.d.ts +1 -1
  159. package/src/engine/graphics/ecs/mesh/Mesh.js +1 -1
  160. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +1 -1
  161. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +1 -1
  162. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.d.ts +1 -1
  163. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.js +1 -1
  164. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +9 -0
  165. package/src/engine/graphics/ecs/mesh-v2/sg_hierarchy_compute_bounding_box_via_parent_entity.d.ts +1 -1
  166. package/src/engine/graphics/geometry/MikkT/MikkTSpace.js +1 -1
  167. package/src/engine/graphics/geometry/MikkT/STSpace.js +1 -1
  168. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
  169. package/src/engine/graphics/geometry/skining/computeSkinnedMeshBoundingVolumes.js +1 -1
  170. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +1 -1
  171. package/src/engine/graphics/particles/particular/engine/MovingBoundingBox.js +1 -1
  172. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +1 -1
  173. package/src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +1 -1
  174. package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +1 -0
  175. package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
  176. package/src/engine/graphics/postprocess/threejs/postprocessing/TexturePass.js +2 -2
  177. package/src/engine/graphics/render/forward_plus/debug/createScreenGrid.js +1 -1
  178. package/src/engine/graphics/render/view/CameraView.js +1 -1
  179. package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +2 -2
  180. package/src/engine/graphics/texture/atlas/AtlasPatch.js +2 -2
  181. package/src/engine/graphics/texture/atlas/TextureAtlas.spec.js +2 -2
  182. package/src/engine/graphics/texture/sampler/Sampler2D.js +1 -1
  183. package/src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.js +1 -1
  184. package/src/engine/graphics/util/makeMeshPreviewScene.js +1 -1
  185. package/src/engine/graphics/util/renderObjectToSampler2D.js +1 -1
  186. package/src/engine/intelligence/behavior/Behavior.spec.js +15 -0
  187. package/src/engine/intelligence/mcts/MoveEdge.js +1 -1
  188. package/src/engine/reference/v1/ReferenceManager.js +3 -0
  189. package/src/engine/reference/v2/Reference.js +33 -37
  190. package/src/engine/sound/sopra/README.md +6 -0
  191. package/src/engine/ui/tiles2d/computeTileGridMove.js +3 -2
  192. package/src/engine/ui/tiles2d/computeTileGridMove.spec.js +1 -1
  193. package/src/generation/automata/CaveGeneratorCellularAutomata.js +10 -7
  194. package/src/generation/automata/CaveGeneratorCellularAutomata.spec.js +12 -0
  195. package/src/generation/automata/CellularAutomata.js +5 -4
  196. package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +25 -9
  197. package/src/generation/theme/AreaMask.js +1 -1
  198. package/src/view/View.js +1 -1
  199. package/src/view/elements/progress/RectangularPieProgressView.js +1 -1
  200. package/src/view/minimap/Minimap.js +1 -1
  201. package/src/view/minimap/dom/MinimapCameraView.js +1 -1
  202. package/src/view/minimap/gl/MinimapFogOfWar.js +1 -1
  203. package/src/view/tooltip/DomTooltipObserver.js +1 -1
  204. package/src/view/tooltip/TooltipManager.js +1 -1
  205. package/src/view/tooltip/TooltipView.js +1 -1
  206. package/src/view/util/DomSizeObserver.js +2 -2
  207. package/src/core/geom/2d/AABB2Math.js +0 -40
  208. package/src/core/geom/2d/AABB2Math.spec.js +0 -17
  209. package/src/core/geom/Plane.js +0 -250
  210. package/src/core/land/reactive/ReactiveLexer.js +0 -158
  211. package/src/core/land/reactive/ReactiveLexer.ts +0 -181
  212. package/src/core/land/reactive/ReactiveListener.ts +0 -323
  213. package/src/core/land/reactive/ReactiveParser.js +0 -1573
  214. package/src/core/land/reactive/ReactiveParser.ts +0 -1776
  215. package/src/core/land/reactive/ReactiveVisitor.js +0 -1
  216. package/src/core/land/reactive/ReactiveVisitor.ts +0 -218
  217. package/src/core/land/reactive/compiler/ReactiveCompiler.js +0 -350
  218. package/src/core/land/reactive/compiler/ReactiveNearlyCompiler.js +0 -166
  219. package/src/core/land/reactive/compiler/ReactiveParser.js +0 -34
  220. package/src/core/land/reactive/nearley/ReactiveNearley.js +0 -187
  221. /package/src/core/geom/{LineSegment2.js → 2d/LineSegment2.js} +0 -0
  222. /package/src/core/geom/{Rectangle.spec.js → 2d/Rectangle.spec.js} +0 -0
  223. /package/src/core/geom/{AABB2.d.ts → 2d/aabb/AABB2.d.ts} +0 -0
  224. /package/src/core/geom/{AABB2.spec.js → 2d/aabb/AABB2.spec.js} +0 -0
  225. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/deserializeAABB3.js +0 -0
  226. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/deserializeAABB3Encoded_v0.js +0 -0
  227. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/deserializeAABB3Quantized16Uint.js +0 -0
  228. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/serializeAABB3.js +0 -0
  229. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/serializeAABB3Quantized16Uint.js +0 -0
  230. /package/src/{engine/graphics/ecs/mesh-v2 → core/geom/3d/vector}/allocate_v3.js +0 -0
@@ -1 +0,0 @@
1
- // Generated from app/src/lang/Reactive.g4 by ANTLR 4.6-SNAPSHOT
@@ -1,218 +0,0 @@
1
- // Generated from app/src/lang/Reactive.g4 by ANTLR 4.6-SNAPSHOT
2
-
3
-
4
- import {ParseTreeVisitor} from "antlr4ts/tree/ParseTreeVisitor";
5
-
6
- import {
7
- AtomicContext,
8
- AtomicExpressionContext,
9
- BinaryExpressionAddContext,
10
- BinaryExpressionAndContext,
11
- BinaryExpressionDivideContext,
12
- BinaryExpressionEqualContext,
13
- BinaryExpressionGreaterThanContext,
14
- BinaryExpressionGreaterThanOrEqualContext,
15
- BinaryExpressionLessThanContext,
16
- BinaryExpressionLessThanOrEqualContext,
17
- BinaryExpressionMultiplyContext,
18
- BinaryExpressionNotEqualContext,
19
- BinaryExpressionOrContext,
20
- BinaryExpressionSubtractContext,
21
- BooleanLiteralContext,
22
- ExpressionContext,
23
- FloatingLiteralContext,
24
- GroupExpressionContext,
25
- IntegerLiteralContext,
26
- LiteralContext,
27
- ReferenceContext,
28
- UnaryExpressionNegateContext,
29
- UnaryExpressionNotContext
30
- } from "./ReactiveParser";
31
-
32
-
33
- /**
34
- * This interface defines a complete generic visitor for a parse tree produced
35
- * by `ReactiveParser`.
36
- *
37
- * @param <Result> The return type of the visit operation. Use `void` for
38
- * operations with no return type.
39
- */
40
- export interface ReactiveVisitor<Result> extends ParseTreeVisitor<Result> {
41
- /**
42
- * Visit a parse tree produced by the `BinaryExpressionDivide`
43
- * labeled alternative in `ReactiveParser.expression`.
44
- * @param ctx the parse tree
45
- * @return the visitor result
46
- */
47
- visitBinaryExpressionDivide?: (ctx: BinaryExpressionDivideContext) => Result;
48
-
49
- /**
50
- * Visit a parse tree produced by the `UnaryExpressionNot`
51
- * labeled alternative in `ReactiveParser.expression`.
52
- * @param ctx the parse tree
53
- * @return the visitor result
54
- */
55
- visitUnaryExpressionNot?: (ctx: UnaryExpressionNotContext) => Result;
56
-
57
- /**
58
- * Visit a parse tree produced by the `BinaryExpressionLessThan`
59
- * labeled alternative in `ReactiveParser.expression`.
60
- * @param ctx the parse tree
61
- * @return the visitor result
62
- */
63
- visitBinaryExpressionLessThan?: (ctx: BinaryExpressionLessThanContext) => Result;
64
-
65
- /**
66
- * Visit a parse tree produced by the `BinaryExpressionAnd`
67
- * labeled alternative in `ReactiveParser.expression`.
68
- * @param ctx the parse tree
69
- * @return the visitor result
70
- */
71
- visitBinaryExpressionAnd?: (ctx: BinaryExpressionAndContext) => Result;
72
-
73
- /**
74
- * Visit a parse tree produced by the `Atomic`
75
- * labeled alternative in `ReactiveParser.expression`.
76
- * @param ctx the parse tree
77
- * @return the visitor result
78
- */
79
- visitAtomic?: (ctx: AtomicContext) => Result;
80
-
81
- /**
82
- * Visit a parse tree produced by the `BinaryExpressionGreaterThanOrEqual`
83
- * labeled alternative in `ReactiveParser.expression`.
84
- * @param ctx the parse tree
85
- * @return the visitor result
86
- */
87
- visitBinaryExpressionGreaterThanOrEqual?: (ctx: BinaryExpressionGreaterThanOrEqualContext) => Result;
88
-
89
- /**
90
- * Visit a parse tree produced by the `BinaryExpressionOr`
91
- * labeled alternative in `ReactiveParser.expression`.
92
- * @param ctx the parse tree
93
- * @return the visitor result
94
- */
95
- visitBinaryExpressionOr?: (ctx: BinaryExpressionOrContext) => Result;
96
-
97
- /**
98
- * Visit a parse tree produced by the `GroupExpression`
99
- * labeled alternative in `ReactiveParser.expression`.
100
- * @param ctx the parse tree
101
- * @return the visitor result
102
- */
103
- visitGroupExpression?: (ctx: GroupExpressionContext) => Result;
104
-
105
- /**
106
- * Visit a parse tree produced by the `BinaryExpressionSubtract`
107
- * labeled alternative in `ReactiveParser.expression`.
108
- * @param ctx the parse tree
109
- * @return the visitor result
110
- */
111
- visitBinaryExpressionSubtract?: (ctx: BinaryExpressionSubtractContext) => Result;
112
-
113
- /**
114
- * Visit a parse tree produced by the `BinaryExpressionGreaterThan`
115
- * labeled alternative in `ReactiveParser.expression`.
116
- * @param ctx the parse tree
117
- * @return the visitor result
118
- */
119
- visitBinaryExpressionGreaterThan?: (ctx: BinaryExpressionGreaterThanContext) => Result;
120
-
121
- /**
122
- * Visit a parse tree produced by the `BinaryExpressionNotEqual`
123
- * labeled alternative in `ReactiveParser.expression`.
124
- * @param ctx the parse tree
125
- * @return the visitor result
126
- */
127
- visitBinaryExpressionNotEqual?: (ctx: BinaryExpressionNotEqualContext) => Result;
128
-
129
- /**
130
- * Visit a parse tree produced by the `UnaryExpressionNegate`
131
- * labeled alternative in `ReactiveParser.expression`.
132
- * @param ctx the parse tree
133
- * @return the visitor result
134
- */
135
- visitUnaryExpressionNegate?: (ctx: UnaryExpressionNegateContext) => Result;
136
-
137
- /**
138
- * Visit a parse tree produced by the `BinaryExpressionEqual`
139
- * labeled alternative in `ReactiveParser.expression`.
140
- * @param ctx the parse tree
141
- * @return the visitor result
142
- */
143
- visitBinaryExpressionEqual?: (ctx: BinaryExpressionEqualContext) => Result;
144
-
145
- /**
146
- * Visit a parse tree produced by the `BinaryExpressionMultiply`
147
- * labeled alternative in `ReactiveParser.expression`.
148
- * @param ctx the parse tree
149
- * @return the visitor result
150
- */
151
- visitBinaryExpressionMultiply?: (ctx: BinaryExpressionMultiplyContext) => Result;
152
-
153
- /**
154
- * Visit a parse tree produced by the `BinaryExpressionLessThanOrEqual`
155
- * labeled alternative in `ReactiveParser.expression`.
156
- * @param ctx the parse tree
157
- * @return the visitor result
158
- */
159
- visitBinaryExpressionLessThanOrEqual?: (ctx: BinaryExpressionLessThanOrEqualContext) => Result;
160
-
161
- /**
162
- * Visit a parse tree produced by the `BinaryExpressionAdd`
163
- * labeled alternative in `ReactiveParser.expression`.
164
- * @param ctx the parse tree
165
- * @return the visitor result
166
- */
167
- visitBinaryExpressionAdd?: (ctx: BinaryExpressionAddContext) => Result;
168
-
169
- /**
170
- * Visit a parse tree produced by `ReactiveParser.expression`.
171
- * @param ctx the parse tree
172
- * @return the visitor result
173
- */
174
- visitExpression?: (ctx: ExpressionContext) => Result;
175
-
176
- /**
177
- * Visit a parse tree produced by `ReactiveParser.reference`.
178
- * @param ctx the parse tree
179
- * @return the visitor result
180
- */
181
- visitReference?: (ctx: ReferenceContext) => Result;
182
-
183
- /**
184
- * Visit a parse tree produced by `ReactiveParser.atomicExpression`.
185
- * @param ctx the parse tree
186
- * @return the visitor result
187
- */
188
- visitAtomicExpression?: (ctx: AtomicExpressionContext) => Result;
189
-
190
- /**
191
- * Visit a parse tree produced by `ReactiveParser.literal`.
192
- * @param ctx the parse tree
193
- * @return the visitor result
194
- */
195
- visitLiteral?: (ctx: LiteralContext) => Result;
196
-
197
- /**
198
- * Visit a parse tree produced by `ReactiveParser.integerLiteral`.
199
- * @param ctx the parse tree
200
- * @return the visitor result
201
- */
202
- visitIntegerLiteral?: (ctx: IntegerLiteralContext) => Result;
203
-
204
- /**
205
- * Visit a parse tree produced by `ReactiveParser.floatingLiteral`.
206
- * @param ctx the parse tree
207
- * @return the visitor result
208
- */
209
- visitFloatingLiteral?: (ctx: FloatingLiteralContext) => Result;
210
-
211
- /**
212
- * Visit a parse tree produced by `ReactiveParser.booleanLiteral`.
213
- * @param ctx the parse tree
214
- * @return the visitor result
215
- */
216
- visitBooleanLiteral?: (ctx: BooleanLiteralContext) => Result;
217
- }
218
-
@@ -1,350 +0,0 @@
1
- import { ANTLRInputStream } from "antlr4ts/ANTLRInputStream";
2
- import { CommonTokenStream } from "antlr4ts/CommonTokenStream";
3
- import { AbstractParseTreeVisitor } from "antlr4ts/tree/AbstractParseTreeVisitor.js";
4
- import { assert } from "../../../assert.js";
5
- import { ReactiveAdd } from "../../../model/reactive/model/arithmetic/ReactiveAdd.js";
6
- import { ReactiveDivide } from "../../../model/reactive/model/arithmetic/ReactiveDivide.js";
7
- import { ReactiveMultiply } from "../../../model/reactive/model/arithmetic/ReactiveMultiply.js";
8
- import { ReactiveNegate } from "../../../model/reactive/model/arithmetic/ReactiveNegate.js";
9
- import { ReactiveSubtract } from "../../../model/reactive/model/arithmetic/ReactiveSubtract.js";
10
- import { ReactiveEquals } from "../../../model/reactive/model/comparative/ReactiveEquals.js";
11
- import { ReactiveGreaterThan } from "../../../model/reactive/model/comparative/ReactiveGreaterThan.js";
12
- import { ReactiveGreaterThanOrEqual } from "../../../model/reactive/model/comparative/ReactiveGreaterThanOrEqual.js";
13
- import { ReactiveLessThan } from "../../../model/reactive/model/comparative/ReactiveLessThan.js";
14
- import { ReactiveLessThanOrEqual } from "../../../model/reactive/model/comparative/ReactiveLessThanOrEqual.js";
15
- import { ReactiveNotEquals } from "../../../model/reactive/model/comparative/ReactiveNotEquals.js";
16
- import { ReactiveAnd } from "../../../model/reactive/model/logic/ReactiveAnd.js";
17
- import { ReactiveNot } from "../../../model/reactive/model/logic/ReactiveNot.js";
18
- import { ReactiveOr } from "../../../model/reactive/model/logic/ReactiveOr.js";
19
- import { ReactiveLiteralBoolean } from "../../../model/reactive/model/terminal/ReactiveLiteralBoolean.js";
20
- import { ReactiveLiteralNumber } from "../../../model/reactive/model/terminal/ReactiveLiteralNumber.js";
21
- import { ReactiveReference } from "../../../model/reactive/model/terminal/ReactiveReference.js";
22
- import { ReactiveLexer } from "../ReactiveLexer.ts";
23
- import { ReactiveParser } from "../ReactiveParser.ts";
24
-
25
-
26
- class CompilingVisitor extends AbstractParseTreeVisitor {
27
- constructor() {
28
- super();
29
- }
30
-
31
- visit(ctx) {
32
- return super.visit(ctx);
33
- }
34
-
35
- visitFirstChild(ctx) {
36
- return this.visit(ctx.children[0]);
37
- }
38
-
39
- // Visit a parse tree produced by ReactiveParser#groupExpression.
40
- visitGroupExpression(ctx) {
41
- return this.visit(ctx._exp);
42
- };
43
-
44
- /**
45
- *
46
- * @param {ParserRuleContext} ctx
47
- * @returns {ReactiveExpression}
48
- */
49
- visitAtomic(ctx) {
50
- const children = ctx.children;
51
- const child = children[0];
52
- return this.visitAtomicExpression(child);
53
- };
54
-
55
- /**
56
- *
57
- * @param ctx
58
- * @returns {ReactiveNot}
59
- */
60
- visitUnaryExpressionNot(ctx) {
61
- const result = new ReactiveNot();
62
-
63
- this._buildUnaryExpression(ctx, result);
64
-
65
- return result;
66
- }
67
-
68
- /**
69
- *
70
- * @param ctx
71
- * @returns {ReactiveNegate}
72
- */
73
- visitUnaryExpressionNegate(ctx) {
74
- const result = new ReactiveNegate();
75
-
76
- this._buildUnaryExpression(ctx, result);
77
-
78
- return result;
79
- }
80
-
81
- /**
82
- *
83
- * @param {RuleContext} ctx
84
- * @param {ReactiveUnaryExpression} node
85
- * @private
86
- */
87
- _buildUnaryExpression(ctx, node) {
88
- const exp = ctx._exp;
89
-
90
- const source = this.visit(exp);
91
-
92
-
93
- node.connect(source);
94
-
95
- }
96
-
97
- /**
98
- *
99
- * @param {RuleContext} ctx
100
- * @param {ReactiveBinaryExpression} node
101
- * @private
102
- */
103
- _buildBinaryExpression(ctx, node) {
104
- const left = this.visit(ctx._left);
105
- const right = this.visit(ctx._right);
106
-
107
-
108
- node.connect(left, right);
109
- }
110
-
111
- /**
112
- *
113
- * @param ctx
114
- * @returns {ReactiveMultiply}
115
- */
116
- visitBinaryExpressionMultiply(ctx) {
117
- const result = new ReactiveMultiply();
118
-
119
- this._buildBinaryExpression(ctx, result);
120
-
121
- return result;
122
- }
123
-
124
- /**
125
- *
126
- * @param ctx
127
- * @returns {ReactiveDivide}
128
- */
129
- visitBinaryExpressionDivide(ctx) {
130
- const result = new ReactiveDivide();
131
-
132
- this._buildBinaryExpression(ctx, result);
133
-
134
- return result;
135
- }
136
-
137
- /**
138
- *
139
- * @param ctx
140
- * @returns {ReactiveAdd}
141
- */
142
- visitBinaryExpressionAdd(ctx) {
143
- const result = new ReactiveAdd();
144
-
145
- this._buildBinaryExpression(ctx, result);
146
-
147
- return result;
148
- }
149
-
150
- /**
151
- *
152
- * @param ctx
153
- * @returns {ReactiveSubtract}
154
- */
155
- visitBinaryExpressionSubtract(ctx) {
156
- const result = new ReactiveSubtract();
157
-
158
- this._buildBinaryExpression(ctx, result);
159
-
160
- return result;
161
- }
162
-
163
- /**
164
- *
165
- * @param ctx
166
- * @returns {ReactiveGreaterThan}
167
- */
168
- visitBinaryExpressionGreaterThan(ctx) {
169
- const result = new ReactiveGreaterThan();
170
-
171
- this._buildBinaryExpression(ctx, result);
172
-
173
- return result;
174
- }
175
-
176
- /**
177
- *
178
- * @param ctx
179
- * @returns {ReactiveLessThan}
180
- */
181
- visitBinaryExpressionLessThan(ctx) {
182
- const result = new ReactiveLessThan();
183
-
184
- this._buildBinaryExpression(ctx, result);
185
-
186
- return result;
187
- }
188
-
189
- /**
190
- *
191
- * @param ctx
192
- * @returns {ReactiveGreaterThanOrEqual}
193
- */
194
- visitBinaryExpressionGreaterThanOrEqual(ctx) {
195
- const result = new ReactiveGreaterThanOrEqual();
196
-
197
- this._buildBinaryExpression(ctx, result);
198
-
199
- return result;
200
- }
201
-
202
- /**
203
- *
204
- * @param ctx
205
- * @returns {ReactiveLessThanOrEqual}
206
- */
207
- visitBinaryExpressionLessThanOrEqual(ctx) {
208
- const result = new ReactiveLessThanOrEqual();
209
-
210
- this._buildBinaryExpression(ctx, result);
211
-
212
- return result;
213
- }
214
-
215
- /**
216
- *
217
- * @param ctx
218
- * @returns {ReactiveEquals}
219
- */
220
- visitBinaryExpressionEqual(ctx) {
221
- const result = new ReactiveEquals();
222
-
223
- this._buildBinaryExpression(ctx, result);
224
-
225
- return result;
226
- }
227
-
228
- /**
229
- *
230
- * @param ctx
231
- * @returns {ReactiveNotEquals}
232
- */
233
- visitBinaryExpressionNotEqual(ctx) {
234
- const result = new ReactiveNotEquals();
235
-
236
- this._buildBinaryExpression(ctx, result);
237
-
238
- return result;
239
- }
240
-
241
- /**
242
- *
243
- * @param ctx
244
- * @returns {ReactiveAnd}
245
- */
246
- visitBinaryExpressionAnd(ctx) {
247
- const result = new ReactiveAnd();
248
-
249
- this._buildBinaryExpression(ctx, result);
250
-
251
- return result;
252
- }
253
-
254
- /**
255
- *
256
- * @param ctx
257
- * @returns {ReactiveOr}
258
- */
259
- visitBinaryExpressionOr(ctx) {
260
- const result = new ReactiveOr();
261
-
262
- this._buildBinaryExpression(ctx, result);
263
-
264
- return result;
265
- }
266
-
267
-
268
- // Visit a parse tree produced by ReactiveParser#reference.
269
- visitReference(ctx) {
270
- const text = ctx.text;
271
- return new ReactiveReference(text);
272
- }
273
-
274
-
275
- // Visit a parse tree produced by ReactiveParser#atomicExpression.
276
- /**
277
- *
278
- * @param ctx
279
- * @returns {ReactiveExpression}
280
- */
281
- visitAtomicExpression(ctx) {
282
- return this.visitFirstChild(ctx);
283
- }
284
-
285
-
286
- // Visit a parse tree produced by ReactiveParser#literal.
287
- visitLiteral(ctx) {
288
- return this.visitFirstChild(ctx);
289
- }
290
-
291
-
292
- // Visit a parse tree produced by ReactiveParser#integerLiteral.
293
- visitIntegerLiteral(ctx) {
294
- const text = ctx.text;
295
- const value = parseInt(text, 10);
296
- return new ReactiveLiteralNumber(value);
297
- }
298
-
299
-
300
- // Visit a parse tree produced by ReactiveParser#floatingLiteral.
301
- visitFloatingLiteral(ctx) {
302
- const text = ctx.text;
303
- const value = parseFloat(text);
304
- return new ReactiveLiteralNumber(value);
305
- }
306
-
307
-
308
- // Visit a parse tree produced by ReactiveParser#booleanLiteral.
309
- visitBooleanLiteral(ctx) {
310
- const text = ctx.text;
311
- const value = text === 'true';
312
- return new ReactiveLiteralBoolean(value);
313
- };
314
-
315
- }
316
-
317
- /**
318
- *
319
- * @param {string} code
320
- * @returns {ReactiveExpression}
321
- */
322
- export function compileReactiveExpression(code) {
323
- assert.isString(code, 'code');
324
-
325
- const chars = new ANTLRInputStream(code);
326
-
327
- // break the character string input into tokens
328
- const lexer = new ReactiveLexer(chars);
329
-
330
- // create a token stream
331
- const tokens = new CommonTokenStream(lexer);
332
-
333
- // Initialize parser with a token stream
334
- const parser = new ReactiveParser(tokens);
335
-
336
- // Request parse tree to be built
337
- parser.buildParseTrees = true;
338
-
339
- // Build a parse tree from 'expression' rule
340
- const tree = parser.expression();
341
-
342
- // Initialize compiler visitor
343
- const visitor = new CompilingVisitor();
344
-
345
- // Compile CST
346
- const node = visitor.visit(tree);
347
-
348
- return node;
349
- }
350
-