File: SwitchToIf.h

package info (click to toggle)
rumur 2026.03.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,664 kB
  • sloc: cpp: 18,723; ansic: 3,824; python: 1,578; objc: 1,542; yacc: 568; sh: 331; lex: 241; lisp: 15; makefile: 5
file content (29 lines) | stat: -rw-r--r-- 677 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#pragma once

#include "Stage.h"
#include <cstddef>
#include <rumur/rumur.h>
#include <string>

// a stage for turning switch statements into if statements
class SwitchToIf : public IntermediateStage {

private:
  // have we figured out what character(s) are used for indentation?
  bool learned_indentation = false;

  // was the last relevant character we saw a newline?
  bool last_newline = false;

  // the character(s) we believe to represent one level of indentation
  std::string indentation;

public:
  explicit SwitchToIf(Stage &next_);

  void process(const Token &t) final;

  void visit_switch(const rumur::Switch &n) final;

  virtual ~SwitchToIf() = default;
};