[go: up one dir, main page]

File: findentclass.h

package info (click to toggle)
findent 3.1.7-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 2,176 kB
  • sloc: sh: 4,746; cpp: 4,049; fortran: 1,565; pascal: 1,204; lex: 533; yacc: 305; makefile: 179; python: 155; lisp: 52
file content (112 lines) | stat: -rw-r--r-- 2,720 bytes parent folder | download
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#ifndef FINDENTCLASS_H
#define FINDENTCLASS_H

#include <set>
#include <utility>  // pair
#include <string>

#include "flags.h"
#include "prop.h"
#include "findent_types.h"
#include "debug.h"
#include "fortranline.h"
#include "globals.h"

class Findent
{

   public:
      Findent() {}

      Findent(Flags &f)
      {
	 //
	 // public
	 //
	 gl                 = new Globals;
	 cur_indent         = 0;
	 cur_rprop          = empty_rprop;
	 end_of_file        = 0;
	 endline            = "\n";
	 flags              = f;
	 indent_handled     = 0;
	 labellength        = 0;
	 nbseen             = 0;
	 num_lines          = 0;
	 start_indent       = 0;

	 gl->global_format      = UNKNOWN;
	 gl->global_gnu_format  = flags.input_format_gnu;;
	 gl->global_line_length = flags.input_line_length;
	 gl->global_omp         = flags.honour_omp;

	 //
	 // private
	 //
	 all_indent         = 0;
	 endline_set        = 0;
	 input_format       = flags.input_format;
	 lines_read         = 0;
	 output_format      = 0;
	 reading_from_tty   = 0;
	 //
	 // for getnext:
	 //
	 prevlastchar       = 0;
      }

      ~Findent() { delete gl; }

      Fortranline getnext(bool &eof, bool use_wb = 1);
      Fortranline mygetline(bool &eof, bool buffer = 0);

      void         handle_pre_light(Fortranline &line, bool &p_more);
      void         init_indent();
      int          run();

      int          cur_indent;
      std::string  endline;
      bool         end_of_file;
      Flags        flags;
      Globals*     gl;
      bool         indent_handled;
      indent_t     indent;          // to store indents
      int          input_format;
      int          labellength;
      bool         nbseen;
      int          num_lines;
      int          output_format;
      int          start_indent;

      std::set <std::pair<int,std::string> > includes;

   private:

      int          all_indent;
      linebuffer_t curlinebuffer;   // deque for source lines
      prop_t       cur_rprop;
      bool         endline_set;
      int          lines_read;
      bool         reading_from_tty;
      linebuffer_t wizardbuffer;    // to store wizard lines and push back lines from handle_fortran

      int          determine_fix_or_free();
      int          guess_fixedfree(Fortranline &line);
      int          guess_indent(Fortranline line);
      std::string  handle_dos(const std::string &s);
      void         handle_reading_from_tty();
      void         output_deps();
      std::string  type2str(const int t);
      int          what_to_return();

      void push_indent(int p) { indent.push_back(p); }

      // for handle_pre_light:
      int pregentype;

      // for getnext:
      char prevlastchar;

};

#endif