forked from sass/libsass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemitter.hpp
83 lines (71 loc) · 2.35 KB
/
emitter.hpp
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
#ifndef SASS_EMITTER_H
#define SASS_EMITTER_H
#include <string>
#include "source_map.hpp"
#include "ast_fwd_decl.hpp"
namespace Sass {
class Context;
using namespace std;
class Emitter {
public:
Emitter(Context* ctx);
virtual ~Emitter() { };
protected:
OutputBuffer wbuf;
public:
const string buffer(void) { return wbuf.buffer; }
const SourceMap smap(void) { return wbuf.smap; }
const OutputBuffer output(void) { return wbuf; }
// proxy methods for source maps
void add_source_index(size_t idx);
void set_filename(const string& str);
void add_open_mapping(AST_Node* node);
void add_close_mapping(AST_Node* node);
string generate_source_map(Context &ctx);
ParserState remap(const ParserState& pstate);
public:
Context* ctx;
size_t indentation;
size_t scheduled_space;
size_t scheduled_linefeed;
bool scheduled_delimiter;
public:
bool in_comment;
bool in_wrapped;
bool in_media_block;
bool in_declaration;
bool in_declaration_list;
public:
// return buffer as string
string get_buffer(void);
// flush scheduled space/linefeed
Output_Style output_style(void);
// add outstanding linefeed
void finalize(void);
// flush scheduled space/linefeed
void flush_schedules(void);
// prepend some text or token to the buffer
void prepend_string(const string& text);
void prepend_output(const OutputBuffer& out);
// append some text or token to the buffer
void append_string(const string& text);
// append some white-space only text
void append_wspace(const string& text);
// append some text or token to the buffer
// this adds source-mappings for node start and end
void append_token(const string& text, AST_Node* node);
public: // syntax sugar
void append_indentation();
void append_optional_space(void);
void append_mandatory_space(void);
void append_special_linefeed(void);
void append_optional_linefeed(void);
void append_mandatory_linefeed(void);
void append_scope_opener(AST_Node* node = 0);
void append_scope_closer(AST_Node* node = 0);
void append_comma_separator(void);
void append_colon_separator(void);
void append_delimiter(void);
};
}
#endif