FunctionCallCanonicalizationPass.h 701 B

1234567891011121314151617181920212223242526
  1. /*
  2. * Copyright (c) 2023, Dan Klishch <danilklishch@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include "Compiler/GenericASTPass.h"
  8. namespace JSSpecCompiler {
  9. // FunctionCallCanonicalizationPass simplifies ladders of BinaryOperators nodes in the function call
  10. // arguments into nice and neat FunctionCall nodes.
  11. //
  12. // Ladders initially appear since I do not want to complicate expression parser, so it interprets
  13. // `f(a, b, c, d)` as `f "function_call_operator" (a, (b, (c, d))))`.
  14. class FunctionCallCanonicalizationPass : public GenericASTPass {
  15. public:
  16. using GenericASTPass::GenericASTPass;
  17. protected:
  18. RecursionDecision on_entry(Tree tree) override;
  19. };
  20. }