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
@@ -1,11 +1,14 @@
1
- #define SASS_AST
1
+ #ifndef SASS_AST_H
2
+ #define SASS_AST_H
2
3
 
4
+ #include <set>
5
+ #include <deque>
6
+ #include <vector>
3
7
  #include <string>
4
8
  #include <sstream>
5
- #include <vector>
6
- #include <set>
9
+ #include <iostream>
10
+ #include <typeinfo>
7
11
  #include <algorithm>
8
- #include <deque>
9
12
  #include <unordered_map>
10
13
 
11
14
  #ifdef __clang__
@@ -27,61 +30,43 @@
27
30
 
28
31
  #endif
29
32
 
30
- #ifndef SASS_CONSTANTS
33
+ #include "util.hpp"
34
+ #include "units.hpp"
35
+ #include "context.hpp"
36
+ #include "position.hpp"
31
37
  #include "constants.hpp"
32
- #endif
33
-
34
- #ifndef SASS_OPERATION
35
38
  #include "operation.hpp"
36
- #endif
37
-
38
- #ifndef SASS_TOKEN
39
- #include "token.hpp"
40
- #endif
41
-
42
- #ifndef SASS_ENVIRONMENT
39
+ #include "position.hpp"
40
+ #include "inspect.hpp"
41
+ #include "source_map.hpp"
43
42
  #include "environment.hpp"
44
- #endif
43
+ #include "error_handling.hpp"
44
+ #include "ast_def_macros.hpp"
45
+ #include "ast_fwd_decl.hpp"
46
+ #include "to_string.hpp"
47
+ #include "source_map.hpp"
45
48
 
46
49
  #include "sass.h"
47
50
  #include "sass_values.h"
48
51
  #include "sass_functions.h"
49
52
 
50
- #include "units.hpp"
51
-
52
- #ifndef SASS_ERROR_HANDLING
53
- #include "error_handling.hpp"
54
- #endif
55
-
56
- #include "ast_def_macros.hpp"
57
- #include "inspect.hpp"
58
-
59
- #include <sstream>
60
- #include <iostream>
61
- #include <typeinfo>
62
-
63
- #ifndef SASS_POSITION
64
- #include "position.hpp"
65
- #endif
66
-
67
-
68
53
  namespace Sass {
69
54
  using namespace std;
70
55
 
71
56
  //////////////////////////////////////////////////////////
72
57
  // Abstract base class for all abstract syntax tree nodes.
73
58
  //////////////////////////////////////////////////////////
74
- class Block;
75
- class Statement;
76
- class Expression;
77
- class Selector;
78
59
  class AST_Node {
79
- ADD_PROPERTY(string, path);
80
- ADD_PROPERTY(Position, position);
60
+ ADD_PROPERTY(ParserState, pstate);
81
61
  public:
82
- AST_Node(string path, Position position) : path_(path), position_(position) { }
62
+ AST_Node(ParserState pstate)
63
+ : pstate_(pstate)
64
+ { }
83
65
  virtual ~AST_Node() = 0;
84
66
  // virtual Block* block() { return 0; }
67
+ public:
68
+ Offset off() { return pstate(); };
69
+ Position pos() { return pstate(); };
85
70
  ATTACH_OPERATIONS();
86
71
  };
87
72
  inline AST_Node::~AST_Node() { }
@@ -112,10 +97,13 @@ namespace Sass {
112
97
  ADD_PROPERTY(bool, is_interpolant);
113
98
  ADD_PROPERTY(Concrete_Type, concrete_type);
114
99
  public:
115
- Expression(string path, Position position,
100
+ Expression(ParserState pstate,
116
101
  bool d = false, bool e = false, bool i = false, Concrete_Type ct = NONE)
117
- : AST_Node(path, position),
118
- is_delayed_(d), is_expanded_(d), is_interpolant_(i), concrete_type_(ct)
102
+ : AST_Node(pstate),
103
+ is_delayed_(d),
104
+ is_expanded_(d),
105
+ is_interpolant_(i),
106
+ concrete_type_(ct)
119
107
  { }
120
108
  virtual operator bool() { return true; }
121
109
  virtual ~Expression() { };
@@ -173,6 +161,7 @@ namespace Sass {
173
161
  virtual ~Vectorized() = 0;
174
162
  size_t length() const { return elements_.size(); }
175
163
  bool empty() const { return elements_.empty(); }
164
+ T last() { return elements_.back(); }
176
165
  T& operator[](size_t i) { return elements_[i]; }
177
166
  const T& operator[](size_t i) const { return elements_[i]; }
178
167
  Vectorized& operator<<(T element)
@@ -187,6 +176,11 @@ namespace Sass {
187
176
  for (size_t i = 0, L = v->length(); i < L; ++i) *this << (*v)[i];
188
177
  return *this;
189
178
  }
179
+ Vectorized& unshift(T element)
180
+ {
181
+ elements_.insert(elements_.begin(), element);
182
+ return *this;
183
+ }
190
184
  vector<T>& elements() { return elements_; }
191
185
  const vector<T>& elements() const { return elements_; }
192
186
  vector<T>& elements(vector<T>& e) { elements_ = e; return elements_; }
@@ -195,7 +189,7 @@ namespace Sass {
195
189
  inline Vectorized<T>::~Vectorized() { }
196
190
 
197
191
  /////////////////////////////////////////////////////////////////////////////
198
- // Mixin class for AST nodes that should behave like ahash table. Uses an
192
+ // Mixin class for AST nodes that should behave like a hash table. Uses an
199
193
  // extra <vector> internally to maintain insertion order for interation.
200
194
  /////////////////////////////////////////////////////////////////////////////
201
195
  class Hashed {
@@ -258,10 +252,30 @@ namespace Sass {
258
252
  /////////////////////////////////////////////////////////////////////////
259
253
  class Statement : public AST_Node {
260
254
  public:
261
- Statement(string path, Position position) : AST_Node(path, position) { }
255
+ enum Statement_Type {
256
+ NONE,
257
+ RULESET,
258
+ MEDIA,
259
+ DIRECTIVE,
260
+ FEATURE,
261
+ ATROOT,
262
+ BUBBLE,
263
+ KEYFRAMERULE
264
+ };
265
+ private:
266
+ ADD_PROPERTY(Block*, block);
267
+ ADD_PROPERTY(Statement_Type, statement_type);
268
+ ADD_PROPERTY(size_t, tabs);
269
+ ADD_PROPERTY(bool, group_end);
270
+ public:
271
+ Statement(ParserState pstate, Statement_Type st = NONE, size_t t = 0)
272
+ : AST_Node(pstate), statement_type_(st), tabs_(t), group_end_(false)
273
+ { }
262
274
  virtual ~Statement() = 0;
263
275
  // needed for rearranging nested rulesets during CSS emission
264
276
  virtual bool is_hoistable() { return false; }
277
+ virtual bool is_invisible() { return false; }
278
+ virtual bool bubbles() { return false; }
265
279
  virtual Block* block() { return 0; }
266
280
  };
267
281
  inline Statement::~Statement() { }
@@ -281,8 +295,8 @@ namespace Sass {
281
295
  else has_non_hoistable_ = true;
282
296
  };
283
297
  public:
284
- Block(string path, Position position, size_t s = 0, bool r = false)
285
- : Statement(path, position),
298
+ Block(ParserState pstate, size_t s = 0, bool r = false)
299
+ : Statement(pstate),
286
300
  Vectorized<Statement*>(s),
287
301
  is_root_(r), has_hoistable_(false), has_non_hoistable_(false)
288
302
  { }
@@ -296,8 +310,8 @@ namespace Sass {
296
310
  class Has_Block : public Statement {
297
311
  ADD_PROPERTY(Block*, block);
298
312
  public:
299
- Has_Block(string path, Position position, Block* b)
300
- : Statement(path, position), block_(b)
313
+ Has_Block(ParserState pstate, Block* b)
314
+ : Statement(pstate), block_(b)
301
315
  { }
302
316
  virtual ~Has_Block() = 0;
303
317
  };
@@ -307,13 +321,13 @@ namespace Sass {
307
321
  // Rulesets (i.e., sets of styles headed by a selector and containing a block
308
322
  // of style declarations.
309
323
  /////////////////////////////////////////////////////////////////////////////
310
- class Selector;
311
324
  class Ruleset : public Has_Block {
312
325
  ADD_PROPERTY(Selector*, selector);
313
326
  public:
314
- Ruleset(string path, Position position, Selector* s, Block* b)
315
- : Has_Block(path, position, b), selector_(s)
316
- { }
327
+ Ruleset(ParserState pstate, Selector* s, Block* b)
328
+ : Has_Block(pstate, b), selector_(s)
329
+ { statement_type(RULESET); }
330
+ bool is_invisible();
317
331
  // nested rulesets need to be hoisted out of their enclosing blocks
318
332
  bool is_hoistable() { return true; }
319
333
  ATTACH_OPERATIONS();
@@ -322,28 +336,50 @@ namespace Sass {
322
336
  /////////////////////////////////////////////////////////
323
337
  // Nested declaration sets (i.e., namespaced properties).
324
338
  /////////////////////////////////////////////////////////
325
- class String;
326
339
  class Propset : public Has_Block {
327
340
  ADD_PROPERTY(String*, property_fragment);
328
341
  public:
329
- Propset(string path, Position position, String* pf, Block* b = 0)
330
- : Has_Block(path, position, b), property_fragment_(pf)
342
+ Propset(ParserState pstate, String* pf, Block* b = 0)
343
+ : Has_Block(pstate, b), property_fragment_(pf)
331
344
  { }
332
345
  ATTACH_OPERATIONS();
333
346
  };
334
347
 
348
+ /////////////////
349
+ // Bubble.
350
+ /////////////////
351
+ class Bubble : public Statement {
352
+ ADD_PROPERTY(Statement*, node);
353
+ ADD_PROPERTY(bool, group_end);
354
+ public:
355
+ Bubble(ParserState pstate, Statement* n, Statement* g = 0, size_t t = 0)
356
+ : Statement(pstate, Statement::BUBBLE, t), node_(n), group_end_(g == 0)
357
+ { }
358
+ bool bubbles() { return true; }
359
+ ATTACH_OPERATIONS();
360
+ };
361
+
335
362
  /////////////////
336
363
  // Media queries.
337
364
  /////////////////
338
- class List;
339
365
  class Media_Block : public Has_Block {
340
366
  ADD_PROPERTY(List*, media_queries);
341
367
  ADD_PROPERTY(Selector*, selector);
342
368
  public:
343
- Media_Block(string path, Position position, List* mqs, Block* b)
344
- : Has_Block(path, position, b), media_queries_(mqs), selector_(0)
345
- { }
369
+ Media_Block(ParserState pstate, List* mqs, Block* b)
370
+ : Has_Block(pstate, b), media_queries_(mqs), selector_(0)
371
+ { statement_type(MEDIA); }
372
+ Media_Block(ParserState pstate, List* mqs, Block* b, Selector* s)
373
+ : Has_Block(pstate, b), media_queries_(mqs), selector_(s)
374
+ { statement_type(MEDIA); }
375
+ bool bubbles() { return true; }
346
376
  bool is_hoistable() { return true; }
377
+ bool is_invisible() {
378
+ bool is_invisible = true;
379
+ for (size_t i = 0, L = block()->length(); i < L && is_invisible; i++)
380
+ is_invisible &= (*block())[i]->is_invisible();
381
+ return is_invisible;
382
+ }
347
383
  ATTACH_OPERATIONS();
348
384
  };
349
385
 
@@ -354,10 +390,11 @@ namespace Sass {
354
390
  ADD_PROPERTY(Feature_Query*, feature_queries);
355
391
  ADD_PROPERTY(Selector*, selector);
356
392
  public:
357
- Feature_Block(string path, Position position, Feature_Query* fqs, Block* b)
358
- : Has_Block(path, position, b), feature_queries_(fqs), selector_(0)
359
- { }
393
+ Feature_Block(ParserState pstate, Feature_Query* fqs, Block* b)
394
+ : Has_Block(pstate, b), feature_queries_(fqs), selector_(0)
395
+ { statement_type(FEATURE); }
360
396
  bool is_hoistable() { return true; }
397
+ bool bubbles() { return true; }
361
398
  ATTACH_OPERATIONS();
362
399
  };
363
400
 
@@ -370,9 +407,34 @@ namespace Sass {
370
407
  ADD_PROPERTY(Selector*, selector);
371
408
  ADD_PROPERTY(Expression*, value);
372
409
  public:
373
- At_Rule(string path, Position position, string kwd, Selector* sel = 0, Block* b = 0)
374
- : Has_Block(path, position, b), keyword_(kwd), selector_(sel), value_(0) // set value manually if needed
375
- { }
410
+ At_Rule(ParserState pstate, string kwd, Selector* sel = 0, Block* b = 0)
411
+ : Has_Block(pstate, b), keyword_(kwd), selector_(sel), value_(0) // set value manually if needed
412
+ { statement_type(DIRECTIVE); }
413
+ bool bubbles() { return is_keyframes() || is_media(); }
414
+ bool is_media() {
415
+ return keyword_.compare("@-webkit-media") == 0 ||
416
+ keyword_.compare("@-moz-media") == 0 ||
417
+ keyword_.compare("@-o-media") == 0 ||
418
+ keyword_.compare("@media") == 0;
419
+ }
420
+ bool is_keyframes() {
421
+ return keyword_.compare("@-webkit-keyframes") == 0 ||
422
+ keyword_.compare("@-moz-keyframes") == 0 ||
423
+ keyword_.compare("@-o-keyframes") == 0 ||
424
+ keyword_.compare("@keyframes") == 0;
425
+ }
426
+ ATTACH_OPERATIONS();
427
+ };
428
+
429
+ ///////////////////////////////////////////////////////////////////////
430
+ // Keyframe-rules -- the child blocks of "@keyframes" nodes.
431
+ ///////////////////////////////////////////////////////////////////////
432
+ class Keyframe_Rule : public Has_Block {
433
+ ADD_PROPERTY(String*, rules);
434
+ public:
435
+ Keyframe_Rule(ParserState pstate, Block* b)
436
+ : Has_Block(pstate, b), rules_(0)
437
+ { statement_type(KEYFRAMERULE); }
376
438
  ATTACH_OPERATIONS();
377
439
  };
378
440
 
@@ -384,9 +446,9 @@ namespace Sass {
384
446
  ADD_PROPERTY(Expression*, value);
385
447
  ADD_PROPERTY(bool, is_important);
386
448
  public:
387
- Declaration(string path, Position position,
449
+ Declaration(ParserState pstate,
388
450
  String* prop, Expression* val, bool i = false)
389
- : Statement(path, position), property_(prop), value_(val), is_important_(i)
451
+ : Statement(pstate), property_(prop), value_(val), is_important_(i)
390
452
  { }
391
453
  ATTACH_OPERATIONS();
392
454
  };
@@ -394,19 +456,17 @@ namespace Sass {
394
456
  /////////////////////////////////////
395
457
  // Assignments -- variable and value.
396
458
  /////////////////////////////////////
397
- class Variable;
398
- class Expression;
399
459
  class Assignment : public Statement {
400
460
  ADD_PROPERTY(string, variable);
401
461
  ADD_PROPERTY(Expression*, value);
402
462
  ADD_PROPERTY(bool, is_guarded);
403
463
  ADD_PROPERTY(bool, is_global);
404
464
  public:
405
- Assignment(string path, Position position,
465
+ Assignment(ParserState pstate,
406
466
  string var, Expression* val,
407
467
  bool guarded = false,
408
468
  bool global = false)
409
- : Statement(path, position), variable_(var), value_(val), is_guarded_(guarded), is_global_(global)
469
+ : Statement(pstate), variable_(var), value_(val), is_guarded_(guarded), is_global_(global)
410
470
  { }
411
471
  ATTACH_OPERATIONS();
412
472
  };
@@ -417,10 +477,10 @@ namespace Sass {
417
477
  ////////////////////////////////////////////////////////////////////////////
418
478
  class Import : public Statement {
419
479
  vector<string> files_;
420
- vector<Expression*> urls_;
480
+ vector<Expression*> urls_;
421
481
  public:
422
- Import(string path, Position position)
423
- : Statement(path, position),
482
+ Import(ParserState pstate)
483
+ : Statement(pstate),
424
484
  files_(vector<string>()), urls_(vector<Expression*>())
425
485
  { }
426
486
  vector<string>& files() { return files_; }
@@ -431,8 +491,8 @@ namespace Sass {
431
491
  class Import_Stub : public Statement {
432
492
  ADD_PROPERTY(string, file_name);
433
493
  public:
434
- Import_Stub(string path, Position position, string f)
435
- : Statement(path, position), file_name_(f)
494
+ Import_Stub(ParserState pstate, string f)
495
+ : Statement(pstate), file_name_(f)
436
496
  { }
437
497
  ATTACH_OPERATIONS();
438
498
  };
@@ -443,8 +503,8 @@ namespace Sass {
443
503
  class Warning : public Statement {
444
504
  ADD_PROPERTY(Expression*, message);
445
505
  public:
446
- Warning(string path, Position position, Expression* msg)
447
- : Statement(path, position), message_(msg)
506
+ Warning(ParserState pstate, Expression* msg)
507
+ : Statement(pstate), message_(msg)
448
508
  { }
449
509
  ATTACH_OPERATIONS();
450
510
  };
@@ -455,8 +515,8 @@ namespace Sass {
455
515
  class Error : public Statement {
456
516
  ADD_PROPERTY(Expression*, message);
457
517
  public:
458
- Error(string path, Position position, Expression* msg)
459
- : Statement(path, position), message_(msg)
518
+ Error(ParserState pstate, Expression* msg)
519
+ : Statement(pstate), message_(msg)
460
520
  { }
461
521
  ATTACH_OPERATIONS();
462
522
  };
@@ -467,8 +527,8 @@ namespace Sass {
467
527
  class Debug : public Statement {
468
528
  ADD_PROPERTY(Expression*, value);
469
529
  public:
470
- Debug(string path, Position position, Expression* val)
471
- : Statement(path, position), value_(val)
530
+ Debug(ParserState pstate, Expression* val)
531
+ : Statement(pstate), value_(val)
472
532
  { }
473
533
  ATTACH_OPERATIONS();
474
534
  };
@@ -478,9 +538,10 @@ namespace Sass {
478
538
  ///////////////////////////////////////////
479
539
  class Comment : public Statement {
480
540
  ADD_PROPERTY(String*, text);
541
+ ADD_PROPERTY(bool, is_important);
481
542
  public:
482
- Comment(string path, Position position, String* txt)
483
- : Statement(path, position), text_(txt)
543
+ Comment(ParserState pstate, String* txt, bool is_important)
544
+ : Statement(pstate), text_(txt), is_important_(is_important)
484
545
  { }
485
546
  ATTACH_OPERATIONS();
486
547
  };
@@ -493,8 +554,8 @@ namespace Sass {
493
554
  ADD_PROPERTY(Block*, consequent);
494
555
  ADD_PROPERTY(Block*, alternative);
495
556
  public:
496
- If(string path, Position position, Expression* pred, Block* con, Block* alt = 0)
497
- : Statement(path, position), predicate_(pred), consequent_(con), alternative_(alt)
557
+ If(ParserState pstate, Expression* pred, Block* con, Block* alt = 0)
558
+ : Statement(pstate), predicate_(pred), consequent_(con), alternative_(alt)
498
559
  { }
499
560
  ATTACH_OPERATIONS();
500
561
  };
@@ -508,9 +569,9 @@ namespace Sass {
508
569
  ADD_PROPERTY(Expression*, upper_bound);
509
570
  ADD_PROPERTY(bool, is_inclusive);
510
571
  public:
511
- For(string path, Position position,
572
+ For(ParserState pstate,
512
573
  string var, Expression* lo, Expression* hi, Block* b, bool inc)
513
- : Has_Block(path, position, b),
574
+ : Has_Block(pstate, b),
514
575
  variable_(var), lower_bound_(lo), upper_bound_(hi), is_inclusive_(inc)
515
576
  { }
516
577
  ATTACH_OPERATIONS();
@@ -523,8 +584,8 @@ namespace Sass {
523
584
  ADD_PROPERTY(vector<string>, variables);
524
585
  ADD_PROPERTY(Expression*, list);
525
586
  public:
526
- Each(string path, Position position, vector<string> vars, Expression* lst, Block* b)
527
- : Has_Block(path, position, b), variables_(vars), list_(lst)
587
+ Each(ParserState pstate, vector<string> vars, Expression* lst, Block* b)
588
+ : Has_Block(pstate, b), variables_(vars), list_(lst)
528
589
  { }
529
590
  ATTACH_OPERATIONS();
530
591
  };
@@ -535,8 +596,8 @@ namespace Sass {
535
596
  class While : public Has_Block {
536
597
  ADD_PROPERTY(Expression*, predicate);
537
598
  public:
538
- While(string path, Position position, Expression* pred, Block* b)
539
- : Has_Block(path, position, b), predicate_(pred)
599
+ While(ParserState pstate, Expression* pred, Block* b)
600
+ : Has_Block(pstate, b), predicate_(pred)
540
601
  { }
541
602
  ATTACH_OPERATIONS();
542
603
  };
@@ -547,8 +608,8 @@ namespace Sass {
547
608
  class Return : public Statement {
548
609
  ADD_PROPERTY(Expression*, value);
549
610
  public:
550
- Return(string path, Position position, Expression* val)
551
- : Statement(path, position), value_(val)
611
+ Return(ParserState pstate, Expression* val)
612
+ : Statement(pstate), value_(val)
552
613
  { }
553
614
  ATTACH_OPERATIONS();
554
615
  };
@@ -559,8 +620,8 @@ namespace Sass {
559
620
  class Extension : public Statement {
560
621
  ADD_PROPERTY(Selector*, selector);
561
622
  public:
562
- Extension(string path, Position position, Selector* s)
563
- : Statement(path, position), selector_(s)
623
+ Extension(ParserState pstate, Selector* s)
624
+ : Statement(pstate), selector_(s)
564
625
  { }
565
626
  ATTACH_OPERATIONS();
566
627
  };
@@ -569,12 +630,10 @@ namespace Sass {
569
630
  // Definitions for both mixins and functions. The two cases are distinguished
570
631
  // by a type tag.
571
632
  /////////////////////////////////////////////////////////////////////////////
572
- struct Context;
573
633
  struct Backtrace;
574
- class Parameters;
575
634
  typedef Environment<AST_Node*> Env;
576
635
  typedef const char* Signature;
577
- typedef Expression* (*Native_Function)(Env&, Env&, Context&, Signature, const string&, Position, Backtrace*);
636
+ typedef Expression* (*Native_Function)(Env&, Env&, Context&, Signature, ParserState, Backtrace*);
578
637
  typedef const char* Signature;
579
638
  class Definition : public Has_Block {
580
639
  public:
@@ -589,13 +648,12 @@ namespace Sass {
589
648
  ADD_PROPERTY(bool, is_overload_stub);
590
649
  ADD_PROPERTY(Signature, signature);
591
650
  public:
592
- Definition(string path,
593
- Position position,
651
+ Definition(ParserState pstate,
594
652
  string n,
595
653
  Parameters* params,
596
654
  Block* b,
597
655
  Type t)
598
- : Has_Block(path, position, b),
656
+ : Has_Block(pstate, b),
599
657
  name_(n),
600
658
  parameters_(params),
601
659
  environment_(0),
@@ -606,14 +664,13 @@ namespace Sass {
606
664
  is_overload_stub_(false),
607
665
  signature_(0)
608
666
  { }
609
- Definition(string path,
610
- Position position,
667
+ Definition(ParserState pstate,
611
668
  Signature sig,
612
669
  string n,
613
670
  Parameters* params,
614
671
  Native_Function func_ptr,
615
672
  bool overload_stub = false)
616
- : Has_Block(path, position, 0),
673
+ : Has_Block(pstate, 0),
617
674
  name_(n),
618
675
  parameters_(params),
619
676
  environment_(0),
@@ -624,8 +681,7 @@ namespace Sass {
624
681
  is_overload_stub_(overload_stub),
625
682
  signature_(sig)
626
683
  { }
627
- Definition(string path,
628
- Position position,
684
+ Definition(ParserState pstate,
629
685
  Signature sig,
630
686
  string n,
631
687
  Parameters* params,
@@ -633,7 +689,7 @@ namespace Sass {
633
689
  void* cookie,
634
690
  bool whatever,
635
691
  bool whatever2)
636
- : Has_Block(path, position, 0),
692
+ : Has_Block(pstate, 0),
637
693
  name_(n),
638
694
  parameters_(params),
639
695
  environment_(0),
@@ -650,13 +706,12 @@ namespace Sass {
650
706
  //////////////////////////////////////
651
707
  // Mixin calls (i.e., `@include ...`).
652
708
  //////////////////////////////////////
653
- class Arguments;
654
709
  class Mixin_Call : public Has_Block {
655
710
  ADD_PROPERTY(string, name);
656
711
  ADD_PROPERTY(Arguments*, arguments);
657
712
  public:
658
- Mixin_Call(string path, Position position, string n, Arguments* args, Block* b = 0)
659
- : Has_Block(path, position, b), name_(n), arguments_(args)
713
+ Mixin_Call(ParserState pstate, string n, Arguments* args, Block* b = 0)
714
+ : Has_Block(pstate, b), name_(n), arguments_(args)
660
715
  { }
661
716
  ATTACH_OPERATIONS();
662
717
  };
@@ -666,7 +721,7 @@ namespace Sass {
666
721
  ///////////////////////////////////////////////////
667
722
  class Content : public Statement {
668
723
  public:
669
- Content(string path, Position position) : Statement(path, position) { }
724
+ Content(ParserState pstate) : Statement(pstate) { }
670
725
  ATTACH_OPERATIONS();
671
726
  };
672
727
 
@@ -682,9 +737,9 @@ namespace Sass {
682
737
  ADD_PROPERTY(Separator, separator);
683
738
  ADD_PROPERTY(bool, is_arglist);
684
739
  public:
685
- List(string path, Position position,
740
+ List(ParserState pstate,
686
741
  size_t size = 0, Separator sep = SPACE, bool argl = false)
687
- : Expression(path, position),
742
+ : Expression(pstate),
688
743
  Vectorized<Expression*>(size),
689
744
  separator_(sep), is_arglist_(argl)
690
745
  { concrete_type(LIST); }
@@ -729,13 +784,12 @@ namespace Sass {
729
784
  ///////////////////////////////////////////////////////////////////////
730
785
  // Key value paris.
731
786
  ///////////////////////////////////////////////////////////////////////
732
-
733
787
  class Map : public Expression, public Hashed {
734
788
  void adjust_after_pushing(std::pair<Expression*, Expression*> p) { is_expanded(false); }
735
789
  public:
736
- Map(string path, Position position,
790
+ Map(ParserState pstate,
737
791
  size_t size = 0)
738
- : Expression(path, position),
792
+ : Expression(pstate),
739
793
  Hashed(size)
740
794
  { concrete_type(MAP); }
741
795
  string type() { return "map"; }
@@ -772,8 +826,6 @@ namespace Sass {
772
826
  ATTACH_OPERATIONS();
773
827
  };
774
828
 
775
-
776
-
777
829
  //////////////////////////////////////////////////////////////////////////
778
830
  // Binary expressions. Represents logical, relational, and arithmetic
779
831
  // operations. Templatized to avoid large switch statements and repetitive
@@ -792,9 +844,9 @@ namespace Sass {
792
844
  ADD_PROPERTY(Expression*, left);
793
845
  ADD_PROPERTY(Expression*, right);
794
846
  public:
795
- Binary_Expression(string path, Position position,
847
+ Binary_Expression(ParserState pstate,
796
848
  Type t, Expression* lhs, Expression* rhs)
797
- : Expression(path, position), type_(t), left_(lhs), right_(rhs)
849
+ : Expression(pstate), type_(t), left_(lhs), right_(rhs)
798
850
  { }
799
851
  ATTACH_OPERATIONS();
800
852
  };
@@ -809,8 +861,8 @@ namespace Sass {
809
861
  ADD_PROPERTY(Type, type);
810
862
  ADD_PROPERTY(Expression*, operand);
811
863
  public:
812
- Unary_Expression(string path, Position position, Type t, Expression* o)
813
- : Expression(path, position), type_(t), operand_(o)
864
+ Unary_Expression(ParserState pstate, Type t, Expression* o)
865
+ : Expression(pstate), type_(t), operand_(o)
814
866
  { }
815
867
  ATTACH_OPERATIONS();
816
868
  };
@@ -825,11 +877,11 @@ namespace Sass {
825
877
  ADD_PROPERTY(bool, is_keyword_argument);
826
878
  size_t hash_;
827
879
  public:
828
- Argument(string p, Position pos, Expression* val, string n = "", bool rest = false, bool keyword = false)
829
- : Expression(p, pos), value_(val), name_(n), is_rest_argument_(rest), is_keyword_argument_(keyword), hash_(0)
880
+ Argument(ParserState pstate, Expression* val, string n = "", bool rest = false, bool keyword = false)
881
+ : Expression(pstate), value_(val), name_(n), is_rest_argument_(rest), is_keyword_argument_(keyword), hash_(0)
830
882
  {
831
883
  if (!name_.empty() && is_rest_argument_) {
832
- error("variable-length argument may not be passed by name", path(), position());
884
+ error("variable-length argument may not be passed by name", pstate);
833
885
  }
834
886
  }
835
887
 
@@ -874,37 +926,37 @@ namespace Sass {
874
926
  {
875
927
  if (!a->name().empty()) {
876
928
  if (has_rest_argument_ || has_keyword_argument_) {
877
- error("named arguments must precede variable-length argument", a->path(), a->position());
929
+ error("named arguments must precede variable-length argument", a->pstate());
878
930
  }
879
931
  has_named_arguments_ = true;
880
932
  }
881
933
  else if (a->is_rest_argument()) {
882
934
  if (has_rest_argument_) {
883
- error("functions and mixins may only be called with one variable-length argument", a->path(), a->position());
935
+ error("functions and mixins may only be called with one variable-length argument", a->pstate());
884
936
  }
885
937
  if (has_keyword_argument_) {
886
- error("only keyword arguments may follow variable arguments", a->path(), a->position());
938
+ error("only keyword arguments may follow variable arguments", a->pstate());
887
939
  }
888
940
  has_rest_argument_ = true;
889
941
  }
890
942
  else if (a->is_keyword_argument()) {
891
943
  if (has_keyword_argument_) {
892
- error("functions and mixins may only be called with one keyword argument", a->path(), a->position());
944
+ error("functions and mixins may only be called with one keyword argument", a->pstate());
893
945
  }
894
946
  has_keyword_argument_ = true;
895
947
  }
896
948
  else {
897
949
  if (has_rest_argument_) {
898
- error("ordinal arguments must precede variable-length arguments", a->path(), a->position());
950
+ error("ordinal arguments must precede variable-length arguments", a->pstate());
899
951
  }
900
952
  if (has_named_arguments_) {
901
- error("ordinal arguments must precede named arguments", a->path(), a->position());
953
+ error("ordinal arguments must precede named arguments", a->pstate());
902
954
  }
903
955
  }
904
956
  }
905
957
  public:
906
- Arguments(string path, Position position)
907
- : Expression(path, position),
958
+ Arguments(ParserState pstate)
959
+ : Expression(pstate),
908
960
  Vectorized<Argument*>(),
909
961
  has_named_arguments_(false),
910
962
  has_rest_argument_(false),
@@ -922,11 +974,11 @@ namespace Sass {
922
974
  ADD_PROPERTY(void*, cookie);
923
975
  size_t hash_;
924
976
  public:
925
- Function_Call(string path, Position position, string n, Arguments* args, void* cookie)
926
- : Expression(path, position), name_(n), arguments_(args), cookie_(cookie), hash_(0)
977
+ Function_Call(ParserState pstate, string n, Arguments* args, void* cookie)
978
+ : Expression(pstate), name_(n), arguments_(args), cookie_(cookie), hash_(0)
927
979
  { concrete_type(STRING); }
928
- Function_Call(string path, Position position, string n, Arguments* args)
929
- : Expression(path, position), name_(n), arguments_(args), cookie_(0), hash_(0)
980
+ Function_Call(ParserState pstate, string n, Arguments* args)
981
+ : Expression(pstate), name_(n), arguments_(args), cookie_(0), hash_(0)
930
982
  { concrete_type(STRING); }
931
983
 
932
984
  virtual bool operator==(Expression& rhs) const
@@ -968,8 +1020,8 @@ namespace Sass {
968
1020
  ADD_PROPERTY(String*, name);
969
1021
  ADD_PROPERTY(Arguments*, arguments);
970
1022
  public:
971
- Function_Call_Schema(string path, Position position, String* n, Arguments* args)
972
- : Expression(path, position), name_(n), arguments_(args)
1023
+ Function_Call_Schema(ParserState pstate, String* n, Arguments* args)
1024
+ : Expression(pstate), name_(n), arguments_(args)
973
1025
  { concrete_type(STRING); }
974
1026
  ATTACH_OPERATIONS();
975
1027
  };
@@ -980,8 +1032,8 @@ namespace Sass {
980
1032
  class Variable : public Expression {
981
1033
  ADD_PROPERTY(string, name);
982
1034
  public:
983
- Variable(string path, Position position, string n)
984
- : Expression(path, position), name_(n)
1035
+ Variable(ParserState pstate, string n)
1036
+ : Expression(pstate), name_(n)
985
1037
  { }
986
1038
 
987
1039
  virtual bool operator==(Expression& rhs) const
@@ -1018,8 +1070,8 @@ namespace Sass {
1018
1070
  ADD_PROPERTY(string, value);
1019
1071
  size_t hash_;
1020
1072
  public:
1021
- Textual(string path, Position position, Type t, string val)
1022
- : Expression(path, position, true), type_(t), value_(val),
1073
+ Textual(ParserState pstate, Type t, string val)
1074
+ : Expression(pstate, true), type_(t), value_(val),
1023
1075
  hash_(0)
1024
1076
  { }
1025
1077
 
@@ -1056,8 +1108,8 @@ namespace Sass {
1056
1108
  vector<string> denominator_units_;
1057
1109
  size_t hash_;
1058
1110
  public:
1059
- Number(string path, Position position, double val, string u = "", bool zero = true)
1060
- : Expression(path, position),
1111
+ Number(ParserState pstate, double val, string u = "", bool zero = true)
1112
+ : Expression(pstate),
1061
1113
  value_(val),
1062
1114
  zero_(zero),
1063
1115
  numerator_units_(vector<string>()),
@@ -1201,8 +1253,8 @@ namespace Sass {
1201
1253
  ADD_PROPERTY(string, disp);
1202
1254
  size_t hash_;
1203
1255
  public:
1204
- Color(string path, Position position, double r, double g, double b, double a = 1, bool sixtuplet = true, const string disp = "")
1205
- : Expression(path, position), r_(r), g_(g), b_(b), a_(a), sixtuplet_(sixtuplet), disp_(disp),
1256
+ Color(ParserState pstate, double r, double g, double b, double a = 1, bool sixtuplet = true, const string disp = "")
1257
+ : Expression(pstate), r_(r), g_(g), b_(b), a_(a), sixtuplet_(sixtuplet), disp_(disp),
1206
1258
  hash_(0)
1207
1259
  { concrete_type(COLOR); }
1208
1260
  string type() { return "color"; }
@@ -1238,8 +1290,8 @@ namespace Sass {
1238
1290
  ADD_PROPERTY(bool, value);
1239
1291
  size_t hash_;
1240
1292
  public:
1241
- Boolean(string path, Position position, bool val)
1242
- : Expression(path, position), value_(val),
1293
+ Boolean(ParserState pstate, bool val)
1294
+ : Expression(pstate), value_(val),
1243
1295
  hash_(0)
1244
1296
  { concrete_type(BOOLEAN); }
1245
1297
  virtual operator bool() { return value_; }
@@ -1275,10 +1327,10 @@ namespace Sass {
1275
1327
  // "flat" strings.
1276
1328
  ////////////////////////////////////////////////////////////////////////
1277
1329
  class String : public Expression {
1278
- ADD_PROPERTY(bool, needs_unquoting);
1330
+ ADD_PROPERTY(bool, sass_fix_1291);
1279
1331
  public:
1280
- String(string path, Position position, bool unq = false, bool delayed = false)
1281
- : Expression(path, position, delayed), needs_unquoting_(unq)
1332
+ String(ParserState pstate, bool delayed = false, bool sass_fix_1291 = false)
1333
+ : Expression(pstate, delayed), sass_fix_1291_(sass_fix_1291)
1282
1334
  { concrete_type(STRING); }
1283
1335
  static string type_name() { return "string"; }
1284
1336
  virtual ~String() = 0;
@@ -1291,12 +1343,11 @@ namespace Sass {
1291
1343
  // evaluation phase.
1292
1344
  ///////////////////////////////////////////////////////////////////////
1293
1345
  class String_Schema : public String, public Vectorized<Expression*> {
1294
- ADD_PROPERTY(char, quote_mark);
1295
1346
  ADD_PROPERTY(bool, has_interpolants);
1296
1347
  size_t hash_;
1297
1348
  public:
1298
- String_Schema(string path, Position position, size_t size = 0, bool unq = false, char qm = '\0', bool i = false)
1299
- : String(path, position, unq), Vectorized<Expression*>(size), quote_mark_(qm), has_interpolants_(i), hash_(0)
1349
+ String_Schema(ParserState pstate, size_t size = 0, bool has_interpolants = false)
1350
+ : String(pstate), Vectorized<Expression*>(size), has_interpolants_(has_interpolants), hash_(0)
1300
1351
  { }
1301
1352
  string type() { return "string"; }
1302
1353
  static string type_name() { return "string"; }
@@ -1335,22 +1386,23 @@ namespace Sass {
1335
1386
  // Flat strings -- the lowest level of raw textual data.
1336
1387
  ////////////////////////////////////////////////////////
1337
1388
  class String_Constant : public String {
1389
+ ADD_PROPERTY(char, quote_mark);
1338
1390
  ADD_PROPERTY(string, value);
1339
- string unquoted_;
1391
+ protected:
1340
1392
  size_t hash_;
1341
1393
  public:
1342
- String_Constant(string path, Position position, string val, bool unq = false)
1343
- : String(path, position, unq, true), value_(val), hash_(0)
1344
- { unquoted_ = unquote(value_); }
1345
- String_Constant(string path, Position position, const char* beg, bool unq = false)
1346
- : String(path, position, unq, true), value_(string(beg)), hash_(0)
1347
- { unquoted_ = unquote(value_); }
1348
- String_Constant(string path, Position position, const char* beg, const char* end, bool unq = false)
1349
- : String(path, position, unq, true), value_(string(beg, end-beg)), hash_(0)
1350
- { unquoted_ = unquote(value_); }
1351
- String_Constant(string path, Position position, const Token& tok, bool unq = false)
1352
- : String(path, position, unq, true), value_(string(tok.begin, tok.end)), hash_(0)
1353
- { unquoted_ = unquote(value_); }
1394
+ String_Constant(ParserState pstate, string val)
1395
+ : String(pstate), quote_mark_(0), value_(val), hash_(0)
1396
+ { }
1397
+ String_Constant(ParserState pstate, const char* beg)
1398
+ : String(pstate), quote_mark_(0), value_(string(beg)), hash_(0)
1399
+ { }
1400
+ String_Constant(ParserState pstate, const char* beg, const char* end)
1401
+ : String(pstate), quote_mark_(0), value_(string(beg, end-beg)), hash_(0)
1402
+ { }
1403
+ String_Constant(ParserState pstate, const Token& tok)
1404
+ : String(pstate), quote_mark_(0), value_(string(tok.begin, tok.end)), hash_(0)
1405
+ { }
1354
1406
  string type() { return "string"; }
1355
1407
  static string type_name() { return "string"; }
1356
1408
 
@@ -1359,7 +1411,7 @@ namespace Sass {
1359
1411
  try
1360
1412
  {
1361
1413
  String_Constant& e = dynamic_cast<String_Constant&>(rhs);
1362
- return e && unquoted_ == e.unquoted_;
1414
+ return e && value_ == e.value_;
1363
1415
  }
1364
1416
  catch (std::bad_cast&)
1365
1417
  {
@@ -1370,15 +1422,27 @@ namespace Sass {
1370
1422
 
1371
1423
  virtual size_t hash()
1372
1424
  {
1373
- if (hash_ == 0) hash_ = std::hash<string>()(unquoted_);
1425
+ if (hash_ == 0) hash_ = std::hash<string>()(value_);
1374
1426
  return hash_;
1375
1427
  }
1376
1428
 
1377
- static char single_quote() { return '\''; }
1429
+ // static char auto_quote() { return '*'; }
1378
1430
  static char double_quote() { return '"'; }
1431
+ static char single_quote() { return '\''; }
1379
1432
 
1380
- bool is_quoted() { return value_.length() && (value_[0] == '"' || value_[0] == '\''); }
1381
- char quote_mark() { return is_quoted() ? value_[0] : '\0'; }
1433
+ ATTACH_OPERATIONS();
1434
+ };
1435
+
1436
+ ////////////////////////////////////////////////////////
1437
+ // Possibly quoted string (unquote on instantiation)
1438
+ ////////////////////////////////////////////////////////
1439
+ class String_Quoted : public String_Constant {
1440
+ public:
1441
+ String_Quoted(ParserState pstate, string val)
1442
+ : String_Constant(pstate, val)
1443
+ {
1444
+ value_ = unquote(value_, &quote_mark_);
1445
+ }
1382
1446
  ATTACH_OPERATIONS();
1383
1447
  };
1384
1448
 
@@ -1391,9 +1455,9 @@ namespace Sass {
1391
1455
  ADD_PROPERTY(bool, is_negated);
1392
1456
  ADD_PROPERTY(bool, is_restricted);
1393
1457
  public:
1394
- Media_Query(string path, Position position,
1458
+ Media_Query(ParserState pstate,
1395
1459
  String* t = 0, size_t s = 0, bool n = false, bool r = false)
1396
- : Expression(path, position), Vectorized<Media_Query_Expression*>(s),
1460
+ : Expression(pstate), Vectorized<Media_Query_Expression*>(s),
1397
1461
  media_type_(t), is_negated_(n), is_restricted_(r)
1398
1462
  { }
1399
1463
  ATTACH_OPERATIONS();
@@ -1407,9 +1471,9 @@ namespace Sass {
1407
1471
  ADD_PROPERTY(Expression*, value);
1408
1472
  ADD_PROPERTY(bool, is_interpolated);
1409
1473
  public:
1410
- Media_Query_Expression(string path, Position position,
1474
+ Media_Query_Expression(ParserState pstate,
1411
1475
  Expression* f, Expression* v, bool i = false)
1412
- : Expression(path, position), feature_(f), value_(v), is_interpolated_(i)
1476
+ : Expression(pstate), feature_(f), value_(v), is_interpolated_(i)
1413
1477
  { }
1414
1478
  ATTACH_OPERATIONS();
1415
1479
  };
@@ -1419,8 +1483,8 @@ namespace Sass {
1419
1483
  ///////////////////
1420
1484
  class Feature_Query : public Expression, public Vectorized<Feature_Query_Condition*> {
1421
1485
  public:
1422
- Feature_Query(string path, Position position, size_t s = 0)
1423
- : Expression(path, position), Vectorized<Feature_Query_Condition*>(s)
1486
+ Feature_Query(ParserState pstate, size_t s = 0)
1487
+ : Expression(pstate), Vectorized<Feature_Query_Condition*>(s)
1424
1488
  { }
1425
1489
  ATTACH_OPERATIONS();
1426
1490
  };
@@ -1437,20 +1501,100 @@ namespace Sass {
1437
1501
  ADD_PROPERTY(Operand, operand);
1438
1502
  ADD_PROPERTY(bool, is_root);
1439
1503
  public:
1440
- Feature_Query_Condition(string path, Position position, size_t s = 0, String* f = 0,
1504
+ Feature_Query_Condition(ParserState pstate, size_t s = 0, String* f = 0,
1441
1505
  Expression* v = 0, Operand o = NONE, bool r = false)
1442
- : Expression(path, position), Vectorized<Feature_Query_Condition*>(s),
1506
+ : Expression(pstate), Vectorized<Feature_Query_Condition*>(s),
1443
1507
  feature_(f), value_(v), operand_(o), is_root_(r)
1444
1508
  { }
1445
1509
  ATTACH_OPERATIONS();
1446
1510
  };
1447
1511
 
1512
+ /////////////////////////////////////////////////
1513
+ // At root expressions (for use inside @at-root).
1514
+ /////////////////////////////////////////////////
1515
+ class At_Root_Expression : public Expression {
1516
+ private:
1517
+ ADD_PROPERTY(String*, feature);
1518
+ ADD_PROPERTY(Expression*, value);
1519
+ ADD_PROPERTY(bool, is_interpolated);
1520
+ public:
1521
+ At_Root_Expression(ParserState pstate, String* f = 0, Expression* v = 0, bool i = false)
1522
+ : Expression(pstate), feature_(f), value_(v), is_interpolated_(i)
1523
+ { }
1524
+ bool exclude(string str)
1525
+ {
1526
+ To_String to_string;
1527
+ bool with = feature() && unquote(feature()->perform(&to_string)).compare("with") == 0;
1528
+ List* l = static_cast<List*>(value());
1529
+ string v;
1530
+
1531
+ if (with)
1532
+ {
1533
+ if (!l || l->length() == 0) return str.compare("rule") != 0;
1534
+ for (size_t i = 0, L = l->length(); i < L; ++i)
1535
+ {
1536
+ v = unquote((*l)[i]->perform(&to_string));
1537
+ if (v.compare("all") == 0 || v == str) return false;
1538
+ }
1539
+ return true;
1540
+ }
1541
+ else
1542
+ {
1543
+ if (!l || !l->length()) return str.compare("rule") == 0;
1544
+ for (size_t i = 0, L = l->length(); i < L; ++i)
1545
+ {
1546
+ v = unquote((*l)[i]->perform(&to_string));
1547
+ if (v.compare("all") == 0 || v == str) return true;
1548
+ }
1549
+ return false;
1550
+ }
1551
+ }
1552
+ ATTACH_OPERATIONS();
1553
+ };
1554
+
1555
+ ///////////
1556
+ // At-root.
1557
+ ///////////
1558
+ class At_Root_Block : public Has_Block {
1559
+ ADD_PROPERTY(At_Root_Expression*, expression);
1560
+ public:
1561
+ At_Root_Block(ParserState pstate, Block* b = 0, At_Root_Expression* e = 0)
1562
+ : Has_Block(pstate, b), expression_(e)
1563
+ { statement_type(ATROOT); }
1564
+ bool is_hoistable() { return true; }
1565
+ bool bubbles() { return true; }
1566
+ bool exclude_node(Statement* s) {
1567
+ if (s->statement_type() == Statement::DIRECTIVE)
1568
+ {
1569
+ return expression()->exclude(static_cast<At_Rule*>(s)->keyword().erase(0, 1));
1570
+ }
1571
+ if (s->statement_type() == Statement::MEDIA)
1572
+ {
1573
+ return expression()->exclude("media");
1574
+ }
1575
+ if (s->statement_type() == Statement::RULESET)
1576
+ {
1577
+ return expression()->exclude("rule");
1578
+ }
1579
+ if (s->statement_type() == Statement::FEATURE)
1580
+ {
1581
+ return expression()->exclude("supports");
1582
+ }
1583
+ if (static_cast<At_Rule*>(s)->is_keyframes())
1584
+ {
1585
+ return expression()->exclude("keyframes");
1586
+ }
1587
+ return false;
1588
+ }
1589
+ ATTACH_OPERATIONS();
1590
+ };
1591
+
1448
1592
  //////////////////
1449
1593
  // The null value.
1450
1594
  //////////////////
1451
1595
  class Null : public Expression {
1452
1596
  public:
1453
- Null(string path, Position position) : Expression(path, position) { concrete_type(NULL_VAL); }
1597
+ Null(ParserState pstate) : Expression(pstate) { concrete_type(NULL_VAL); }
1454
1598
  string type() { return "null"; }
1455
1599
  static string type_name() { return "null"; }
1456
1600
  bool is_invisible() { return true; }
@@ -1477,8 +1621,8 @@ namespace Sass {
1477
1621
  ADD_PROPERTY(Expression*, expression);
1478
1622
  ADD_PROPERTY(Env*, environment);
1479
1623
  public:
1480
- Thunk(string path, Position position, Expression* exp, Env* env = 0)
1481
- : Expression(path, position), expression_(exp), environment_(env)
1624
+ Thunk(ParserState pstate, Expression* exp, Env* env = 0)
1625
+ : Expression(pstate), expression_(exp), environment_(env)
1482
1626
  { }
1483
1627
  };
1484
1628
 
@@ -1490,12 +1634,12 @@ namespace Sass {
1490
1634
  ADD_PROPERTY(Expression*, default_value);
1491
1635
  ADD_PROPERTY(bool, is_rest_parameter);
1492
1636
  public:
1493
- Parameter(string p, Position pos,
1637
+ Parameter(ParserState pstate,
1494
1638
  string n, Expression* def = 0, bool rest = false)
1495
- : AST_Node(p, pos), name_(n), default_value_(def), is_rest_parameter_(rest)
1639
+ : AST_Node(pstate), name_(n), default_value_(def), is_rest_parameter_(rest)
1496
1640
  {
1497
1641
  if (default_value_ && is_rest_parameter_) {
1498
- error("variable-length parameter may not have a default value", path(), position());
1642
+ error("variable-length parameter may not have a default value", pstate);
1499
1643
  }
1500
1644
  }
1501
1645
  ATTACH_OPERATIONS();
@@ -1514,31 +1658,31 @@ namespace Sass {
1514
1658
  {
1515
1659
  if (p->default_value()) {
1516
1660
  if (has_rest_parameter_) {
1517
- error("optional parameters may not be combined with variable-length parameters", p->path(), p->position());
1661
+ error("optional parameters may not be combined with variable-length parameters", p->pstate());
1518
1662
  }
1519
1663
  has_optional_parameters_ = true;
1520
1664
  }
1521
1665
  else if (p->is_rest_parameter()) {
1522
1666
  if (has_rest_parameter_) {
1523
- error("functions and mixins cannot have more than one variable-length parameter", p->path(), p->position());
1667
+ error("functions and mixins cannot have more than one variable-length parameter", p->pstate());
1524
1668
  }
1525
1669
  if (has_optional_parameters_) {
1526
- error("optional parameters may not be combined with variable-length parameters", p->path(), p->position());
1670
+ error("optional parameters may not be combined with variable-length parameters", p->pstate());
1527
1671
  }
1528
1672
  has_rest_parameter_ = true;
1529
1673
  }
1530
1674
  else {
1531
1675
  if (has_rest_parameter_) {
1532
- error("required parameters must precede variable-length parameters", p->path(), p->position());
1676
+ error("required parameters must precede variable-length parameters", p->pstate());
1533
1677
  }
1534
1678
  if (has_optional_parameters_) {
1535
- error("required parameters must precede optional parameters", p->path(), p->position());
1679
+ error("required parameters must precede optional parameters", p->pstate());
1536
1680
  }
1537
1681
  }
1538
1682
  }
1539
1683
  public:
1540
- Parameters(string path, Position position)
1541
- : AST_Node(path, position),
1684
+ Parameters(ParserState pstate)
1685
+ : AST_Node(pstate),
1542
1686
  Vectorized<Parameter*>(),
1543
1687
  has_optional_parameters_(false),
1544
1688
  has_rest_parameter_(false)
@@ -1557,12 +1701,27 @@ namespace Sass {
1557
1701
  class Selector : public AST_Node {
1558
1702
  ADD_PROPERTY(bool, has_reference);
1559
1703
  ADD_PROPERTY(bool, has_placeholder);
1560
- public:
1561
- Selector(string path, Position position, bool r = false, bool h = false)
1562
- : AST_Node(path, position), has_reference_(r), has_placeholder_(h)
1704
+ // line break before list separator
1705
+ ADD_PROPERTY(bool, has_line_feed);
1706
+ // line break after list separator
1707
+ ADD_PROPERTY(bool, has_line_break);
1708
+ // maybe we have optional flag
1709
+ ADD_PROPERTY(bool, is_optional);
1710
+ // parent block pointers
1711
+ ADD_PROPERTY(Block*, last_block);
1712
+ ADD_PROPERTY(Media_Block*, media_block);
1713
+ public:
1714
+ Selector(ParserState pstate, bool r = false, bool h = false)
1715
+ : AST_Node(pstate),
1716
+ has_reference_(r),
1717
+ has_placeholder_(h),
1718
+ has_line_feed_(false),
1719
+ has_line_break_(false),
1720
+ is_optional_(false),
1721
+ media_block_(0)
1563
1722
  { }
1564
1723
  virtual ~Selector() = 0;
1565
- virtual Selector_Placeholder* find_placeholder();
1724
+ // virtual Selector_Placeholder* find_placeholder();
1566
1725
  virtual int specificity() { return Constants::SPECIFICITY_BASE; }
1567
1726
  };
1568
1727
  inline Selector::~Selector() { }
@@ -1574,8 +1733,8 @@ namespace Sass {
1574
1733
  class Selector_Schema : public Selector {
1575
1734
  ADD_PROPERTY(String*, contents);
1576
1735
  public:
1577
- Selector_Schema(string path, Position position, String* c)
1578
- : Selector(path, position), contents_(c)
1736
+ Selector_Schema(ParserState pstate, String* c)
1737
+ : Selector(pstate), contents_(c)
1579
1738
  { }
1580
1739
  ATTACH_OPERATIONS();
1581
1740
  };
@@ -1585,8 +1744,8 @@ namespace Sass {
1585
1744
  ////////////////////////////////////////////
1586
1745
  class Simple_Selector : public Selector {
1587
1746
  public:
1588
- Simple_Selector(string path, Position position)
1589
- : Selector(path, position)
1747
+ Simple_Selector(ParserState pstate)
1748
+ : Selector(pstate)
1590
1749
  { }
1591
1750
  virtual ~Simple_Selector() = 0;
1592
1751
  virtual Compound_Selector* unify_with(Compound_Selector*, Context&);
@@ -1605,8 +1764,8 @@ namespace Sass {
1605
1764
  class Selector_Reference : public Simple_Selector {
1606
1765
  ADD_PROPERTY(Selector*, selector);
1607
1766
  public:
1608
- Selector_Reference(string path, Position position, Selector* r = 0)
1609
- : Simple_Selector(path, position), selector_(r)
1767
+ Selector_Reference(ParserState pstate, Selector* r = 0)
1768
+ : Simple_Selector(pstate), selector_(r)
1610
1769
  { has_reference(true); }
1611
1770
  virtual int specificity()
1612
1771
  {
@@ -1622,10 +1781,10 @@ namespace Sass {
1622
1781
  class Selector_Placeholder : public Simple_Selector {
1623
1782
  ADD_PROPERTY(string, name);
1624
1783
  public:
1625
- Selector_Placeholder(string path, Position position, string n)
1626
- : Simple_Selector(path, position), name_(n)
1784
+ Selector_Placeholder(ParserState pstate, string n)
1785
+ : Simple_Selector(pstate), name_(n)
1627
1786
  { has_placeholder(true); }
1628
- virtual Selector_Placeholder* find_placeholder();
1787
+ // virtual Selector_Placeholder* find_placeholder();
1629
1788
  ATTACH_OPERATIONS();
1630
1789
  };
1631
1790
 
@@ -1635,8 +1794,8 @@ namespace Sass {
1635
1794
  class Type_Selector : public Simple_Selector {
1636
1795
  ADD_PROPERTY(string, name);
1637
1796
  public:
1638
- Type_Selector(string path, Position position, string n)
1639
- : Simple_Selector(path, position), name_(n)
1797
+ Type_Selector(ParserState pstate, string n)
1798
+ : Simple_Selector(pstate), name_(n)
1640
1799
  { }
1641
1800
  virtual int specificity()
1642
1801
  {
@@ -1653,8 +1812,8 @@ namespace Sass {
1653
1812
  class Selector_Qualifier : public Simple_Selector {
1654
1813
  ADD_PROPERTY(string, name);
1655
1814
  public:
1656
- Selector_Qualifier(string path, Position position, string n)
1657
- : Simple_Selector(path, position), name_(n)
1815
+ Selector_Qualifier(ParserState pstate, string n)
1816
+ : Simple_Selector(pstate), name_(n)
1658
1817
  { }
1659
1818
  virtual int specificity()
1660
1819
  {
@@ -1673,8 +1832,8 @@ namespace Sass {
1673
1832
  ADD_PROPERTY(string, matcher);
1674
1833
  ADD_PROPERTY(String*, value); // might be interpolated
1675
1834
  public:
1676
- Attribute_Selector(string path, Position position, string n, string m, String* v)
1677
- : Simple_Selector(path, position), name_(n), matcher_(m), value_(v)
1835
+ Attribute_Selector(ParserState pstate, string n, string m, String* v)
1836
+ : Simple_Selector(pstate), name_(n), matcher_(m), value_(v)
1678
1837
  { }
1679
1838
  ATTACH_OPERATIONS();
1680
1839
  };
@@ -1686,8 +1845,8 @@ namespace Sass {
1686
1845
  ADD_PROPERTY(string, name);
1687
1846
  ADD_PROPERTY(String*, expression);
1688
1847
  public:
1689
- Pseudo_Selector(string path, Position position, string n, String* expr = 0)
1690
- : Simple_Selector(path, position), name_(n), expression_(expr)
1848
+ Pseudo_Selector(ParserState pstate, string n, String* expr = 0)
1849
+ : Simple_Selector(pstate), name_(n), expression_(expr)
1691
1850
  { }
1692
1851
  virtual int specificity()
1693
1852
  {
@@ -1724,8 +1883,8 @@ namespace Sass {
1724
1883
  ADD_PROPERTY(string, name);
1725
1884
  ADD_PROPERTY(Selector*, selector);
1726
1885
  public:
1727
- Wrapped_Selector(string path, Position position, string n, Selector* sel)
1728
- : Simple_Selector(path, position), name_(n), selector_(sel)
1886
+ Wrapped_Selector(ParserState pstate, string n, Selector* sel)
1887
+ : Simple_Selector(pstate), name_(n), selector_(sel)
1729
1888
  { }
1730
1889
  ATTACH_OPERATIONS();
1731
1890
  };
@@ -1749,13 +1908,13 @@ namespace Sass {
1749
1908
  if (s->has_placeholder()) has_placeholder(true);
1750
1909
  }
1751
1910
  public:
1752
- Compound_Selector(string path, Position position, size_t s = 0)
1753
- : Selector(path, position),
1911
+ Compound_Selector(ParserState pstate, size_t s = 0)
1912
+ : Selector(pstate),
1754
1913
  Vectorized<Simple_Selector*>(s)
1755
1914
  { }
1756
1915
 
1757
1916
  Compound_Selector* unify_with(Compound_Selector* rhs, Context& ctx);
1758
- virtual Selector_Placeholder* find_placeholder();
1917
+ // virtual Selector_Placeholder* find_placeholder();
1759
1918
  Simple_Selector* base()
1760
1919
  {
1761
1920
  // Implement non-const in terms of const. Safe to const_cast since this method is non-const
@@ -1802,7 +1961,6 @@ namespace Sass {
1802
1961
  // CSS selector combinators (">", "+", "~", and whitespace). Essentially a
1803
1962
  // linked list.
1804
1963
  ////////////////////////////////////////////////////////////////////////////
1805
- struct Context;
1806
1964
  class Complex_Selector : public Selector {
1807
1965
  public:
1808
1966
  enum Combinator { ANCESTOR_OF, PARENT_OF, PRECEDES, ADJACENT_TO };
@@ -1811,11 +1969,11 @@ namespace Sass {
1811
1969
  ADD_PROPERTY(Compound_Selector*, head);
1812
1970
  ADD_PROPERTY(Complex_Selector*, tail);
1813
1971
  public:
1814
- Complex_Selector(string path, Position position,
1815
- Combinator c,
1816
- Compound_Selector* h,
1817
- Complex_Selector* t)
1818
- : Selector(path, position), combinator_(c), head_(h), tail_(t)
1972
+ Complex_Selector(ParserState pstate,
1973
+ Combinator c,
1974
+ Compound_Selector* h,
1975
+ Complex_Selector* t)
1976
+ : Selector(pstate), combinator_(c), head_(h), tail_(t)
1819
1977
  {
1820
1978
  if ((h && h->has_reference()) || (t && t->has_reference())) has_reference(true);
1821
1979
  if ((h && h->has_placeholder()) || (t && t->has_placeholder())) has_placeholder(true);
@@ -1826,7 +1984,7 @@ namespace Sass {
1826
1984
  size_t length();
1827
1985
  bool is_superselector_of(Compound_Selector*);
1828
1986
  bool is_superselector_of(Complex_Selector*);
1829
- virtual Selector_Placeholder* find_placeholder();
1987
+ // virtual Selector_Placeholder* find_placeholder();
1830
1988
  Combinator clear_innermost();
1831
1989
  void set_innermost(Complex_Selector*, Combinator);
1832
1990
  virtual int specificity() const
@@ -1889,7 +2047,7 @@ namespace Sass {
1889
2047
  }
1890
2048
  Complex_Selector* clone(Context&) const; // does not clone Compound_Selector*s
1891
2049
  Complex_Selector* cloneFully(Context&) const; // clones Compound_Selector*s
1892
- vector<Compound_Selector*> to_vector();
2050
+ // vector<Compound_Selector*> to_vector();
1893
2051
  ATTACH_OPERATIONS();
1894
2052
  };
1895
2053
 
@@ -1898,18 +2056,18 @@ namespace Sass {
1898
2056
  ///////////////////////////////////
1899
2057
  // Comma-separated selector groups.
1900
2058
  ///////////////////////////////////
1901
- class Selector_List
1902
- : public Selector, public Vectorized<Complex_Selector*> {
2059
+ class Selector_List : public Selector, public Vectorized<Complex_Selector*> {
1903
2060
  #ifdef DEBUG
1904
2061
  ADD_PROPERTY(string, mCachedSelector);
1905
2062
  #endif
2063
+ ADD_PROPERTY(vector<string>, wspace);
1906
2064
  protected:
1907
2065
  void adjust_after_pushing(Complex_Selector* c);
1908
2066
  public:
1909
- Selector_List(string path, Position position, size_t s = 0)
1910
- : Selector(path, position), Vectorized<Complex_Selector*>(s)
2067
+ Selector_List(ParserState pstate, size_t s = 0)
2068
+ : Selector(pstate), Vectorized<Complex_Selector*>(s), wspace_(0)
1911
2069
  { }
1912
- virtual Selector_Placeholder* find_placeholder();
2070
+ // virtual Selector_Placeholder* find_placeholder();
1913
2071
  virtual int specificity()
1914
2072
  {
1915
2073
  int sum = 0;
@@ -1921,6 +2079,14 @@ namespace Sass {
1921
2079
  ATTACH_OPERATIONS();
1922
2080
  };
1923
2081
 
2082
+ inline bool Ruleset::is_invisible() {
2083
+ bool is_invisible = true;
2084
+ Selector_List* sl = static_cast<Selector_List*>(selector());
2085
+ for (size_t i = 0, L = sl->length(); i < L && is_invisible; ++i)
2086
+ is_invisible &= (*sl)[i]->has_placeholder();
2087
+ return is_invisible;
2088
+ }
2089
+
1924
2090
 
1925
2091
  template<typename SelectorType>
1926
2092
  bool selectors_equal(const SelectorType& one, const SelectorType& two, bool simpleSelectorOrderDependent) {
@@ -1947,3 +2113,5 @@ namespace Sass {
1947
2113
  #pragma clang diagnostic pop
1948
2114
 
1949
2115
  #endif
2116
+
2117
+ #endif