sassc 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/ext/libsass/.gitignore +6 -0
  4. data/ext/libsass/.travis.yml +5 -1
  5. data/ext/libsass/Makefile +12 -3
  6. data/ext/libsass/Makefile.am +16 -28
  7. data/ext/libsass/Readme.md +1 -0
  8. data/ext/libsass/appveyor.yml +1 -2
  9. data/ext/libsass/ast.cpp +9 -0
  10. data/ext/libsass/ast.hpp +152 -55
  11. data/ext/libsass/ast_factory.hpp +2 -0
  12. data/ext/libsass/ast_fwd_decl.hpp +1 -0
  13. data/ext/libsass/backtrace.hpp +2 -2
  14. data/ext/libsass/bind.cpp +15 -13
  15. data/ext/libsass/configure.ac +17 -5
  16. data/ext/libsass/constants.cpp +22 -2
  17. data/ext/libsass/constants.hpp +21 -2
  18. data/ext/libsass/context.cpp +79 -57
  19. data/ext/libsass/context.hpp +23 -9
  20. data/ext/libsass/contextualize.cpp +2 -28
  21. data/ext/libsass/contextualize.hpp +6 -10
  22. data/ext/libsass/contextualize_eval.cpp +93 -0
  23. data/ext/libsass/contextualize_eval.hpp +44 -0
  24. data/ext/libsass/contrib/plugin.cpp +57 -0
  25. data/ext/libsass/cssize.cpp +3 -1
  26. data/ext/libsass/debugger.hpp +242 -83
  27. data/ext/libsass/emitter.cpp +1 -1
  28. data/ext/libsass/emitter.hpp +1 -1
  29. data/ext/libsass/environment.hpp +109 -25
  30. data/ext/libsass/error_handling.cpp +3 -3
  31. data/ext/libsass/error_handling.hpp +0 -1
  32. data/ext/libsass/eval.cpp +145 -61
  33. data/ext/libsass/eval.hpp +9 -1
  34. data/ext/libsass/expand.cpp +134 -60
  35. data/ext/libsass/expand.hpp +5 -2
  36. data/ext/libsass/extend.cpp +7 -5
  37. data/ext/libsass/file.cpp +176 -123
  38. data/ext/libsass/file.hpp +44 -7
  39. data/ext/libsass/functions.cpp +36 -17
  40. data/ext/libsass/functions.hpp +2 -2
  41. data/ext/libsass/inspect.cpp +23 -14
  42. data/ext/libsass/inspect.hpp +1 -0
  43. data/ext/libsass/json.cpp +132 -135
  44. data/ext/libsass/lexer.cpp +133 -0
  45. data/ext/libsass/lexer.hpp +239 -0
  46. data/ext/libsass/listize.cpp +83 -0
  47. data/ext/libsass/listize.hpp +41 -0
  48. data/ext/libsass/operation.hpp +2 -0
  49. data/ext/libsass/output.cpp +5 -6
  50. data/ext/libsass/parser.cpp +426 -388
  51. data/ext/libsass/parser.hpp +97 -109
  52. data/ext/libsass/plugins.cpp +15 -2
  53. data/ext/libsass/plugins.hpp +6 -4
  54. data/ext/libsass/position.cpp +52 -17
  55. data/ext/libsass/position.hpp +19 -17
  56. data/ext/libsass/prelexer.cpp +202 -235
  57. data/ext/libsass/prelexer.hpp +73 -333
  58. data/ext/libsass/sass.cpp +21 -11
  59. data/ext/libsass/sass.h +6 -6
  60. data/ext/libsass/sass_context.cpp +167 -81
  61. data/ext/libsass/sass_context.h +26 -6
  62. data/ext/libsass/sass_functions.cpp +49 -40
  63. data/ext/libsass/sass_functions.h +55 -43
  64. data/ext/libsass/sass_interface.cpp +9 -8
  65. data/ext/libsass/sass_interface.h +3 -3
  66. data/ext/libsass/sass_version.h +8 -0
  67. data/ext/libsass/sass_version.h.in +8 -0
  68. data/ext/libsass/script/ci-build-libsass +3 -3
  69. data/ext/libsass/script/ci-report-coverage +2 -1
  70. data/ext/libsass/source_map.cpp +2 -2
  71. data/ext/libsass/util.cpp +60 -11
  72. data/ext/libsass/util.hpp +6 -1
  73. data/ext/libsass/win/libsass.filters +12 -0
  74. data/ext/libsass/win/libsass.vcxproj +10 -0
  75. data/lib/sassc.rb +3 -1
  76. data/lib/sassc/cache_stores/base.rb +2 -0
  77. data/lib/sassc/dependency.rb +3 -1
  78. data/lib/sassc/engine.rb +31 -16
  79. data/lib/sassc/error.rb +3 -2
  80. data/lib/sassc/functions_handler.rb +54 -0
  81. data/lib/sassc/import_handler.rb +41 -0
  82. data/lib/sassc/importer.rb +4 -31
  83. data/lib/sassc/native.rb +1 -1
  84. data/lib/sassc/native/native_context_api.rb +3 -2
  85. data/lib/sassc/script.rb +0 -51
  86. data/lib/sassc/version.rb +1 -1
  87. data/sassc.gemspec +1 -0
  88. data/test/custom_importer_test.rb +72 -69
  89. data/test/engine_test.rb +53 -54
  90. data/test/functions_test.rb +40 -39
  91. data/test/native_test.rb +145 -149
  92. data/test/output_style_test.rb +98 -0
  93. data/test/test_helper.rb +21 -7
  94. metadata +28 -2
@@ -18,7 +18,7 @@
18
18
  #include "plugins.hpp"
19
19
  #include "sass_functions.h"
20
20
 
21
- struct Sass_C_Function_Descriptor;
21
+ struct Sass_Function;
22
22
 
23
23
  namespace Sass {
24
24
  using namespace std;
@@ -32,8 +32,11 @@ namespace Sass {
32
32
 
33
33
  class Context {
34
34
  public:
35
+ size_t head_imports;
35
36
  Memory_Manager<AST_Node> mem;
36
37
 
38
+ struct Sass_Options* c_options;
39
+ struct Sass_Compiler* c_compiler;
37
40
  const char* source_c_str;
38
41
 
39
42
  // c-strs containing Sass file contents
@@ -51,7 +54,14 @@ namespace Sass {
51
54
  map<string, Block*> style_sheets; // map of paths to ASTs
52
55
  // SourceMap source_map;
53
56
  Output emitter;
54
- vector<Sass_C_Function_Callback> c_functions;
57
+
58
+ vector<Sass_Importer_Entry> c_headers;
59
+ vector<Sass_Importer_Entry> c_importers;
60
+ vector<Sass_Function_Entry> c_functions;
61
+
62
+ void add_c_header(Sass_Importer_Entry header);
63
+ void add_c_importer(Sass_Importer_Entry importer);
64
+ void add_c_function(Sass_Function_Entry function);
55
65
 
56
66
  string indent; // String to be used for indentation
57
67
  string linefeed; // String to be used for line feeds
@@ -67,8 +77,7 @@ namespace Sass {
67
77
  bool is_indented_syntax_src; // treat source string as sass
68
78
 
69
79
  // overload import calls
70
- Sass_C_Import_Callback importer;
71
- vector<struct Sass_Import*> import_stack;
80
+ vector<Sass_Import_Entry> import_stack;
72
81
 
73
82
  map<string, Color*> names_to_colors;
74
83
  map<int, string> colors_to_names;
@@ -76,6 +85,8 @@ namespace Sass {
76
85
  size_t precision; // precision for outputting fractional numbers
77
86
 
78
87
  KWD_ARG_SET(Data) {
88
+ KWD_ARG(Data, struct Sass_Options*, c_options);
89
+ KWD_ARG(Data, struct Sass_Compiler*, c_compiler);
79
90
  KWD_ARG(Data, const char*, source_c_str);
80
91
  KWD_ARG(Data, string, entry_point);
81
92
  KWD_ARG(Data, string, input_path);
@@ -84,8 +95,8 @@ namespace Sass {
84
95
  KWD_ARG(Data, string, linefeed);
85
96
  KWD_ARG(Data, const char*, include_paths_c_str);
86
97
  KWD_ARG(Data, const char*, plugin_paths_c_str);
87
- KWD_ARG(Data, const char**, include_paths_array);
88
- KWD_ARG(Data, const char**, plugin_paths_array);
98
+ // KWD_ARG(Data, const char**, include_paths_array);
99
+ // KWD_ARG(Data, const char**, plugin_paths_array);
89
100
  KWD_ARG(Data, vector<string>, include_paths);
90
101
  KWD_ARG(Data, vector<string>, plugin_paths);
91
102
  KWD_ARG(Data, bool, source_comments);
@@ -97,18 +108,21 @@ namespace Sass {
97
108
  KWD_ARG(Data, size_t, precision);
98
109
  KWD_ARG(Data, bool, source_map_embed);
99
110
  KWD_ARG(Data, bool, source_map_contents);
100
- KWD_ARG(Data, Sass_C_Import_Callback, importer);
101
111
  };
102
112
 
103
113
  Context(Data);
104
114
  ~Context();
105
115
  static string get_cwd();
106
116
  void setup_color_map();
107
- string add_file(string);
117
+
108
118
  Block* parse_file();
109
- string add_file(string, string);
110
119
  Block* parse_string();
111
120
  void add_source(string, string, const char*);
121
+
122
+ string add_file(const string& file);
123
+ string add_file(const string& base, const string& file);
124
+
125
+
112
126
  // allow to optionally overwrite the input path
113
127
  // default argument for input_path is string("stdin")
114
128
  // usefull to influence the source-map generating etc.
@@ -7,8 +7,8 @@
7
7
 
8
8
  namespace Sass {
9
9
 
10
- Contextualize::Contextualize(Context& ctx, Eval* eval, Env* env, Backtrace* bt, Selector* placeholder, Selector* extender)
11
- : ctx(ctx), eval(eval), env(env), parent(0), backtrace(bt), placeholder(placeholder), extender(extender)
10
+ Contextualize::Contextualize(Context& ctx, Env* env, Backtrace* bt, Selector* placeholder, Selector* extender)
11
+ : ctx(ctx), env(env), backtrace(bt), parent(0), placeholder(placeholder), extender(extender)
12
12
  { }
13
13
 
14
14
  Contextualize::~Contextualize() { }
@@ -26,18 +26,6 @@ namespace Sass {
26
26
  return this;
27
27
  }
28
28
 
29
- Selector* Contextualize::operator()(Selector_Schema* s)
30
- {
31
- To_String to_string(&ctx);
32
- string result_str(s->contents()->perform(eval->with(env, backtrace))->perform(&to_string));
33
- result_str += '{'; // the parser looks for a brace to end the selector
34
- Parser p = Parser::from_c_str(result_str.c_str(), ctx, s->pstate());
35
- p.block_stack.push_back(s->last_block());
36
- p.last_media_block = s->media_block();
37
- Selector* result_sel = p.parse_selector_group();
38
- return result_sel->perform(this);
39
- }
40
-
41
29
  Selector* Contextualize::operator()(Selector_List* s)
42
30
  {
43
31
  Selector_List* p = static_cast<Selector_List*>(parent);
@@ -126,18 +114,6 @@ namespace Sass {
126
114
  Selector* Contextualize::operator()(Pseudo_Selector* s)
127
115
  { return s; }
128
116
 
129
- Selector* Contextualize::operator()(Attribute_Selector* s)
130
- {
131
- // the value might be interpolated; evaluate it
132
- String* v = s->value();
133
- if (v && eval) {
134
- v = static_cast<String*>(v->perform(eval->with(env, backtrace)));
135
- }
136
- Attribute_Selector* ss = new (ctx.mem) Attribute_Selector(*s);
137
- ss->value(v);
138
- return ss;
139
- }
140
-
141
117
  Selector* Contextualize::operator()(Selector_Qualifier* s)
142
118
  { return s; }
143
119
 
@@ -162,6 +138,4 @@ namespace Sass {
162
138
  ss->selector(parent);
163
139
  return ss;
164
140
  }
165
-
166
-
167
141
  }
@@ -1,7 +1,6 @@
1
1
  #ifndef SASS_CONTEXTUALIZE_H
2
2
  #define SASS_CONTEXTUALIZE_H
3
3
 
4
- #include "eval.hpp"
5
4
  #include "context.hpp"
6
5
  #include "operation.hpp"
7
6
  #include "environment.hpp"
@@ -14,29 +13,26 @@ namespace Sass {
14
13
 
15
14
  class Contextualize : public Operation_CRTP<Selector*, Contextualize> {
16
15
 
16
+
17
+ public:
17
18
  Context& ctx;
18
- Eval* eval;
19
19
  Env* env;
20
- Selector* parent;
21
20
  Backtrace* backtrace;
22
-
23
- Selector* fallback_impl(AST_Node* n);
24
-
25
- public:
21
+ Selector* parent;
26
22
  Selector* placeholder;
27
23
  Selector* extender;
28
- Contextualize(Context&, Eval*, Env*, Backtrace*, Selector* placeholder = 0, Selector* extender = 0);
24
+
25
+ Selector* fallback_impl(AST_Node* n);
26
+ Contextualize(Context&, Env*, Backtrace*, Selector* placeholder = 0, Selector* extender = 0);
29
27
  virtual ~Contextualize();
30
28
  Contextualize* with(Selector*, Env*, Backtrace*, Selector* placeholder = 0, Selector* extender = 0);
31
29
  using Operation<Selector*>::operator();
32
30
 
33
- Selector* operator()(Selector_Schema*);
34
31
  Selector* operator()(Selector_List*);
35
32
  Selector* operator()(Complex_Selector*);
36
33
  Selector* operator()(Compound_Selector*);
37
34
  Selector* operator()(Wrapped_Selector*);
38
35
  Selector* operator()(Pseudo_Selector*);
39
- Selector* operator()(Attribute_Selector*);
40
36
  Selector* operator()(Selector_Qualifier*);
41
37
  Selector* operator()(Type_Selector*);
42
38
  Selector* operator()(Selector_Placeholder*);
@@ -0,0 +1,93 @@
1
+ #include "contextualize_eval.hpp"
2
+ #include "ast.hpp"
3
+ #include "eval.hpp"
4
+ #include "backtrace.hpp"
5
+ #include "to_string.hpp"
6
+ #include "parser.hpp"
7
+
8
+ namespace Sass {
9
+
10
+ Contextualize_Eval::Contextualize_Eval(Context& ctx, Eval* eval, Env* env, Backtrace* bt)
11
+ : Contextualize(ctx, env, bt), eval(eval)
12
+ { }
13
+
14
+ Contextualize_Eval::~Contextualize_Eval() { }
15
+
16
+ Selector* Contextualize_Eval::fallback_impl(AST_Node* n)
17
+ {
18
+ return Contextualize::fallback_impl(n);
19
+ }
20
+
21
+ Contextualize_Eval* Contextualize_Eval::with(Selector* s, Env* e, Backtrace* bt, Selector* p, Selector* ex)
22
+ {
23
+ Contextualize::with(s, e, bt, p, ex);
24
+ eval = eval->with(s, e, bt, p, ex);
25
+ return this;
26
+ }
27
+
28
+ Selector* Contextualize_Eval::operator()(Selector_Schema* s)
29
+ {
30
+ To_String to_string;
31
+ string result_str(s->contents()->perform(eval)->perform(&to_string));
32
+ result_str += '{'; // the parser looks for a brace to end the selector
33
+ Selector* result_sel = Parser::from_c_str(result_str.c_str(), ctx, s->pstate()).parse_selector_group();
34
+ return result_sel->perform(this);
35
+ }
36
+
37
+ Selector* Contextualize_Eval::operator()(Selector_List* s)
38
+ {
39
+ return Contextualize::operator ()(s);
40
+ }
41
+
42
+ Selector* Contextualize_Eval::operator()(Complex_Selector* s)
43
+ {
44
+ return Contextualize::operator ()(s);
45
+ }
46
+
47
+ Selector* Contextualize_Eval::operator()(Compound_Selector* s)
48
+ {
49
+ return Contextualize::operator ()(s);
50
+ }
51
+
52
+ Selector* Contextualize_Eval::operator()(Wrapped_Selector* s)
53
+ {
54
+ return Contextualize::operator ()(s);
55
+ }
56
+
57
+ Selector* Contextualize_Eval::operator()(Pseudo_Selector* s)
58
+ {
59
+ return Contextualize::operator ()(s);
60
+ }
61
+
62
+ Selector* Contextualize_Eval::operator()(Attribute_Selector* s)
63
+ {
64
+ // the value might be interpolated; evaluate it
65
+ String* v = s->value();
66
+ if (v && eval) {
67
+ Eval* eval_with = eval->with(env, backtrace);
68
+ v = static_cast<String*>(v->perform(eval_with));
69
+ }
70
+ To_String toString;
71
+ Attribute_Selector* ss = new (ctx.mem) Attribute_Selector(*s);
72
+ ss->value(v);
73
+ return ss;
74
+ }
75
+
76
+ Selector* Contextualize_Eval::operator()(Selector_Qualifier* s)
77
+ { return Contextualize::operator ()(s);
78
+ }
79
+
80
+ Selector* Contextualize_Eval::operator()(Type_Selector* s)
81
+ { return Contextualize::operator ()(s);
82
+ }
83
+
84
+ Selector* Contextualize_Eval::operator()(Selector_Placeholder* p)
85
+ {
86
+ return Contextualize::operator ()(p);
87
+ }
88
+
89
+ Selector* Contextualize_Eval::operator()(Selector_Reference* s)
90
+ {
91
+ return Contextualize::operator ()(s);
92
+ }
93
+ }
@@ -0,0 +1,44 @@
1
+ #ifndef SASS_CONTEXTUALIZE_EVAL_H
2
+ #define SASS_CONTEXTUALIZE_EVAL_H
3
+
4
+ #include "eval.hpp"
5
+ #include "context.hpp"
6
+ #include "operation.hpp"
7
+ #include "environment.hpp"
8
+ #include "ast_fwd_decl.hpp"
9
+
10
+ namespace Sass {
11
+ struct Backtrace;
12
+
13
+ typedef Environment<AST_Node*> Env;
14
+
15
+ class Contextualize_Eval : public Contextualize {
16
+
17
+ Eval* eval;
18
+
19
+ Selector* fallback_impl(AST_Node* n);
20
+
21
+ public:
22
+ Contextualize_Eval(Context&, Eval*, Env*, Backtrace*);
23
+ virtual ~Contextualize_Eval();
24
+ Contextualize_Eval* with(Selector*, Env*, Backtrace*, Selector* placeholder = 0, Selector* extender = 0);
25
+ using Operation<Selector*>::operator();
26
+
27
+ Selector* operator()(Selector_Schema*);
28
+ Selector* operator()(Selector_List*);
29
+ Selector* operator()(Complex_Selector*);
30
+ Selector* operator()(Compound_Selector*);
31
+ Selector* operator()(Wrapped_Selector*);
32
+ Selector* operator()(Pseudo_Selector*);
33
+ Selector* operator()(Attribute_Selector*);
34
+ Selector* operator()(Selector_Qualifier*);
35
+ Selector* operator()(Type_Selector*);
36
+ Selector* operator()(Selector_Placeholder*);
37
+ Selector* operator()(Selector_Reference*);
38
+
39
+ template <typename U>
40
+ Selector* fallback(U x) { return fallback_impl(x); }
41
+ };
42
+ }
43
+
44
+ #endif
@@ -0,0 +1,57 @@
1
+ #include <cstring>
2
+ #include <iostream>
3
+ #include <stdint.h>
4
+ #include "sass_values.h"
5
+
6
+ // gcc: g++ -shared plugin.cpp -o plugin.so -fPIC -Llib -lsass
7
+ // mingw: g++ -shared plugin.cpp -o plugin.dll -Llib -lsass
8
+
9
+ extern "C" const char* ADDCALL libsass_get_version() {
10
+ return libsass_version();
11
+ }
12
+
13
+ union Sass_Value* custom_function(const union Sass_Value* s_args, Sass_Function_Entry cb, struct Sass_Options* opts)
14
+ {
15
+ // get the cookie from function descriptor
16
+ void* cookie = sass_function_get_cookie(cb);
17
+ // we actually abuse the void* to store an "int"
18
+ return sass_make_number((intptr_t)cookie, "px");
19
+ }
20
+
21
+ extern "C" Sass_Function_List ADDCALL libsass_load_functions()
22
+ {
23
+ // allocate a custom function caller
24
+ Sass_Function_Entry c_func =
25
+ sass_make_function("foo()", custom_function, (void*)42);
26
+ // create list of all custom functions
27
+ Sass_Function_List fn_list = sass_make_function_list(1);
28
+ // put the only function in this plugin to the list
29
+ sass_function_set_list_entry(fn_list, 0, c_func);
30
+ // return the list
31
+ return fn_list;
32
+ }
33
+
34
+ Sass_Import_List custom_importer(const char* cur_path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
35
+ {
36
+ // get the cookie from importer descriptor
37
+ void* cookie = sass_importer_get_cookie(cb);
38
+ // create a list to hold our import entries
39
+ Sass_Import_List incs = sass_make_import_list(1);
40
+ // create our only import entry (route path back)
41
+ incs[0] = sass_make_import_entry(cur_path, 0, 0);
42
+ // return imports
43
+ return incs;
44
+ }
45
+
46
+ extern "C" Sass_Importer_List ADDCALL libsass_load_importers()
47
+ {
48
+ // allocate a custom function caller
49
+ Sass_Importer_Entry c_imp =
50
+ sass_make_importer(custom_importer, - 99, (void*)42);
51
+ // create list of all custom functions
52
+ Sass_Importer_List imp_list = sass_make_importer_list(1);
53
+ // put the only function in this plugin to the list
54
+ sass_importer_set_list_entry(imp_list, 0, c_imp);
55
+ // return the list
56
+ return imp_list;
57
+ }
@@ -87,7 +87,7 @@ namespace Sass {
87
87
 
88
88
  Keyframe_Rule* rr = new (ctx.mem) Keyframe_Rule(r->pstate(),
89
89
  r->block()->perform(this)->block());
90
- if (r->rules()) rr->rules(r->rules());
90
+ if (r->selector()) rr->selector(r->selector());
91
91
 
92
92
  return debubble(rr->block(), rr)->block();
93
93
  }
@@ -268,6 +268,8 @@ namespace Sass {
268
268
  m->feature_queries(),
269
269
  wrapper_block);
270
270
 
271
+ mm->tabs(m->tabs());
272
+
271
273
  Bubble* bubble = new (ctx.mem) Bubble(mm->pstate(), mm);
272
274
  return bubble;
273
275
  }
@@ -2,6 +2,7 @@
2
2
  #define SASS_DEBUGGER_H
3
3
 
4
4
  #include <string>
5
+ #include <sstream>
5
6
  #include "ast_fwd_decl.hpp"
6
7
 
7
8
  using namespace std;
@@ -25,28 +26,51 @@ inline string prettyprint(const string& str) {
25
26
  return clean;
26
27
  }
27
28
 
28
- inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
29
+ inline string longToHex(long long t) {
30
+ std::stringstream is;
31
+ is << std::hex << t;
32
+ return is.str();
33
+ }
34
+
35
+ inline string pstate_source_position(AST_Node* node)
29
36
  {
37
+ stringstream str;
38
+ Position start(node->pstate());
39
+ Position end(start + node->pstate().offset);
40
+ str << (start.file == string::npos ? -1 : start.file)
41
+ << "@[" << start.line << ":" << start.column << "]"
42
+ << "-[" << end.line << ":" << end.column << "]";
43
+ return str.str();
44
+ }
30
45
 
46
+ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
47
+ {
48
+ if (node == 0) return;
31
49
  if (ind == "") cerr << "####################################################################\n";
32
50
  if (dynamic_cast<Bubble*>(node)) {
33
51
  Bubble* bubble = dynamic_cast<Bubble*>(node);
34
- cerr << ind << "Bubble " << bubble << " " << bubble->tabs() << endl;
52
+ cerr << ind << "Bubble " << bubble;
53
+ cerr << " (" << pstate_source_position(node) << ")";
54
+ cerr << " " << bubble->tabs();
55
+ cerr << endl;
35
56
  } else if (dynamic_cast<At_Root_Block*>(node)) {
36
57
  At_Root_Block* root_block = dynamic_cast<At_Root_Block*>(node);
37
- cerr << ind << "At_Root_Block " << root_block << " " << root_block->tabs() << endl;
58
+ cerr << ind << "At_Root_Block " << root_block;
59
+ cerr << " (" << pstate_source_position(node) << ")";
60
+ cerr << " " << root_block->tabs();
61
+ cerr << endl;
38
62
  if (root_block->block()) for(auto i : root_block->block()->elements()) { debug_ast(i, ind + " ", env); }
39
63
  } else if (dynamic_cast<Selector_List*>(node)) {
40
64
  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;
65
+ cerr << ind << "Selector_List " << selector;
66
+ cerr << " (" << pstate_source_position(node) << ")";
67
+ cerr << " [block:" << selector->last_block() << "]";
68
+ cerr << (selector->last_block() && selector->last_block()->is_root() ? " [root]" : "");
69
+ cerr << " [@media:" << selector->media_block() << "]";
70
+ cerr << (selector->is_optional() ? " [is_optional]": " -");
71
+ cerr << (selector->has_line_break() ? " [line-break]": " -");
72
+ cerr << (selector->has_line_feed() ? " [line-feed]": " -");
73
+ cerr << endl;
50
74
 
51
75
  for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); }
52
76
 
@@ -54,10 +78,19 @@ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
54
78
  // Expression* expression = dynamic_cast<Expression*>(node);
55
79
  // cerr << ind << "Expression " << expression << " " << expression->concrete_type() << endl;
56
80
 
81
+ } else if (dynamic_cast<Parent_Selector*>(node)) {
82
+ Parent_Selector* selector = dynamic_cast<Parent_Selector*>(node);
83
+ cerr << ind << "Parent_Selector " << selector;
84
+ cerr << " (" << pstate_source_position(node) << ")";
85
+ cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << endl;
86
+ debug_ast(selector->selector(), ind + "->", env);
87
+
57
88
  } else if (dynamic_cast<Complex_Selector*>(node)) {
58
89
  Complex_Selector* selector = dynamic_cast<Complex_Selector*>(node);
59
90
  cerr << ind << "Complex_Selector " << selector
91
+ << " (" << pstate_source_position(node) << ")"
60
92
  << " [block:" << selector->last_block() << "]"
93
+ << " [weight:" << longToHex(selector->specificity()) << "]"
61
94
  << (selector->last_block() && selector->last_block()->is_root() ? " [root]" : "")
62
95
  << " [@media:" << selector->media_block() << "]"
63
96
  << (selector->is_optional() ? " [is_optional]": " -")
@@ -69,43 +102,57 @@ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
69
102
  case Complex_Selector::ADJACENT_TO: cerr << "{+}"; break;
70
103
  case Complex_Selector::ANCESTOR_OF: cerr << "{ }"; break;
71
104
  }
72
- cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << "> X <" << prettyprint(selector->pstate().token.ws_after()) << ">" << endl;
105
+ cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << endl;
73
106
  debug_ast(selector->head(), ind + " ", env);
74
107
  debug_ast(selector->tail(), ind + "-", env);
75
108
  } else if (dynamic_cast<Compound_Selector*>(node)) {
76
109
  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;
110
+ cerr << ind << "Compound_Selector " << selector;
111
+ cerr << " (" << pstate_source_position(node) << ")";
112
+ cerr << " [block:" << selector->last_block() << "]";
113
+ cerr << " [weight:" << longToHex(selector->specificity()) << "]";
114
+ // cerr << (selector->last_block() && selector->last_block()->is_root() ? " [root]" : "");
115
+ cerr << " [@media:" << selector->media_block() << "]";
116
+ cerr << (selector->is_optional() ? " [is_optional]": " -");
117
+ cerr << (selector->has_line_break() ? " [line-break]": " -");
118
+ cerr << (selector->has_line_feed() ? " [line-feed]": " -");
119
+ cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << endl;
85
120
  for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); }
86
121
  } else if (dynamic_cast<Propset*>(node)) {
87
122
  Propset* selector = dynamic_cast<Propset*>(node);
88
- cerr << ind << "Propset " << selector << " " << selector->tabs() << endl;
123
+ cerr << ind << "Propset " << selector;
124
+ cerr << " (" << pstate_source_position(node) << ")";
125
+ cerr << " " << selector->tabs() << endl;
89
126
  if (selector->block()) for(auto i : selector->block()->elements()) { debug_ast(i, ind + " ", env); }
90
127
  } else if (dynamic_cast<Wrapped_Selector*>(node)) {
91
128
  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;
129
+ cerr << ind << "Wrapped_Selector " << selector;
130
+ cerr << " (" << pstate_source_position(node) << ")";
131
+ cerr << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl;
93
132
  debug_ast(selector->selector(), ind + " () ", env);
94
133
  } else if (dynamic_cast<Pseudo_Selector*>(node)) {
95
134
  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;
135
+ cerr << ind << "Pseudo_Selector " << selector;
136
+ cerr << " (" << pstate_source_position(node) << ")";
137
+ cerr << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl;
97
138
  debug_ast(selector->expression(), ind + " <= ", env);
98
139
  } else if (dynamic_cast<Attribute_Selector*>(node)) {
99
140
  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;
141
+ cerr << ind << "Attribute_Selector " << selector;
142
+ cerr << " (" << pstate_source_position(node) << ")";
143
+ cerr << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl;
101
144
  debug_ast(selector->value(), ind + "[" + selector->matcher() + "] ", env);
102
145
  } else if (dynamic_cast<Selector_Qualifier*>(node)) {
103
146
  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;
147
+ cerr << ind << "Selector_Qualifier " << selector;
148
+ cerr << " (" << pstate_source_position(node) << ")";
149
+ cerr << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl;
105
150
  } else if (dynamic_cast<Type_Selector*>(node)) {
106
151
  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;
152
+ cerr << ind << "Type_Selector " << selector;
153
+ cerr << " (" << pstate_source_position(node) << ")";
154
+ cerr << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") <<
155
+ " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << endl;
109
156
  } else if (dynamic_cast<Selector_Placeholder*>(node)) {
110
157
 
111
158
  Selector_Placeholder* selector = dynamic_cast<Selector_Placeholder*>(node);
@@ -119,15 +166,20 @@ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
119
166
 
120
167
  } else if (dynamic_cast<Selector_Reference*>(node)) {
121
168
  Selector_Reference* selector = dynamic_cast<Selector_Reference*>(node);
122
- cerr << ind << "Selector_Reference " << selector << " @ref " << selector->selector() << endl;
169
+ cerr << ind << "Selector_Reference " << selector;
170
+ cerr << " (" << pstate_source_position(node) << ")";
171
+ cerr << " @ref " << selector->selector() << endl;
123
172
  } else if (dynamic_cast<Simple_Selector*>(node)) {
124
173
  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;
174
+ cerr << ind << "Simple_Selector " << selector;
175
+ cerr << " (" << pstate_source_position(node) << ")";
176
+ cerr << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl;
126
177
 
127
178
  } else if (dynamic_cast<Selector_Schema*>(node)) {
128
179
  Selector_Schema* selector = dynamic_cast<Selector_Schema*>(node);
129
- cerr << ind << "Selector_Schema " << selector
130
- << " [block:" << selector->last_block() << "]"
180
+ cerr << ind << "Selector_Schema " << selector;
181
+ cerr << " (" << pstate_source_position(node) << ")";
182
+ cerr << " [block:" << selector->last_block() << "]"
131
183
  << (selector->last_block() && selector->last_block()->is_root() ? " [root]" : "")
132
184
  << " [@media:" << selector->media_block() << "]"
133
185
  << (selector->has_line_break() ? " [line-break]": " -")
@@ -139,23 +191,26 @@ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
139
191
 
140
192
  } else if (dynamic_cast<Selector*>(node)) {
141
193
  Selector* selector = dynamic_cast<Selector*>(node);
142
- cerr << ind << "Selector " << selector
143
- << (selector->has_line_break() ? " [line-break]": " -")
194
+ cerr << ind << "Selector " << selector;
195
+ cerr << " (" << pstate_source_position(node) << ")";
196
+ cerr << (selector->has_line_break() ? " [line-break]": " -")
144
197
  << (selector->has_line_feed() ? " [line-feed]": " -")
145
198
  << endl;
146
199
 
147
200
  } else if (dynamic_cast<Media_Query_Expression*>(node)) {
148
201
  Media_Query_Expression* block = dynamic_cast<Media_Query_Expression*>(node);
149
- cerr << ind << "Media_Query_Expression " << block
150
- << (block->is_interpolated() ? " [is_interpolated]": " -")
202
+ cerr << ind << "Media_Query_Expression " << block;
203
+ cerr << " (" << pstate_source_position(node) << ")";
204
+ cerr << (block->is_interpolated() ? " [is_interpolated]": " -")
151
205
  << endl;
152
206
  debug_ast(block->feature(), ind + " f) ");
153
207
  debug_ast(block->value(), ind + " v) ");
154
208
 
155
209
  } else if (dynamic_cast<Media_Query*>(node)) {
156
210
  Media_Query* block = dynamic_cast<Media_Query*>(node);
157
- cerr << ind << "Media_Query " << block
158
- << (block->is_negated() ? " [is_negated]": " -")
211
+ cerr << ind << "Media_Query " << block;
212
+ cerr << " (" << pstate_source_position(node) << ")";
213
+ cerr << (block->is_negated() ? " [is_negated]": " -")
159
214
  << (block->is_restricted() ? " [is_restricted]": " -")
160
215
  << endl;
161
216
  debug_ast(block->media_type(), ind + " ");
@@ -163,83 +218,131 @@ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
163
218
 
164
219
  } else if (dynamic_cast<Media_Block*>(node)) {
165
220
  Media_Block* block = dynamic_cast<Media_Block*>(node);
166
- cerr << ind << "Media_Block " << block << " " << block->tabs() << endl;
221
+ cerr << ind << "Media_Block " << block;
222
+ cerr << " (" << pstate_source_position(node) << ")";
223
+ cerr << " " << block->tabs() << endl;
167
224
  debug_ast(block->media_queries(), ind + " =@ ");
168
225
  debug_ast(block->selector(), ind + " -@ ");
169
226
  if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
170
227
  } else if (dynamic_cast<Feature_Block*>(node)) {
171
228
  Feature_Block* block = dynamic_cast<Feature_Block*>(node);
172
- cerr << ind << "Feature_Block " << block << " " << block->tabs() << endl;
229
+ cerr << ind << "Feature_Block " << block;
230
+ cerr << " (" << pstate_source_position(node) << ")";
231
+ cerr << " " << block->tabs() << endl;
173
232
  if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
174
233
  } else if (dynamic_cast<Block*>(node)) {
175
234
  Block* root_block = dynamic_cast<Block*>(node);
176
- cerr << ind << "Block " << root_block << " " << root_block->tabs() << endl;
235
+ cerr << ind << "Block " << root_block;
236
+ cerr << " (" << pstate_source_position(node) << ")";
237
+ if (root_block->is_root()) cerr << " [root]";
238
+ cerr << " " << root_block->tabs() << endl;
177
239
  if (root_block->block()) for(auto i : root_block->block()->elements()) { debug_ast(i, ind + " ", env); }
178
240
  } else if (dynamic_cast<Warning*>(node)) {
179
241
  Warning* block = dynamic_cast<Warning*>(node);
180
- cerr << ind << "Warning " << block << " " << block->tabs() << endl;
242
+ cerr << ind << "Warning " << block;
243
+ cerr << " (" << pstate_source_position(node) << ")";
244
+ cerr << " " << block->tabs() << endl;
181
245
  } else if (dynamic_cast<Error*>(node)) {
182
246
  Error* block = dynamic_cast<Error*>(node);
183
- cerr << ind << "Error " << block << " " << block->tabs() << endl;
247
+ cerr << ind << "Error " << block;
248
+ cerr << " (" << pstate_source_position(node) << ")";
249
+ cerr << " " << block->tabs() << endl;
184
250
  } else if (dynamic_cast<Debug*>(node)) {
185
251
  Debug* block = dynamic_cast<Debug*>(node);
186
- cerr << ind << "Debug " << block << " " << block->tabs() << endl;
252
+ cerr << ind << "Debug " << block;
253
+ cerr << " (" << pstate_source_position(node) << ")";
254
+ cerr << " " << block->tabs() << endl;
187
255
  } else if (dynamic_cast<Comment*>(node)) {
188
256
  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;
257
+ cerr << ind << "Comment " << block;
258
+ cerr << " (" << pstate_source_position(node) << ")";
259
+ cerr << " " << block->tabs() <<
260
+ " <" << prettyprint(block->pstate().token.ws_before()) << ">" << endl;
191
261
  debug_ast(block->text(), ind + "// ", env);
192
262
  } else if (dynamic_cast<If*>(node)) {
193
263
  If* block = dynamic_cast<If*>(node);
194
- cerr << ind << "If " << block << " " << block->tabs() << endl;
264
+ cerr << ind << "If " << block;
265
+ cerr << " (" << pstate_source_position(node) << ")";
266
+ cerr << " " << block->tabs() << endl;
195
267
  } else if (dynamic_cast<Return*>(node)) {
196
268
  Return* block = dynamic_cast<Return*>(node);
197
- cerr << ind << "Return " << block << " " << block->tabs() << endl;
269
+ cerr << ind << "Return " << block;
270
+ cerr << " (" << pstate_source_position(node) << ")";
271
+ cerr << " " << block->tabs() << endl;
198
272
  } else if (dynamic_cast<Extension*>(node)) {
199
273
  Extension* block = dynamic_cast<Extension*>(node);
200
- cerr << ind << "Extension " << block << " " << block->tabs() << endl;
274
+ cerr << ind << "Extension " << block;
275
+ cerr << " (" << pstate_source_position(node) << ")";
276
+ cerr << " " << block->tabs() << endl;
201
277
  debug_ast(block->selector(), ind + "-> ", env);
202
278
  } else if (dynamic_cast<Content*>(node)) {
203
279
  Content* block = dynamic_cast<Content*>(node);
204
- cerr << ind << "Content " << block << " " << block->tabs() << endl;
280
+ cerr << ind << "Content " << block;
281
+ cerr << " (" << pstate_source_position(node) << ")";
282
+ cerr << " " << block->tabs() << endl;
205
283
  } else if (dynamic_cast<Import_Stub*>(node)) {
206
284
  Import_Stub* block = dynamic_cast<Import_Stub*>(node);
207
- cerr << ind << "Import_Stub " << block << " " << block->tabs() << endl;
285
+ cerr << ind << "Import_Stub " << block;
286
+ cerr << " (" << pstate_source_position(node) << ")";
287
+ cerr << " " << block->tabs() << endl;
208
288
  } else if (dynamic_cast<Import*>(node)) {
209
289
  Import* block = dynamic_cast<Import*>(node);
210
- cerr << ind << "Import " << block << " " << block->tabs() << endl;
290
+ cerr << ind << "Import " << block;
291
+ cerr << " (" << pstate_source_position(node) << ")";
292
+ cerr << " " << block->tabs() << endl;
211
293
  // vector<string> files_;
212
294
  for (auto imp : block->urls()) debug_ast(imp, "@ ", env);
213
295
  } else if (dynamic_cast<Assignment*>(node)) {
214
296
  Assignment* block = dynamic_cast<Assignment*>(node);
215
- cerr << ind << "Assignment " << block << " <<" << block->variable() << ">> " << block->tabs() << endl;
297
+ cerr << ind << "Assignment " << block;
298
+ cerr << " (" << pstate_source_position(node) << ")";
299
+ cerr << " <<" << block->variable() << ">> " << block->tabs() << endl;
216
300
  debug_ast(block->value(), ind + "=", env);
217
301
  } else if (dynamic_cast<Declaration*>(node)) {
218
302
  Declaration* block = dynamic_cast<Declaration*>(node);
219
- cerr << ind << "Declaration " << block << " " << block->tabs() << endl;
303
+ cerr << ind << "Declaration " << block;
304
+ cerr << " (" << pstate_source_position(node) << ")";
305
+ cerr << " " << block->tabs() << endl;
220
306
  debug_ast(block->property(), ind + " prop: ", env);
221
307
  debug_ast(block->value(), ind + " value: ", env);
308
+ } else if (dynamic_cast<Keyframe_Rule*>(node)) {
309
+ Keyframe_Rule* has_block = dynamic_cast<Keyframe_Rule*>(node);
310
+ cerr << ind << "Keyframe_Rule " << has_block;
311
+ cerr << " (" << pstate_source_position(node) << ")";
312
+ cerr << " " << has_block->tabs() << endl;
313
+ if (has_block->selector()) debug_ast(has_block->selector(), ind + "@");
314
+ if (has_block->block()) for(auto i : has_block->block()->elements()) { debug_ast(i, ind + " ", env); }
222
315
  } else if (dynamic_cast<At_Rule*>(node)) {
223
316
  At_Rule* block = dynamic_cast<At_Rule*>(node);
224
- cerr << ind << "At_Rule " << block << " [" << block->keyword() << "] " << block->tabs() << endl;
317
+ cerr << ind << "At_Rule " << block;
318
+ cerr << " (" << pstate_source_position(node) << ")";
319
+ cerr << " [" << block->keyword() << "] " << block->tabs() << endl;
225
320
  debug_ast(block->value(), ind + "+", env);
226
321
  debug_ast(block->selector(), ind + "~", env);
227
322
  if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
228
323
  } else if (dynamic_cast<Each*>(node)) {
229
324
  Each* block = dynamic_cast<Each*>(node);
230
- cerr << ind << "Each " << block << " " << block->tabs() << endl;
325
+ cerr << ind << "Each " << block;
326
+ cerr << " (" << pstate_source_position(node) << ")";
327
+ cerr << " " << block->tabs() << endl;
231
328
  if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
232
329
  } else if (dynamic_cast<For*>(node)) {
233
330
  For* block = dynamic_cast<For*>(node);
234
- cerr << ind << "For " << block << " " << block->tabs() << endl;
331
+ cerr << ind << "For " << block;
332
+ cerr << " (" << pstate_source_position(node) << ")";
333
+ cerr << " " << block->tabs() << endl;
235
334
  if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
236
335
  } else if (dynamic_cast<While*>(node)) {
237
336
  While* block = dynamic_cast<While*>(node);
238
- cerr << ind << "While " << block << " " << block->tabs() << endl;
337
+ cerr << ind << "While " << block;
338
+ cerr << " (" << pstate_source_position(node) << ")";
339
+ cerr << " " << block->tabs() << endl;
239
340
  if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
240
341
  } else if (dynamic_cast<Definition*>(node)) {
241
342
  Definition* block = dynamic_cast<Definition*>(node);
242
- cerr << ind << "Definition " << block << " " << block->tabs() << endl;
343
+ cerr << ind << "Definition " << block;
344
+ cerr << " (" << pstate_source_position(node) << ")";
345
+ cerr << " " << block->tabs() << endl;
243
346
  if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
244
347
  } else if (dynamic_cast<Mixin_Call*>(node)) {
245
348
  Mixin_Call* block = dynamic_cast<Mixin_Call*>(node);
@@ -247,12 +350,16 @@ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
247
350
  if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); }
248
351
  } else if (dynamic_cast<Ruleset*>(node)) {
249
352
  Ruleset* ruleset = dynamic_cast<Ruleset*>(node);
250
- cerr << ind << "Ruleset " << ruleset << " " << ruleset->tabs() << endl;
353
+ cerr << ind << "Ruleset " << ruleset;
354
+ cerr << " (" << pstate_source_position(node) << ")";
355
+ cerr << " " << ruleset->tabs() << endl;
251
356
  debug_ast(ruleset->selector(), ind + " ");
252
357
  if (ruleset->block()) for(auto i : ruleset->block()->elements()) { debug_ast(i, ind + " ", env); }
253
358
  } else if (dynamic_cast<Block*>(node)) {
254
359
  Block* block = dynamic_cast<Block*>(node);
255
- cerr << ind << "Block " << block << " " << block->tabs() << endl;
360
+ cerr << ind << "Block " << block;
361
+ cerr << " (" << pstate_source_position(node) << ")";
362
+ cerr << " " << block->tabs() << endl;
256
363
  for(auto i : block->elements()) { debug_ast(i, ind + " ", env); }
257
364
  } else if (dynamic_cast<Textual*>(node)) {
258
365
  Textual* expression = dynamic_cast<Textual*>(node);
@@ -264,41 +371,59 @@ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
264
371
  cerr << expression << " [" << expression->value() << "]" << endl;
265
372
  } else if (dynamic_cast<Variable*>(node)) {
266
373
  Variable* expression = dynamic_cast<Variable*>(node);
267
- cerr << ind << "Variable " << expression << " [" << expression->name() << "]" << endl;
374
+ cerr << ind << "Variable " << expression;
375
+ cerr << " (" << pstate_source_position(node) << ")";
376
+ cerr << " [" << expression->name() << "]" << endl;
268
377
  string name(expression->name());
269
378
  if (env && env->has(name)) debug_ast(static_cast<Expression*>((*env)[name]), ind + " -> ", env);
270
379
  } else if (dynamic_cast<Function_Call_Schema*>(node)) {
271
380
  Function_Call_Schema* expression = dynamic_cast<Function_Call_Schema*>(node);
272
- cerr << ind << "Function_Call_Schema " << expression << "]" << endl;
381
+ cerr << ind << "Function_Call_Schema " << expression;
382
+ cerr << " (" << pstate_source_position(node) << ")";
383
+ cerr << "" << endl;
273
384
  debug_ast(expression->name(), ind + "name: ", env);
274
385
  debug_ast(expression->arguments(), ind + " args: ", env);
275
386
  } else if (dynamic_cast<Function_Call*>(node)) {
276
387
  Function_Call* expression = dynamic_cast<Function_Call*>(node);
277
- cerr << ind << "Function_Call " << expression << " [" << expression->name() << "]" << endl;
388
+ cerr << ind << "Function_Call " << expression;
389
+ cerr << " (" << pstate_source_position(node) << ")";
390
+ cerr << " [" << expression->name() << "]" << endl;
278
391
  debug_ast(expression->arguments(), ind + " args: ", env);
279
392
  } else if (dynamic_cast<Arguments*>(node)) {
280
393
  Arguments* expression = dynamic_cast<Arguments*>(node);
281
- cerr << ind << "Arguments " << expression << "]" << endl;
394
+ cerr << ind << "Arguments " << expression;
395
+ cerr << " (" << pstate_source_position(node) << ")";
396
+ cerr << endl;
282
397
  for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); }
283
398
  } else if (dynamic_cast<Argument*>(node)) {
284
399
  Argument* expression = dynamic_cast<Argument*>(node);
285
- cerr << ind << "Argument " << expression << " [" << expression->value() << "]" << endl;
400
+ cerr << ind << "Argument " << expression;
401
+ cerr << " (" << pstate_source_position(node) << ")";
402
+ cerr << " [" << expression->value() << "]" << endl;
286
403
  debug_ast(expression->value(), ind + " value: ", env);
287
404
  } else if (dynamic_cast<Unary_Expression*>(node)) {
288
405
  Unary_Expression* expression = dynamic_cast<Unary_Expression*>(node);
289
- cerr << ind << "Unary_Expression " << expression << " [" << expression->type() << "]" << endl;
406
+ cerr << ind << "Unary_Expression " << expression;
407
+ cerr << " (" << pstate_source_position(node) << ")";
408
+ cerr << " [" << expression->type() << "]" << endl;
290
409
  debug_ast(expression->operand(), ind + " operand: ", env);
291
410
  } else if (dynamic_cast<Binary_Expression*>(node)) {
292
411
  Binary_Expression* expression = dynamic_cast<Binary_Expression*>(node);
293
- cerr << ind << "Binary_Expression " << expression << " [" << expression->type() << "]" << endl;
412
+ cerr << ind << "Binary_Expression " << expression;
413
+ cerr << " (" << pstate_source_position(node) << ")";
414
+ cerr << " [" << expression->type() << "]" << endl;
294
415
  debug_ast(expression->left(), ind + " left: ", env);
295
416
  debug_ast(expression->right(), ind + " right: ", env);
296
417
  } else if (dynamic_cast<Map*>(node)) {
297
418
  Map* expression = dynamic_cast<Map*>(node);
298
- cerr << ind << "Map " << expression << " [Hashed]" << endl;
419
+ cerr << ind << "Map " << expression;
420
+ cerr << " (" << pstate_source_position(node) << ")";
421
+ cerr << " [Hashed]" << endl;
299
422
  } else if (dynamic_cast<List*>(node)) {
300
423
  List* expression = dynamic_cast<List*>(node);
301
- cerr << ind << "List " << expression <<
424
+ cerr << ind << "List " << expression;
425
+ cerr << " (" << pstate_source_position(node) << ")";
426
+ cerr << " (" << expression->length() << ") " <<
302
427
  (expression->separator() == Sass::List::Separator::COMMA ? "Comma " : "Space ") <<
303
428
  " [delayed: " << expression->is_delayed() << "] " <<
304
429
  " [interpolant: " << expression->is_interpolant() << "] " <<
@@ -306,50 +431,84 @@ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
306
431
  for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); }
307
432
  } else if (dynamic_cast<Content*>(node)) {
308
433
  Content* expression = dynamic_cast<Content*>(node);
309
- cerr << ind << "Content " << expression << " [Statement]" << endl;
434
+ cerr << ind << "Content " << expression;
435
+ cerr << " (" << pstate_source_position(node) << ")";
436
+ cerr << " [Statement]" << endl;
310
437
  } else if (dynamic_cast<Boolean*>(node)) {
311
438
  Boolean* expression = dynamic_cast<Boolean*>(node);
312
- cerr << ind << "Boolean " << expression << " [" << expression->value() << "]" << endl;
439
+ cerr << ind << "Boolean " << expression;
440
+ cerr << " (" << pstate_source_position(node) << ")";
441
+ cerr << " [" << expression->value() << "]" << endl;
313
442
  } else if (dynamic_cast<Color*>(node)) {
314
443
  Color* expression = dynamic_cast<Color*>(node);
315
- cerr << ind << "Color " << expression << " [" << expression->r() << ":" << expression->g() << ":" << expression->b() << "@" << expression->a() << "]" << endl;
444
+ cerr << ind << "Color " << expression;
445
+ cerr << " (" << pstate_source_position(node) << ")";
446
+ cerr << " [" << expression->r() << ":" << expression->g() << ":" << expression->b() << "@" << expression->a() << "]" << endl;
316
447
  } else if (dynamic_cast<Number*>(node)) {
317
448
  Number* expression = dynamic_cast<Number*>(node);
318
- cerr << ind << "Number " << expression << " [" << expression->value() << expression->unit() << "]" << endl;
449
+ cerr << ind << "Number " << expression;
450
+ cerr << " (" << pstate_source_position(node) << ")";
451
+ cerr << " [" << expression->value() << expression->unit() << "]" << endl;
319
452
  } else if (dynamic_cast<String_Quoted*>(node)) {
320
453
  String_Quoted* expression = dynamic_cast<String_Quoted*>(node);
321
- cerr << ind << "String_Quoted : " << expression << " [" << prettyprint(expression->value()) << "]" <<
454
+ cerr << ind << "String_Quoted : " << expression;
455
+ cerr << " (" << pstate_source_position(node) << ")";
456
+ cerr << " [" << prettyprint(expression->value()) << "]" <<
322
457
  (expression->is_delayed() ? " {delayed}" : "") <<
323
458
  (expression->sass_fix_1291() ? " {sass_fix_1291}" : "") <<
324
459
  (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;
460
+ " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << endl;
326
461
  } else if (dynamic_cast<String_Constant*>(node)) {
327
462
  String_Constant* expression = dynamic_cast<String_Constant*>(node);
328
- cerr << ind << "String_Constant : " << expression << " [" << prettyprint(expression->value()) << "]" <<
463
+ cerr << ind << "String_Constant : " << expression;
464
+ cerr << " (" << pstate_source_position(node) << ")";
465
+ cerr << " [" << prettyprint(expression->value()) << "]" <<
329
466
  (expression->is_delayed() ? " {delayed}" : "") <<
330
467
  (expression->sass_fix_1291() ? " {sass_fix_1291}" : "") <<
331
- " <" << prettyprint(expression->pstate().token.ws_before()) << "> X <" << prettyprint(expression->pstate().token.ws_after()) << ">" << endl;
468
+ " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << endl;
332
469
  } else if (dynamic_cast<String_Schema*>(node)) {
333
470
  String_Schema* expression = dynamic_cast<String_Schema*>(node);
334
- cerr << ind << "String_Schema " << expression << " " << expression->concrete_type() <<
471
+ cerr << ind << "String_Schema " << expression;
472
+ cerr << " (" << pstate_source_position(node) << ")";
473
+ cerr << " " << expression->concrete_type() <<
335
474
  (expression->has_interpolants() ? " {has_interpolants}" : "") <<
336
475
  endl;
337
476
  for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); }
338
477
  } else if (dynamic_cast<String*>(node)) {
339
478
  String* expression = dynamic_cast<String*>(node);
340
- cerr << ind << "String " << expression << expression->concrete_type() <<
479
+ cerr << ind << "String " << expression;
480
+ cerr << " (" << pstate_source_position(node) << ")";
481
+ cerr << expression->concrete_type() <<
341
482
  " " << (expression->sass_fix_1291() ? "{sass_fix_1291}" : "") <<
342
483
  endl;
343
484
  } else if (dynamic_cast<Expression*>(node)) {
344
485
  Expression* expression = dynamic_cast<Expression*>(node);
345
- cerr << ind << "Expression " << expression << " " << expression->concrete_type() << endl;
486
+ cerr << ind << "Expression " << expression;
487
+ cerr << " (" << pstate_source_position(node) << ")";
488
+ switch (expression->concrete_type()) {
489
+ case Expression::Concrete_Type::NONE: cerr << " [NONE]"; break;
490
+ case Expression::Concrete_Type::BOOLEAN: cerr << " [BOOLEAN]"; break;
491
+ case Expression::Concrete_Type::NUMBER: cerr << " [NUMBER]"; break;
492
+ case Expression::Concrete_Type::COLOR: cerr << " [COLOR]"; break;
493
+ case Expression::Concrete_Type::STRING: cerr << " [STRING]"; break;
494
+ case Expression::Concrete_Type::LIST: cerr << " [LIST]"; break;
495
+ case Expression::Concrete_Type::MAP: cerr << " [MAP]"; break;
496
+ case Expression::Concrete_Type::SELECTOR: cerr << " [SELECTOR]"; break;
497
+ case Expression::Concrete_Type::NULL_VAL: cerr << " [NULL_VAL]"; break;
498
+ case Expression::Concrete_Type::NUM_TYPES: cerr << " [NUM_TYPES]"; break;
499
+ }
500
+ cerr << endl;
346
501
  } else if (dynamic_cast<Has_Block*>(node)) {
347
502
  Has_Block* has_block = dynamic_cast<Has_Block*>(node);
348
- cerr << ind << "Has_Block " << has_block << " " << has_block->tabs() << endl;
503
+ cerr << ind << "Has_Block " << has_block;
504
+ cerr << " (" << pstate_source_position(node) << ")";
505
+ cerr << " " << has_block->tabs() << endl;
349
506
  if (has_block->block()) for(auto i : has_block->block()->elements()) { debug_ast(i, ind + " ", env); }
350
507
  } else if (dynamic_cast<Statement*>(node)) {
351
508
  Statement* statement = dynamic_cast<Statement*>(node);
352
- cerr << ind << "Statement " << statement << " " << statement->tabs() << endl;
509
+ cerr << ind << "Statement " << statement;
510
+ cerr << " (" << pstate_source_position(node) << ")";
511
+ cerr << " " << statement->tabs() << endl;
353
512
  }
354
513
 
355
514
  if (ind == "") cerr << "####################################################################\n";