sassc 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/ext/libsass/.gitignore +13 -6
  4. data/ext/libsass/Makefile +42 -26
  5. data/ext/libsass/Makefile.am +43 -30
  6. data/ext/libsass/Readme.md +4 -2
  7. data/ext/libsass/appveyor.yml +10 -14
  8. data/ext/libsass/ast.cpp +54 -44
  9. data/ext/libsass/ast.hpp +404 -236
  10. data/ext/libsass/ast_def_macros.hpp +5 -0
  11. data/ext/libsass/ast_factory.hpp +6 -3
  12. data/ext/libsass/ast_fwd_decl.hpp +12 -0
  13. data/ext/libsass/b64/encode.h +2 -2
  14. data/ext/libsass/backtrace.hpp +13 -17
  15. data/ext/libsass/base64vlq.hpp +4 -1
  16. data/ext/libsass/bind.cpp +12 -15
  17. data/ext/libsass/bind.hpp +6 -6
  18. data/ext/libsass/color_names.hpp +4 -1
  19. data/ext/libsass/configure.ac +7 -21
  20. data/ext/libsass/constants.cpp +6 -4
  21. data/ext/libsass/constants.hpp +10 -4
  22. data/ext/libsass/context.cpp +89 -58
  23. data/ext/libsass/context.hpp +28 -35
  24. data/ext/libsass/contextualize.cpp +20 -10
  25. data/ext/libsass/contextualize.hpp +8 -23
  26. data/ext/libsass/contrib/libsass.spec +66 -0
  27. data/ext/libsass/cssize.cpp +547 -0
  28. data/ext/libsass/cssize.hpp +82 -0
  29. data/ext/libsass/debug.hpp +3 -3
  30. data/ext/libsass/debugger.hpp +358 -0
  31. data/ext/libsass/emitter.cpp +255 -0
  32. data/ext/libsass/emitter.hpp +83 -0
  33. data/ext/libsass/environment.hpp +7 -3
  34. data/ext/libsass/error_handling.cpp +11 -14
  35. data/ext/libsass/error_handling.hpp +9 -7
  36. data/ext/libsass/eval.cpp +253 -161
  37. data/ext/libsass/eval.hpp +13 -13
  38. data/ext/libsass/expand.cpp +135 -64
  39. data/ext/libsass/expand.hpp +11 -13
  40. data/ext/libsass/extend.cpp +66 -20
  41. data/ext/libsass/extend.hpp +6 -11
  42. data/ext/libsass/file.cpp +31 -26
  43. data/ext/libsass/file.hpp +6 -1
  44. data/ext/libsass/functions.cpp +270 -287
  45. data/ext/libsass/functions.hpp +8 -11
  46. data/ext/libsass/inspect.cpp +385 -255
  47. data/ext/libsass/inspect.hpp +15 -26
  48. data/ext/libsass/kwd_arg_macros.hpp +5 -0
  49. data/ext/libsass/mapping.hpp +4 -3
  50. data/ext/libsass/memory_manager.hpp +5 -2
  51. data/ext/libsass/node.cpp +50 -50
  52. data/ext/libsass/node.hpp +26 -27
  53. data/ext/libsass/operation.hpp +15 -4
  54. data/ext/libsass/output.cpp +401 -0
  55. data/ext/libsass/output.hpp +56 -0
  56. data/ext/libsass/parser.cpp +573 -399
  57. data/ext/libsass/parser.hpp +122 -88
  58. data/ext/libsass/paths.hpp +7 -2
  59. data/ext/libsass/plugins.cpp +155 -0
  60. data/ext/libsass/plugins.hpp +56 -0
  61. data/ext/libsass/position.cpp +128 -0
  62. data/ext/libsass/position.hpp +108 -11
  63. data/ext/libsass/prelexer.cpp +184 -110
  64. data/ext/libsass/prelexer.hpp +131 -24
  65. data/ext/libsass/remove_placeholders.cpp +1 -1
  66. data/ext/libsass/remove_placeholders.hpp +6 -6
  67. data/ext/libsass/sass.cpp +3 -3
  68. data/ext/libsass/sass.h +12 -4
  69. data/ext/libsass/sass2scss.cpp +3 -2
  70. data/ext/libsass/sass2scss.h +5 -0
  71. data/ext/libsass/sass_context.cpp +136 -37
  72. data/ext/libsass/sass_context.h +19 -10
  73. data/ext/libsass/sass_functions.cpp +29 -2
  74. data/ext/libsass/sass_functions.h +8 -2
  75. data/ext/libsass/sass_interface.cpp +32 -23
  76. data/ext/libsass/sass_interface.h +9 -4
  77. data/ext/libsass/sass_util.cpp +19 -23
  78. data/ext/libsass/sass_util.hpp +28 -27
  79. data/ext/libsass/sass_values.cpp +6 -4
  80. data/ext/libsass/sass_values.h +3 -3
  81. data/ext/libsass/script/ci-build-libsass +13 -1
  82. data/ext/libsass/script/ci-report-coverage +2 -1
  83. data/ext/libsass/source_map.cpp +79 -28
  84. data/ext/libsass/source_map.hpp +35 -16
  85. data/ext/libsass/subset_map.hpp +6 -4
  86. data/ext/libsass/to_c.hpp +4 -4
  87. data/ext/libsass/to_string.cpp +13 -8
  88. data/ext/libsass/to_string.hpp +6 -4
  89. data/ext/libsass/units.cpp +2 -1
  90. data/ext/libsass/units.hpp +6 -1
  91. data/ext/libsass/utf8_string.cpp +0 -5
  92. data/ext/libsass/utf8_string.hpp +3 -2
  93. data/ext/libsass/util.cpp +461 -49
  94. data/ext/libsass/util.hpp +34 -13
  95. data/ext/libsass/version.sh +10 -0
  96. data/ext/libsass/win/libsass.filters +20 -11
  97. data/ext/libsass/win/libsass.vcxproj +11 -8
  98. data/lib/sassc/importer.rb +1 -8
  99. data/lib/sassc/native.rb +7 -0
  100. data/lib/sassc/native/native_context_api.rb +5 -5
  101. data/lib/sassc/version.rb +1 -1
  102. data/test/native_test.rb +1 -1
  103. metadata +14 -10
  104. data/ext/libsass/copy_c_str.cpp +0 -13
  105. data/ext/libsass/copy_c_str.hpp +0 -5
  106. data/ext/libsass/output_compressed.cpp +0 -401
  107. data/ext/libsass/output_compressed.hpp +0 -95
  108. data/ext/libsass/output_nested.cpp +0 -364
  109. data/ext/libsass/output_nested.hpp +0 -108
  110. data/ext/libsass/test-driver +0 -127
  111. data/ext/libsass/token.hpp +0 -32
@@ -0,0 +1,82 @@
1
+ #ifndef SASS_CSSIZE_H
2
+ #define SASS_CSSIZE_H
3
+
4
+ #include <vector>
5
+ #include <iostream>
6
+
7
+ #include "ast.hpp"
8
+ #include "context.hpp"
9
+ #include "operation.hpp"
10
+ #include "environment.hpp"
11
+
12
+ namespace Sass {
13
+ using namespace std;
14
+
15
+ typedef Environment<AST_Node*> Env;
16
+ struct Backtrace;
17
+
18
+ class Cssize : public Operation_CRTP<Statement*, Cssize> {
19
+
20
+ Context& ctx;
21
+ Env* env;
22
+ vector<Block*> block_stack;
23
+ vector<Statement*> p_stack;
24
+ Backtrace* backtrace;
25
+
26
+ Statement* fallback_impl(AST_Node* n);
27
+
28
+ public:
29
+ Cssize(Context&, Env*, Backtrace*);
30
+ virtual ~Cssize() { }
31
+
32
+ using Operation<Statement*>::operator();
33
+
34
+ Statement* operator()(Block*);
35
+ Statement* operator()(Ruleset*);
36
+ // Statement* operator()(Propset*);
37
+ // Statement* operator()(Bubble*);
38
+ Statement* operator()(Media_Block*);
39
+ Statement* operator()(Feature_Block*);
40
+ Statement* operator()(At_Root_Block*);
41
+ Statement* operator()(At_Rule*);
42
+ Statement* operator()(Keyframe_Rule*);
43
+ // Statement* operator()(Declaration*);
44
+ // Statement* operator()(Assignment*);
45
+ // Statement* operator()(Import*);
46
+ // Statement* operator()(Import_Stub*);
47
+ // Statement* operator()(Warning*);
48
+ // Statement* operator()(Error*);
49
+ // Statement* operator()(Comment*);
50
+ // Statement* operator()(If*);
51
+ // Statement* operator()(For*);
52
+ // Statement* operator()(Each*);
53
+ // Statement* operator()(While*);
54
+ // Statement* operator()(Return*);
55
+ // Statement* operator()(Extension*);
56
+ // Statement* operator()(Definition*);
57
+ // Statement* operator()(Mixin_Call*);
58
+ // Statement* operator()(Content*);
59
+
60
+ Statement* parent();
61
+ vector<pair<bool, Block*>> slice_by_bubble(Statement*);
62
+ Statement* bubble(At_Rule*);
63
+ Statement* bubble(At_Root_Block*);
64
+ Statement* bubble(Media_Block*);
65
+ Statement* bubble(Feature_Block*);
66
+ Statement* shallow_copy(Statement*);
67
+ Statement* debubble(Block* children, Statement* parent = 0);
68
+ Statement* flatten(Statement*);
69
+ bool bubblable(Statement*);
70
+
71
+ List* merge_media_queries(Media_Block*, Media_Block*);
72
+ Media_Query* merge_media_query(Media_Query*, Media_Query*);
73
+
74
+ template <typename U>
75
+ Statement* fallback(U x) { return fallback_impl(x); }
76
+
77
+ void append_block(Block*);
78
+ };
79
+
80
+ }
81
+
82
+ #endif
@@ -1,5 +1,5 @@
1
- #ifndef DEBUG_H
2
- #define DEBUG_H
1
+ #ifndef SASS_DEBUG_H
2
+ #define SASS_DEBUG_H
3
3
 
4
4
  #include <stdint.h>
5
5
 
@@ -36,4 +36,4 @@ const uint32_t debug_lvl = (DEBUG_LVL);
36
36
 
37
37
  #endif // DEBUG
38
38
 
39
- #endif // DEBUG_H
39
+ #endif // SASS_DEBUG
@@ -0,0 +1,358 @@
1
+ #ifndef SASS_DEBUGGER_H
2
+ #define SASS_DEBUGGER_H
3
+
4
+ #include <string>
5
+ #include "ast_fwd_decl.hpp"
6
+
7
+ using namespace std;
8
+ using namespace Sass;
9
+
10
+ inline string str_replace(std::string str, const std::string& oldStr, const std::string& newStr)
11
+ {
12
+ size_t pos = 0;
13
+ while((pos = str.find(oldStr, pos)) != std::string::npos)
14
+ {
15
+ str.replace(pos, oldStr.length(), newStr);
16
+ pos += newStr.length();
17
+ }
18
+ return str;
19
+ }
20
+
21
+ inline string prettyprint(const string& str) {
22
+ string clean = str_replace(str, "\n", "\\n");
23
+ clean = str_replace(clean, " ", "\\t");
24
+ clean = str_replace(clean, "\r", "\\r");
25
+ return clean;
26
+ }
27
+
28
+ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
29
+ {
30
+
31
+ if (ind == "") cerr << "####################################################################\n";
32
+ if (dynamic_cast<Bubble*>(node)) {
33
+ Bubble* bubble = dynamic_cast<Bubble*>(node);
34
+ cerr << ind << "Bubble " << bubble << " " << bubble->tabs() << endl;
35
+ } else if (dynamic_cast<At_Root_Block*>(node)) {
36
+ At_Root_Block* root_block = dynamic_cast<At_Root_Block*>(node);
37
+ cerr << ind << "At_Root_Block " << root_block << " " << root_block->tabs() << endl;
38
+ if (root_block->block()) for(auto i : root_block->block()->elements()) { debug_ast(i, ind + " ", env); }
39
+ } else if (dynamic_cast<Selector_List*>(node)) {
40
+ Selector_List* selector = dynamic_cast<Selector_List*>(node);
41
+
42
+ cerr << ind << "Selector_List " << selector
43
+ << " [block:" << selector->last_block() << "]"
44
+ << (selector->last_block() && selector->last_block()->is_root() ? " [root]" : "")
45
+ << " [@media:" << selector->media_block() << "]"
46
+ << (selector->is_optional() ? " [is_optional]": " -")
47
+ << (selector->has_line_break() ? " [line-break]": " -")
48
+ << (selector->has_line_feed() ? " [line-feed]": " -")
49
+ << endl;
50
+
51
+ for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); }
52
+
53
+ // } else if (dynamic_cast<Expression*>(node)) {
54
+ // Expression* expression = dynamic_cast<Expression*>(node);
55
+ // cerr << ind << "Expression " << expression << " " << expression->concrete_type() << endl;
56
+
57
+ } else if (dynamic_cast<Complex_Selector*>(node)) {
58
+ Complex_Selector* selector = dynamic_cast<Complex_Selector*>(node);
59
+ cerr << ind << "Complex_Selector " << selector
60
+ << " [block:" << selector->last_block() << "]"
61
+ << (selector->last_block() && selector->last_block()->is_root() ? " [root]" : "")
62
+ << " [@media:" << selector->media_block() << "]"
63
+ << (selector->is_optional() ? " [is_optional]": " -")
64
+ << (selector->has_line_break() ? " [line-break]": " -")
65
+ << (selector->has_line_feed() ? " [line-feed]": " -") << " -> ";
66
+ switch (selector->combinator()) {
67
+ case Complex_Selector::PARENT_OF: cerr << "{>}"; break;
68
+ case Complex_Selector::PRECEDES: cerr << "{~}"; break;
69
+ case Complex_Selector::ADJACENT_TO: cerr << "{+}"; break;
70
+ case Complex_Selector::ANCESTOR_OF: cerr << "{ }"; break;
71
+ }
72
+ cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << "> X <" << prettyprint(selector->pstate().token.ws_after()) << ">" << endl;
73
+ debug_ast(selector->head(), ind + " ", env);
74
+ debug_ast(selector->tail(), ind + "-", env);
75
+ } else if (dynamic_cast<Compound_Selector*>(node)) {
76
+ Compound_Selector* selector = dynamic_cast<Compound_Selector*>(node);
77
+ cerr << ind << "Compound_Selector " << selector
78
+ << " [block:" << selector->last_block() << "]"
79
+ << (selector->last_block() && selector->last_block()->is_root() ? " [root]" : "")
80
+ << " [@media:" << selector->media_block() << "]"
81
+ << (selector->is_optional() ? " [is_optional]": " -")
82
+ << (selector->has_line_break() ? " [line-break]": " -")
83
+ << (selector->has_line_feed() ? " [line-feed]": " -") <<
84
+ " <" << prettyprint(selector->pstate().token.ws_before()) << "> X <" << prettyprint(selector->pstate().token.ws_after()) << ">" << endl;
85
+ for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); }
86
+ } else if (dynamic_cast<Propset*>(node)) {
87
+ Propset* selector = dynamic_cast<Propset*>(node);
88
+ cerr << ind << "Propset " << selector << " " << selector->tabs() << endl;
89
+ if (selector->block()) for(auto i : selector->block()->elements()) { debug_ast(i, ind + " ", env); }
90
+ } else if (dynamic_cast<Wrapped_Selector*>(node)) {
91
+ Wrapped_Selector* selector = dynamic_cast<Wrapped_Selector*>(node);
92
+ cerr << ind << "Wrapped_Selector " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl;
93
+ debug_ast(selector->selector(), ind + " () ", env);
94
+ } else if (dynamic_cast<Pseudo_Selector*>(node)) {
95
+ Pseudo_Selector* selector = dynamic_cast<Pseudo_Selector*>(node);
96
+ cerr << ind << "Pseudo_Selector " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl;
97
+ debug_ast(selector->expression(), ind + " <= ", env);
98
+ } else if (dynamic_cast<Attribute_Selector*>(node)) {
99
+ Attribute_Selector* selector = dynamic_cast<Attribute_Selector*>(node);
100
+ cerr << ind << "Attribute_Selector " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl;
101
+ debug_ast(selector->value(), ind + "[" + selector->matcher() + "] ", env);
102
+ } else if (dynamic_cast<Selector_Qualifier*>(node)) {
103
+ Selector_Qualifier* selector = dynamic_cast<Selector_Qualifier*>(node);
104
+ cerr << ind << "Selector_Qualifier " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl;
105
+ } else if (dynamic_cast<Type_Selector*>(node)) {
106
+ Type_Selector* selector = dynamic_cast<Type_Selector*>(node);
107
+ cerr << ind << "Type_Selector " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") <<
108
+ " <" << prettyprint(selector->pstate().token.ws_before()) << "> X <" << prettyprint(selector->pstate().token.ws_after()) << ">" << endl;
109
+ } else if (dynamic_cast<Selector_Placeholder*>(node)) {
110
+
111
+ Selector_Placeholder* selector = dynamic_cast<Selector_Placeholder*>(node);
112
+ cerr << ind << "Selector_Placeholder [" << selector->name() << "] " << selector
113
+ << " [block:" << selector->last_block() << "]"
114
+ << " [@media:" << selector->media_block() << "]"
115
+ << (selector->is_optional() ? " [is_optional]": " -")
116
+ << (selector->has_line_break() ? " [line-break]": " -")
117
+ << (selector->has_line_feed() ? " [line-feed]": " -")
118
+ << endl;
119
+
120
+ } else if (dynamic_cast<Selector_Reference*>(node)) {
121
+ Selector_Reference* selector = dynamic_cast<Selector_Reference*>(node);
122
+ cerr << ind << "Selector_Reference " << selector << " @ref " << selector->selector() << endl;
123
+ } else if (dynamic_cast<Simple_Selector*>(node)) {
124
+ Simple_Selector* selector = dynamic_cast<Simple_Selector*>(node);
125
+ cerr << ind << "Simple_Selector " << selector << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl;
126
+
127
+ } else if (dynamic_cast<Selector_Schema*>(node)) {
128
+ Selector_Schema* selector = dynamic_cast<Selector_Schema*>(node);
129
+ cerr << ind << "Selector_Schema " << selector
130
+ << " [block:" << selector->last_block() << "]"
131
+ << (selector->last_block() && selector->last_block()->is_root() ? " [root]" : "")
132
+ << " [@media:" << selector->media_block() << "]"
133
+ << (selector->has_line_break() ? " [line-break]": " -")
134
+ << (selector->has_line_feed() ? " [line-feed]": " -")
135
+ << endl;
136
+
137
+ debug_ast(selector->contents(), ind + " ");
138
+ // for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); }
139
+
140
+ } else if (dynamic_cast<Selector*>(node)) {
141
+ Selector* selector = dynamic_cast<Selector*>(node);
142
+ cerr << ind << "Selector " << selector
143
+ << (selector->has_line_break() ? " [line-break]": " -")
144
+ << (selector->has_line_feed() ? " [line-feed]": " -")
145
+ << endl;
146
+
147
+ } else if (dynamic_cast<Media_Query_Expression*>(node)) {
148
+ Media_Query_Expression* block = dynamic_cast<Media_Query_Expression*>(node);
149
+ cerr << ind << "Media_Query_Expression " << block
150
+ << (block->is_interpolated() ? " [is_interpolated]": " -")
151
+ << endl;
152
+ debug_ast(block->feature(), ind + " f) ");
153
+ debug_ast(block->value(), ind + " v) ");
154
+
155
+ } else if (dynamic_cast<Media_Query*>(node)) {
156
+ Media_Query* block = dynamic_cast<Media_Query*>(node);
157
+ cerr << ind << "Media_Query " << block
158
+ << (block->is_negated() ? " [is_negated]": " -")
159
+ << (block->is_restricted() ? " [is_restricted]": " -")
160
+ << endl;
161
+ debug_ast(block->media_type(), ind + " ");
162
+ for(auto i : block->elements()) { debug_ast(i, ind + " ", env); }
163
+
164
+ } else if (dynamic_cast<Media_Block*>(node)) {
165
+ Media_Block* block = dynamic_cast<Media_Block*>(node);
166
+ cerr << ind << "Media_Block " << block << " " << block->tabs() << endl;
167
+ debug_ast(block->media_queries(), ind + " =@ ");
168
+ debug_ast(block->selector(), ind + " -@ ");
169
+ if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
170
+ } else if (dynamic_cast<Feature_Block*>(node)) {
171
+ Feature_Block* block = dynamic_cast<Feature_Block*>(node);
172
+ cerr << ind << "Feature_Block " << block << " " << block->tabs() << endl;
173
+ if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
174
+ } else if (dynamic_cast<Block*>(node)) {
175
+ Block* root_block = dynamic_cast<Block*>(node);
176
+ cerr << ind << "Block " << root_block << " " << root_block->tabs() << endl;
177
+ if (root_block->block()) for(auto i : root_block->block()->elements()) { debug_ast(i, ind + " ", env); }
178
+ } else if (dynamic_cast<Warning*>(node)) {
179
+ Warning* block = dynamic_cast<Warning*>(node);
180
+ cerr << ind << "Warning " << block << " " << block->tabs() << endl;
181
+ } else if (dynamic_cast<Error*>(node)) {
182
+ Error* block = dynamic_cast<Error*>(node);
183
+ cerr << ind << "Error " << block << " " << block->tabs() << endl;
184
+ } else if (dynamic_cast<Debug*>(node)) {
185
+ Debug* block = dynamic_cast<Debug*>(node);
186
+ cerr << ind << "Debug " << block << " " << block->tabs() << endl;
187
+ } else if (dynamic_cast<Comment*>(node)) {
188
+ Comment* block = dynamic_cast<Comment*>(node);
189
+ cerr << ind << "Comment " << block << " " << block->tabs() <<
190
+ " <" << prettyprint(block->pstate().token.ws_before()) << "> X <" << prettyprint(block->pstate().token.ws_after()) << ">" << endl;
191
+ debug_ast(block->text(), ind + "// ", env);
192
+ } else if (dynamic_cast<If*>(node)) {
193
+ If* block = dynamic_cast<If*>(node);
194
+ cerr << ind << "If " << block << " " << block->tabs() << endl;
195
+ } else if (dynamic_cast<Return*>(node)) {
196
+ Return* block = dynamic_cast<Return*>(node);
197
+ cerr << ind << "Return " << block << " " << block->tabs() << endl;
198
+ } else if (dynamic_cast<Extension*>(node)) {
199
+ Extension* block = dynamic_cast<Extension*>(node);
200
+ cerr << ind << "Extension " << block << " " << block->tabs() << endl;
201
+ debug_ast(block->selector(), ind + "-> ", env);
202
+ } else if (dynamic_cast<Content*>(node)) {
203
+ Content* block = dynamic_cast<Content*>(node);
204
+ cerr << ind << "Content " << block << " " << block->tabs() << endl;
205
+ } else if (dynamic_cast<Import_Stub*>(node)) {
206
+ Import_Stub* block = dynamic_cast<Import_Stub*>(node);
207
+ cerr << ind << "Import_Stub " << block << " " << block->tabs() << endl;
208
+ } else if (dynamic_cast<Import*>(node)) {
209
+ Import* block = dynamic_cast<Import*>(node);
210
+ cerr << ind << "Import " << block << " " << block->tabs() << endl;
211
+ // vector<string> files_;
212
+ for (auto imp : block->urls()) debug_ast(imp, "@ ", env);
213
+ } else if (dynamic_cast<Assignment*>(node)) {
214
+ Assignment* block = dynamic_cast<Assignment*>(node);
215
+ cerr << ind << "Assignment " << block << " <<" << block->variable() << ">> " << block->tabs() << endl;
216
+ debug_ast(block->value(), ind + "=", env);
217
+ } else if (dynamic_cast<Declaration*>(node)) {
218
+ Declaration* block = dynamic_cast<Declaration*>(node);
219
+ cerr << ind << "Declaration " << block << " " << block->tabs() << endl;
220
+ debug_ast(block->property(), ind + " prop: ", env);
221
+ debug_ast(block->value(), ind + " value: ", env);
222
+ } else if (dynamic_cast<At_Rule*>(node)) {
223
+ At_Rule* block = dynamic_cast<At_Rule*>(node);
224
+ cerr << ind << "At_Rule " << block << " [" << block->keyword() << "] " << block->tabs() << endl;
225
+ debug_ast(block->value(), ind + "+", env);
226
+ debug_ast(block->selector(), ind + "~", env);
227
+ if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
228
+ } else if (dynamic_cast<Each*>(node)) {
229
+ Each* block = dynamic_cast<Each*>(node);
230
+ cerr << ind << "Each " << block << " " << block->tabs() << endl;
231
+ if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
232
+ } else if (dynamic_cast<For*>(node)) {
233
+ For* block = dynamic_cast<For*>(node);
234
+ cerr << ind << "For " << block << " " << block->tabs() << endl;
235
+ if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
236
+ } else if (dynamic_cast<While*>(node)) {
237
+ While* block = dynamic_cast<While*>(node);
238
+ cerr << ind << "While " << block << " " << block->tabs() << endl;
239
+ if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
240
+ } else if (dynamic_cast<Definition*>(node)) {
241
+ Definition* block = dynamic_cast<Definition*>(node);
242
+ cerr << ind << "Definition " << block << " " << block->tabs() << endl;
243
+ if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
244
+ } else if (dynamic_cast<Mixin_Call*>(node)) {
245
+ Mixin_Call* block = dynamic_cast<Mixin_Call*>(node);
246
+ cerr << ind << "Mixin_Call " << block << " " << block->tabs() << endl;
247
+ if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
248
+ } else if (dynamic_cast<Ruleset*>(node)) {
249
+ Ruleset* ruleset = dynamic_cast<Ruleset*>(node);
250
+ cerr << ind << "Ruleset " << ruleset << " " << ruleset->tabs() << endl;
251
+ debug_ast(ruleset->selector(), ind + " ");
252
+ if (ruleset->block()) for(auto i : ruleset->block()->elements()) { debug_ast(i, ind + " ", env); }
253
+ } else if (dynamic_cast<Block*>(node)) {
254
+ Block* block = dynamic_cast<Block*>(node);
255
+ cerr << ind << "Block " << block << " " << block->tabs() << endl;
256
+ for(auto i : block->elements()) { debug_ast(i, ind + " ", env); }
257
+ } else if (dynamic_cast<Textual*>(node)) {
258
+ Textual* expression = dynamic_cast<Textual*>(node);
259
+ cerr << ind << "Textual ";
260
+ if (expression->type() == Textual::NUMBER) cerr << " [NUMBER]";
261
+ else if (expression->type() == Textual::PERCENTAGE) cerr << " [PERCENTAGE]";
262
+ else if (expression->type() == Textual::DIMENSION) cerr << " [DIMENSION]";
263
+ else if (expression->type() == Textual::HEX) cerr << " [HEX]";
264
+ cerr << expression << " [" << expression->value() << "]" << endl;
265
+ } else if (dynamic_cast<Variable*>(node)) {
266
+ Variable* expression = dynamic_cast<Variable*>(node);
267
+ cerr << ind << "Variable " << expression << " [" << expression->name() << "]" << endl;
268
+ string name(expression->name());
269
+ if (env && env->has(name)) debug_ast(static_cast<Expression*>((*env)[name]), ind + " -> ", env);
270
+ } else if (dynamic_cast<Function_Call_Schema*>(node)) {
271
+ Function_Call_Schema* expression = dynamic_cast<Function_Call_Schema*>(node);
272
+ cerr << ind << "Function_Call_Schema " << expression << "]" << endl;
273
+ debug_ast(expression->name(), ind + "name: ", env);
274
+ debug_ast(expression->arguments(), ind + " args: ", env);
275
+ } else if (dynamic_cast<Function_Call*>(node)) {
276
+ Function_Call* expression = dynamic_cast<Function_Call*>(node);
277
+ cerr << ind << "Function_Call " << expression << " [" << expression->name() << "]" << endl;
278
+ debug_ast(expression->arguments(), ind + " args: ", env);
279
+ } else if (dynamic_cast<Arguments*>(node)) {
280
+ Arguments* expression = dynamic_cast<Arguments*>(node);
281
+ cerr << ind << "Arguments " << expression << "]" << endl;
282
+ for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); }
283
+ } else if (dynamic_cast<Argument*>(node)) {
284
+ Argument* expression = dynamic_cast<Argument*>(node);
285
+ cerr << ind << "Argument " << expression << " [" << expression->value() << "]" << endl;
286
+ debug_ast(expression->value(), ind + " value: ", env);
287
+ } else if (dynamic_cast<Unary_Expression*>(node)) {
288
+ Unary_Expression* expression = dynamic_cast<Unary_Expression*>(node);
289
+ cerr << ind << "Unary_Expression " << expression << " [" << expression->type() << "]" << endl;
290
+ debug_ast(expression->operand(), ind + " operand: ", env);
291
+ } else if (dynamic_cast<Binary_Expression*>(node)) {
292
+ Binary_Expression* expression = dynamic_cast<Binary_Expression*>(node);
293
+ cerr << ind << "Binary_Expression " << expression << " [" << expression->type() << "]" << endl;
294
+ debug_ast(expression->left(), ind + " left: ", env);
295
+ debug_ast(expression->right(), ind + " right: ", env);
296
+ } else if (dynamic_cast<Map*>(node)) {
297
+ Map* expression = dynamic_cast<Map*>(node);
298
+ cerr << ind << "Map " << expression << " [Hashed]" << endl;
299
+ } else if (dynamic_cast<List*>(node)) {
300
+ List* expression = dynamic_cast<List*>(node);
301
+ cerr << ind << "List " << expression <<
302
+ (expression->separator() == Sass::List::Separator::COMMA ? "Comma " : "Space ") <<
303
+ " [delayed: " << expression->is_delayed() << "] " <<
304
+ " [interpolant: " << expression->is_interpolant() << "] " <<
305
+ endl;
306
+ for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); }
307
+ } else if (dynamic_cast<Content*>(node)) {
308
+ Content* expression = dynamic_cast<Content*>(node);
309
+ cerr << ind << "Content " << expression << " [Statement]" << endl;
310
+ } else if (dynamic_cast<Boolean*>(node)) {
311
+ Boolean* expression = dynamic_cast<Boolean*>(node);
312
+ cerr << ind << "Boolean " << expression << " [" << expression->value() << "]" << endl;
313
+ } else if (dynamic_cast<Color*>(node)) {
314
+ Color* expression = dynamic_cast<Color*>(node);
315
+ cerr << ind << "Color " << expression << " [" << expression->r() << ":" << expression->g() << ":" << expression->b() << "@" << expression->a() << "]" << endl;
316
+ } else if (dynamic_cast<Number*>(node)) {
317
+ Number* expression = dynamic_cast<Number*>(node);
318
+ cerr << ind << "Number " << expression << " [" << expression->value() << expression->unit() << "]" << endl;
319
+ } else if (dynamic_cast<String_Quoted*>(node)) {
320
+ String_Quoted* expression = dynamic_cast<String_Quoted*>(node);
321
+ cerr << ind << "String_Quoted : " << expression << " [" << prettyprint(expression->value()) << "]" <<
322
+ (expression->is_delayed() ? " {delayed}" : "") <<
323
+ (expression->sass_fix_1291() ? " {sass_fix_1291}" : "") <<
324
+ (expression->quote_mark() != 0 ? " {qm:" + string(1, expression->quote_mark()) + "}" : "") <<
325
+ " <" << prettyprint(expression->pstate().token.ws_before()) << "> X <" << prettyprint(expression->pstate().token.ws_after()) << ">" << endl;
326
+ } else if (dynamic_cast<String_Constant*>(node)) {
327
+ String_Constant* expression = dynamic_cast<String_Constant*>(node);
328
+ cerr << ind << "String_Constant : " << expression << " [" << prettyprint(expression->value()) << "]" <<
329
+ (expression->is_delayed() ? " {delayed}" : "") <<
330
+ (expression->sass_fix_1291() ? " {sass_fix_1291}" : "") <<
331
+ " <" << prettyprint(expression->pstate().token.ws_before()) << "> X <" << prettyprint(expression->pstate().token.ws_after()) << ">" << endl;
332
+ } else if (dynamic_cast<String_Schema*>(node)) {
333
+ String_Schema* expression = dynamic_cast<String_Schema*>(node);
334
+ cerr << ind << "String_Schema " << expression << " " << expression->concrete_type() <<
335
+ (expression->has_interpolants() ? " {has_interpolants}" : "") <<
336
+ endl;
337
+ for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); }
338
+ } else if (dynamic_cast<String*>(node)) {
339
+ String* expression = dynamic_cast<String*>(node);
340
+ cerr << ind << "String " << expression << expression->concrete_type() <<
341
+ " " << (expression->sass_fix_1291() ? "{sass_fix_1291}" : "") <<
342
+ endl;
343
+ } else if (dynamic_cast<Expression*>(node)) {
344
+ Expression* expression = dynamic_cast<Expression*>(node);
345
+ cerr << ind << "Expression " << expression << " " << expression->concrete_type() << endl;
346
+ } else if (dynamic_cast<Has_Block*>(node)) {
347
+ Has_Block* has_block = dynamic_cast<Has_Block*>(node);
348
+ cerr << ind << "Has_Block " << has_block << " " << has_block->tabs() << endl;
349
+ if (has_block->block()) for(auto i : has_block->block()->elements()) { debug_ast(i, ind + " ", env); }
350
+ } else if (dynamic_cast<Statement*>(node)) {
351
+ Statement* statement = dynamic_cast<Statement*>(node);
352
+ cerr << ind << "Statement " << statement << " " << statement->tabs() << endl;
353
+ }
354
+
355
+ if (ind == "") cerr << "####################################################################\n";
356
+ }
357
+
358
+ #endif // SASS_DEBUGGER