sassc 1.7.1 → 1.8.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/ext/libsass/.gitignore +10 -6
  4. data/ext/libsass/.travis.yml +4 -1
  5. data/ext/libsass/GNUmakefile.am +88 -0
  6. data/ext/libsass/Makefile +157 -76
  7. data/ext/libsass/Makefile.conf +47 -0
  8. data/ext/libsass/Readme.md +13 -14
  9. data/ext/libsass/appveyor.yml +25 -41
  10. data/ext/libsass/configure.ac +20 -7
  11. data/ext/libsass/contrib/plugin.cpp +1 -1
  12. data/ext/libsass/include/sass.h +15 -0
  13. data/ext/libsass/{sass.h → include/sass/base.h} +17 -9
  14. data/ext/libsass/{sass_context.h → include/sass/context.h} +3 -1
  15. data/ext/libsass/{sass_functions.h → include/sass/functions.h} +4 -4
  16. data/ext/libsass/{sass_interface.h → include/sass/interface.h} +5 -2
  17. data/ext/libsass/{sass_values.h → include/sass/values.h} +15 -1
  18. data/ext/libsass/{sass_version.h → include/sass/version.h} +0 -0
  19. data/ext/libsass/{sass_version.h.in → include/sass/version.h.in} +0 -0
  20. data/ext/libsass/{sass2scss.h → include/sass2scss.h} +6 -7
  21. data/ext/libsass/m4/m4-ax_cxx_compile_stdcxx_11.m4 +167 -0
  22. data/ext/libsass/script/ci-build-libsass +67 -23
  23. data/ext/libsass/src/GNUmakefile.am +54 -0
  24. data/ext/libsass/src/ast.cpp +2029 -0
  25. data/ext/libsass/{ast.hpp → src/ast.hpp} +832 -660
  26. data/ext/libsass/src/ast_def_macros.hpp +47 -0
  27. data/ext/libsass/src/ast_factory.hpp +93 -0
  28. data/ext/libsass/{ast_fwd_decl.hpp → src/ast_fwd_decl.hpp} +9 -4
  29. data/ext/libsass/{b64 → src/b64}/cencode.h +1 -1
  30. data/ext/libsass/{b64 → src/b64}/encode.h +0 -0
  31. data/ext/libsass/{backtrace.hpp → src/backtrace.hpp} +9 -10
  32. data/ext/libsass/{base64vlq.cpp → src/base64vlq.cpp} +2 -2
  33. data/ext/libsass/{base64vlq.hpp → src/base64vlq.hpp} +1 -2
  34. data/ext/libsass/{bind.cpp → src/bind.cpp} +96 -59
  35. data/ext/libsass/{bind.hpp → src/bind.hpp} +1 -1
  36. data/ext/libsass/src/c99func.c +54 -0
  37. data/ext/libsass/{cencode.c → src/cencode.c} +5 -5
  38. data/ext/libsass/src/color_maps.cpp +643 -0
  39. data/ext/libsass/src/color_maps.hpp +333 -0
  40. data/ext/libsass/{constants.cpp → src/constants.cpp} +10 -1
  41. data/ext/libsass/{constants.hpp → src/constants.hpp} +7 -0
  42. data/ext/libsass/{context.cpp → src/context.cpp} +152 -122
  43. data/ext/libsass/src/context.hpp +150 -0
  44. data/ext/libsass/{cssize.cpp → src/cssize.cpp} +123 -109
  45. data/ext/libsass/{cssize.hpp → src/cssize.hpp} +9 -13
  46. data/ext/libsass/{debug.hpp → src/debug.hpp} +9 -9
  47. data/ext/libsass/src/debugger.hpp +683 -0
  48. data/ext/libsass/{emitter.cpp → src/emitter.cpp} +13 -13
  49. data/ext/libsass/{emitter.hpp → src/emitter.hpp} +10 -11
  50. data/ext/libsass/src/environment.cpp +184 -0
  51. data/ext/libsass/src/environment.hpp +92 -0
  52. data/ext/libsass/src/error_handling.cpp +46 -0
  53. data/ext/libsass/src/error_handling.hpp +34 -0
  54. data/ext/libsass/src/eval.cpp +1462 -0
  55. data/ext/libsass/src/eval.hpp +107 -0
  56. data/ext/libsass/src/expand.cpp +653 -0
  57. data/ext/libsass/{expand.hpp → src/expand.hpp} +17 -16
  58. data/ext/libsass/{extend.cpp → src/extend.cpp} +198 -139
  59. data/ext/libsass/{extend.hpp → src/extend.hpp} +7 -8
  60. data/ext/libsass/{file.cpp → src/file.cpp} +103 -57
  61. data/ext/libsass/{file.hpp → src/file.hpp} +23 -14
  62. data/ext/libsass/{functions.cpp → src/functions.cpp} +642 -333
  63. data/ext/libsass/{functions.hpp → src/functions.hpp} +17 -4
  64. data/ext/libsass/{inspect.cpp → src/inspect.cpp} +147 -260
  65. data/ext/libsass/{inspect.hpp → src/inspect.hpp} +7 -7
  66. data/ext/libsass/{json.cpp → src/json.cpp} +33 -43
  67. data/ext/libsass/{json.hpp → src/json.hpp} +1 -1
  68. data/ext/libsass/{kwd_arg_macros.hpp → src/kwd_arg_macros.hpp} +0 -0
  69. data/ext/libsass/{lexer.cpp → src/lexer.cpp} +28 -0
  70. data/ext/libsass/{lexer.hpp → src/lexer.hpp} +25 -10
  71. data/ext/libsass/{listize.cpp → src/listize.cpp} +17 -13
  72. data/ext/libsass/{listize.hpp → src/listize.hpp} +0 -2
  73. data/ext/libsass/{mapping.hpp → src/mapping.hpp} +0 -0
  74. data/ext/libsass/src/memory_manager.cpp +76 -0
  75. data/ext/libsass/src/memory_manager.hpp +48 -0
  76. data/ext/libsass/{node.cpp → src/node.cpp} +89 -18
  77. data/ext/libsass/{node.hpp → src/node.hpp} +5 -6
  78. data/ext/libsass/{operation.hpp → src/operation.hpp} +18 -12
  79. data/ext/libsass/{output.cpp → src/output.cpp} +47 -55
  80. data/ext/libsass/{output.hpp → src/output.hpp} +5 -4
  81. data/ext/libsass/src/parser.cpp +2529 -0
  82. data/ext/libsass/{parser.hpp → src/parser.hpp} +84 -60
  83. data/ext/libsass/{paths.hpp → src/paths.hpp} +10 -13
  84. data/ext/libsass/{plugins.cpp → src/plugins.cpp} +14 -17
  85. data/ext/libsass/{plugins.hpp → src/plugins.hpp} +10 -11
  86. data/ext/libsass/{position.cpp → src/position.cpp} +5 -6
  87. data/ext/libsass/{position.hpp → src/position.hpp} +19 -22
  88. data/ext/libsass/{prelexer.cpp → src/prelexer.cpp} +401 -53
  89. data/ext/libsass/{prelexer.hpp → src/prelexer.hpp} +50 -10
  90. data/ext/libsass/{remove_placeholders.cpp → src/remove_placeholders.cpp} +12 -16
  91. data/ext/libsass/{remove_placeholders.hpp → src/remove_placeholders.hpp} +1 -7
  92. data/ext/libsass/{sass.cpp → src/sass.cpp} +3 -5
  93. data/ext/libsass/{sass2scss.cpp → src/sass2scss.cpp} +51 -46
  94. data/ext/libsass/{sass_context.cpp → src/sass_context.cpp} +114 -112
  95. data/ext/libsass/{sass_functions.cpp → src/sass_functions.cpp} +11 -18
  96. data/ext/libsass/{sass_interface.cpp → src/sass_interface.cpp} +44 -81
  97. data/ext/libsass/{sass_util.cpp → src/sass_util.cpp} +26 -8
  98. data/ext/libsass/{sass_util.hpp → src/sass_util.hpp} +14 -18
  99. data/ext/libsass/{sass_values.cpp → src/sass_values.cpp} +91 -20
  100. data/ext/libsass/{source_map.cpp → src/source_map.cpp} +13 -13
  101. data/ext/libsass/{source_map.hpp → src/source_map.hpp} +9 -9
  102. data/ext/libsass/{subset_map.hpp → src/subset_map.hpp} +29 -31
  103. data/ext/libsass/{support → src/support}/libsass.pc.in +0 -0
  104. data/ext/libsass/src/to_c.cpp +73 -0
  105. data/ext/libsass/src/to_c.hpp +41 -0
  106. data/ext/libsass/src/to_string.cpp +47 -0
  107. data/ext/libsass/{to_string.hpp → src/to_string.hpp} +9 -7
  108. data/ext/libsass/src/to_value.cpp +109 -0
  109. data/ext/libsass/src/to_value.hpp +50 -0
  110. data/ext/libsass/{units.cpp → src/units.cpp} +56 -51
  111. data/ext/libsass/{units.hpp → src/units.hpp} +8 -9
  112. data/ext/libsass/{utf8.h → src/utf8.h} +0 -0
  113. data/ext/libsass/{utf8 → src/utf8}/checked.h +0 -0
  114. data/ext/libsass/{utf8 → src/utf8}/core.h +12 -12
  115. data/ext/libsass/{utf8 → src/utf8}/unchecked.h +0 -0
  116. data/ext/libsass/{utf8_string.cpp → src/utf8_string.cpp} +0 -0
  117. data/ext/libsass/{utf8_string.hpp → src/utf8_string.hpp} +6 -6
  118. data/ext/libsass/{util.cpp → src/util.cpp} +144 -86
  119. data/ext/libsass/src/util.hpp +59 -0
  120. data/ext/libsass/src/values.cpp +137 -0
  121. data/ext/libsass/src/values.hpp +12 -0
  122. data/ext/libsass/test/test_node.cpp +33 -33
  123. data/ext/libsass/test/test_paths.cpp +5 -6
  124. data/ext/libsass/test/test_selector_difference.cpp +4 -5
  125. data/ext/libsass/test/test_specificity.cpp +4 -5
  126. data/ext/libsass/test/test_subset_map.cpp +91 -91
  127. data/ext/libsass/test/test_superselector.cpp +11 -11
  128. data/ext/libsass/test/test_unification.cpp +4 -4
  129. data/ext/libsass/win/libsass.targets +101 -0
  130. data/ext/libsass/win/libsass.vcxproj +45 -127
  131. data/ext/libsass/win/libsass.vcxproj.filters +303 -0
  132. data/lib/sassc/import_handler.rb +1 -1
  133. data/lib/sassc/native/native_functions_api.rb +3 -3
  134. data/lib/sassc/version.rb +1 -1
  135. data/test/custom_importer_test.rb +1 -4
  136. data/test/functions_test.rb +3 -2
  137. data/test/native_test.rb +4 -3
  138. metadata +117 -110
  139. data/ext/libsass/Makefile.am +0 -146
  140. data/ext/libsass/ast.cpp +0 -945
  141. data/ext/libsass/ast_def_macros.hpp +0 -21
  142. data/ext/libsass/ast_factory.hpp +0 -92
  143. data/ext/libsass/color_names.hpp +0 -327
  144. data/ext/libsass/context.hpp +0 -157
  145. data/ext/libsass/contextualize.cpp +0 -148
  146. data/ext/libsass/contextualize.hpp +0 -46
  147. data/ext/libsass/contextualize_eval.cpp +0 -93
  148. data/ext/libsass/contextualize_eval.hpp +0 -44
  149. data/ext/libsass/debugger.hpp +0 -558
  150. data/ext/libsass/environment.hpp +0 -163
  151. data/ext/libsass/error_handling.cpp +0 -35
  152. data/ext/libsass/error_handling.hpp +0 -32
  153. data/ext/libsass/eval.cpp +0 -1392
  154. data/ext/libsass/eval.hpp +0 -88
  155. data/ext/libsass/expand.cpp +0 -575
  156. data/ext/libsass/memory_manager.hpp +0 -57
  157. data/ext/libsass/parser.cpp +0 -2403
  158. data/ext/libsass/posix/getopt.c +0 -562
  159. data/ext/libsass/posix/getopt.h +0 -95
  160. data/ext/libsass/to_c.cpp +0 -61
  161. data/ext/libsass/to_c.hpp +0 -44
  162. data/ext/libsass/to_string.cpp +0 -34
  163. data/ext/libsass/util.hpp +0 -54
  164. data/ext/libsass/win/libsass.filters +0 -312
@@ -1,15 +1,12 @@
1
1
  #ifndef SASS_INSPECT_H
2
2
  #define SASS_INSPECT_H
3
3
 
4
- #include <string>
5
-
6
4
  #include "position.hpp"
7
5
  #include "operation.hpp"
8
6
  #include "emitter.hpp"
9
7
 
10
8
  namespace Sass {
11
9
  class Context;
12
- using namespace std;
13
10
 
14
11
  class Inspect : public Operation_CRTP<void, Inspect>, public Emitter {
15
12
  protected:
@@ -28,7 +25,7 @@ namespace Sass {
28
25
  virtual void operator()(Ruleset*);
29
26
  virtual void operator()(Propset*);
30
27
  virtual void operator()(Bubble*);
31
- virtual void operator()(Feature_Block*);
28
+ virtual void operator()(Supports_Block*);
32
29
  virtual void operator()(Media_Block*);
33
30
  virtual void operator()(At_Root_Block*);
34
31
  virtual void operator()(At_Rule*);
@@ -57,6 +54,8 @@ namespace Sass {
57
54
  virtual void operator()(Unary_Expression*);
58
55
  virtual void operator()(Function_Call*);
59
56
  virtual void operator()(Function_Call_Schema*);
57
+ // virtual void operator()(Custom_Warning*);
58
+ // virtual void operator()(Custom_Error*);
60
59
  virtual void operator()(Variable*);
61
60
  virtual void operator()(Textual*);
62
61
  virtual void operator()(Number*);
@@ -65,8 +64,10 @@ namespace Sass {
65
64
  virtual void operator()(String_Schema*);
66
65
  virtual void operator()(String_Constant*);
67
66
  virtual void operator()(String_Quoted*);
68
- virtual void operator()(Feature_Query*);
69
- virtual void operator()(Feature_Query_Condition*);
67
+ virtual void operator()(Supports_Operator*);
68
+ virtual void operator()(Supports_Negation*);
69
+ virtual void operator()(Supports_Declaration*);
70
+ virtual void operator()(Supports_Interpolation*);
70
71
  virtual void operator()(Media_Query*);
71
72
  virtual void operator()(Media_Query_Expression*);
72
73
  virtual void operator()(At_Root_Expression*);
@@ -79,7 +80,6 @@ namespace Sass {
79
80
  virtual void operator()(Arguments*);
80
81
  // selectors
81
82
  virtual void operator()(Selector_Schema*);
82
- virtual void operator()(Selector_Reference*);
83
83
  virtual void operator()(Selector_Placeholder*);
84
84
  virtual void operator()(Type_Selector*);
85
85
  virtual void operator()(Selector_Qualifier*);
@@ -21,6 +21,11 @@
21
21
  THE SOFTWARE.
22
22
  */
23
23
 
24
+ #ifdef _MSC_VER
25
+ #define _CRT_SECURE_NO_WARNINGS
26
+ #define _CRT_NONSTDC_NO_DEPRECATE
27
+ #endif
28
+
24
29
  #include "json.hpp"
25
30
 
26
31
  #include <assert.h>
@@ -29,35 +34,13 @@
29
34
  #include <stdlib.h>
30
35
  #include <string.h>
31
36
 
32
- #ifdef _MSC_VER
33
-
37
+ #if defined(_MSC_VER) && _MSC_VER < 1900
34
38
  #include <stdarg.h>
35
- #define snprintf c99_snprintf
36
-
37
- inline int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap)
38
- {
39
- int count = -1;
40
-
41
- if (size != 0)
42
- count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
43
- if (count == -1)
44
- count = _vscprintf(format, ap);
45
-
46
- return count;
47
- }
48
-
49
- inline int c99_snprintf(char* str, size_t size, const char* format, ...)
50
- {
51
- int count;
52
- va_list ap;
53
-
54
- va_start(ap, format);
55
- count = c99_vsnprintf(str, size, format, ap);
56
- va_end(ap);
57
-
58
- return count;
59
- }
60
- #endif // _MSC_VER
39
+ #ifdef snprintf
40
+ #undef snprintf
41
+ #endif
42
+ extern "C" int snprintf(char *, size_t, const char *, ...);
43
+ #endif
61
44
 
62
45
  #define out_of_memory() do { \
63
46
  fprintf(stderr, "Out of memory.\n"); \
@@ -129,7 +112,7 @@ static void sb_put(SB *sb, const char *bytes, int count)
129
112
 
130
113
  static void sb_puts(SB *sb, const char *str)
131
114
  {
132
- sb_put(sb, str, strlen(str));
115
+ sb_put(sb, str, (int)strlen(str));
133
116
  }
134
117
 
135
118
  static char *sb_finish(SB *sb)
@@ -352,9 +335,8 @@ static void to_surrogate_pair(uint32_t unicode, uint16_t *uc, uint16_t *lc)
352
335
  *lc = (n & 0x3FF) | 0xDC00;
353
336
  }
354
337
 
355
- #define is_space(c) ((c) == '\t' || (c) == '\n' || (c) == '\r' || (c) == ' ')
356
- #define is_digit(c) ((c) >= '0' && (c) <= '9')
357
-
338
+ static bool is_space (const char *c);
339
+ static bool is_digit (const char *c);
358
340
  static bool parse_value (const char **sp, JsonNode **out);
359
341
  static bool parse_string (const char **sp, char **out);
360
342
  static bool parse_number (const char **sp, double *out);
@@ -680,7 +662,7 @@ static bool parse_value(const char **sp, JsonNode **out)
680
662
  return false;
681
663
 
682
664
  case '"': {
683
- char *str;
665
+ char *str = NULL;
684
666
  if (parse_string(&s, out ? &str : NULL)) {
685
667
  if (out)
686
668
  *out = mkstring(str);
@@ -721,7 +703,7 @@ static bool parse_array(const char **sp, JsonNode **out)
721
703
  {
722
704
  const char *s = *sp;
723
705
  JsonNode *ret = out ? json_mkarray() : NULL;
724
- JsonNode *element;
706
+ JsonNode *element = NULL;
725
707
 
726
708
  if (*s++ != '[')
727
709
  goto failure;
@@ -765,8 +747,8 @@ static bool parse_object(const char **sp, JsonNode **out)
765
747
  {
766
748
  const char *s = *sp;
767
749
  JsonNode *ret = out ? json_mkobject() : NULL;
768
- char *key;
769
- JsonNode *value;
750
+ char *key = NULL;
751
+ JsonNode *value = NULL;
770
752
 
771
753
  if (*s++ != '{')
772
754
  goto failure;
@@ -932,6 +914,14 @@ failed:
932
914
  return false;
933
915
  }
934
916
 
917
+ bool is_space(const char *c) {
918
+ return ((*c) == '\t' || (*c) == '\n' || (*c) == '\r' || (*c) == ' ');
919
+ }
920
+
921
+ bool is_digit(const char *c){
922
+ return ((*c) >= '0' && (*c) <= '9');
923
+ }
924
+
935
925
  /*
936
926
  * The JSON spec says that a number shall follow this precise pattern
937
927
  * (spaces and quotes added for readability):
@@ -954,21 +944,21 @@ bool parse_number(const char **sp, double *out)
954
944
  if (*s == '0') {
955
945
  s++;
956
946
  } else {
957
- if (!is_digit(*s))
947
+ if (!is_digit(s))
958
948
  return false;
959
949
  do {
960
950
  s++;
961
- } while (is_digit(*s));
951
+ } while (is_digit(s));
962
952
  }
963
953
 
964
954
  /* ('.' [0-9]+)? */
965
955
  if (*s == '.') {
966
956
  s++;
967
- if (!is_digit(*s))
957
+ if (!is_digit(s))
968
958
  return false;
969
959
  do {
970
960
  s++;
971
- } while (is_digit(*s));
961
+ } while (is_digit(s));
972
962
  }
973
963
 
974
964
  /* ([Ee] [+-]? [0-9]+)? */
@@ -976,11 +966,11 @@ bool parse_number(const char **sp, double *out)
976
966
  s++;
977
967
  if (*s == '+' || *s == '-')
978
968
  s++;
979
- if (!is_digit(*s))
969
+ if (!is_digit(s))
980
970
  return false;
981
971
  do {
982
972
  s++;
983
- } while (is_digit(*s));
973
+ } while (is_digit(s));
984
974
  }
985
975
 
986
976
  if (out)
@@ -993,7 +983,7 @@ bool parse_number(const char **sp, double *out)
993
983
  static void skip_space(const char **sp)
994
984
  {
995
985
  const char *s = *sp;
996
- while (is_space(*s))
986
+ while (is_space(s))
997
987
  s++;
998
988
  *sp = s;
999
989
  }
@@ -114,4 +114,4 @@ void json_remove_from_parent(JsonNode *node);
114
114
  */
115
115
  bool json_check(const JsonNode *node, char errmsg[256]);
116
116
 
117
- #endif
117
+ #endif
@@ -75,6 +75,24 @@ namespace Sass {
75
75
  return unsigned(chr) > 127;
76
76
  }
77
77
 
78
+ // check if char is outside ascii range
79
+ // but with specific ranges (copied from Ruby Sass)
80
+ bool is_nonascii(const char& chr)
81
+ {
82
+ return (
83
+ (unsigned(chr) > 127 && unsigned(chr) < 55296) ||
84
+ (unsigned(chr) > 57343 && unsigned(chr) < 65534) ||
85
+ (unsigned(chr) > 65535 && unsigned(chr) < 1114111)
86
+ );
87
+ }
88
+
89
+ // check if char is within a reduced ascii range
90
+ // valid in a uri (copied from Ruby Sass)
91
+ bool is_uri_character(const char& chr)
92
+ {
93
+ return unsigned(chr) > 41 && unsigned(chr) < 127;
94
+ }
95
+
78
96
  // Match word character (look ahead)
79
97
  bool is_character(const char& chr)
80
98
  {
@@ -90,11 +108,13 @@ namespace Sass {
90
108
  const char* space(const char* src) { return is_space(*src) ? src + 1 : 0; }
91
109
  const char* alpha(const char* src) { return is_alpha(*src) ? src + 1 : 0; }
92
110
  const char* unicode(const char* src) { return is_unicode(*src) ? src + 1 : 0; }
111
+ const char* nonascii(const char* src) { return is_nonascii(*src) ? src + 1 : 0; }
93
112
  const char* digit(const char* src) { return is_digit(*src) ? src + 1 : 0; }
94
113
  const char* xdigit(const char* src) { return is_xdigit(*src) ? src + 1 : 0; }
95
114
  const char* alnum(const char* src) { return is_alnum(*src) ? src + 1 : 0; }
96
115
  const char* punct(const char* src) { return is_punct(*src) ? src + 1 : 0; }
97
116
  const char* character(const char* src) { return is_character(*src) ? src + 1 : 0; }
117
+ const char* uri_character(const char* src) { return is_uri_character(*src) ? src + 1 : 0; }
98
118
 
99
119
  // Match multiple ctype characters.
100
120
  const char* spaces(const char* src) { return one_plus<space>(src); }
@@ -129,5 +149,13 @@ namespace Sass {
129
149
  return *src == 0 || *src == '\n' || *src == '\r' ? src : 0;
130
150
  }
131
151
 
152
+ // Assert end_of_file boundary (/\z/)
153
+ // This is a zero-width positive lookahead
154
+ const char* end_of_file(const char* src)
155
+ {
156
+ // end of file or unix linefeed return here
157
+ return *src == 0 ? src : 0;
158
+ }
159
+
132
160
  }
133
161
  }
@@ -32,7 +32,9 @@ namespace Sass {
32
32
  bool is_alnum(const char& src);
33
33
  bool is_xdigit(const char& src);
34
34
  bool is_unicode(const char& src);
35
+ bool is_nonascii(const char& src);
35
36
  bool is_character(const char& src);
37
+ bool is_uri_character(const char& src);
36
38
 
37
39
  // Match a single ctype predicate.
38
40
  const char* space(const char* src);
@@ -42,7 +44,9 @@ namespace Sass {
42
44
  const char* alnum(const char* src);
43
45
  const char* punct(const char* src);
44
46
  const char* unicode(const char* src);
47
+ const char* nonascii(const char* src);
45
48
  const char* character(const char* src);
49
+ const char* uri_character(const char* src);
46
50
 
47
51
  // Match multiple ctype characters.
48
52
  const char* spaces(const char* src);
@@ -65,7 +69,9 @@ namespace Sass {
65
69
  // Assert string boundaries (/\Z|\z|\A/)
66
70
  // There are zero-width positive lookaheads
67
71
  const char* end_of_line(const char* src);
68
- // const char* end_of_string(const char* src);
72
+
73
+ // Assert end_of_file boundary (/\z/)
74
+ const char* end_of_file(const char* src);
69
75
  // const char* start_of_string(const char* src);
70
76
 
71
77
  // Type definition for prelexer functions
@@ -107,7 +113,7 @@ namespace Sass {
107
113
  }
108
114
 
109
115
  // Match for members of char class.
110
- // Regex equivalent: /[axy]/
116
+ // Regex equivalent: /[axy]+/
111
117
  template <const char* char_class>
112
118
  const char* class_chars(const char* src) {
113
119
  const char* p = src;
@@ -142,26 +148,35 @@ namespace Sass {
142
148
  // Tries supplied matchers in order.
143
149
  // Succeeds if one of them succeeds.
144
150
  // Regex equivalent: /(?:FOO|BAR)/
145
- template <prelexer... mxs>
151
+ template <const prelexer mx>
146
152
  const char* alternatives(const char* src) {
147
153
  const char* rslt;
148
- for (prelexer mx : { mxs... }) {
149
- if ((rslt = mx(src))) return rslt;
150
- }
154
+ if ((rslt = mx(src))) return rslt;
151
155
  return 0;
152
156
  }
157
+ template <const prelexer mx1, const prelexer mx2, const prelexer... mxs>
158
+ const char* alternatives(const char* src) {
159
+ const char* rslt;
160
+ if ((rslt = mx1(src))) return rslt;
161
+ return alternatives<mx2, mxs...>(src);
162
+ }
153
163
 
154
164
  // Tries supplied matchers in order.
155
165
  // Succeeds if all of them succeeds.
156
166
  // Regex equivalent: /(?:FOO)(?:BAR)/
157
- template <prelexer... mxs>
167
+ template <const prelexer mx1>
158
168
  const char* sequence(const char* src) {
159
169
  const char* rslt = src;
160
- for (prelexer mx : { mxs... }) {
161
- if (!(rslt = mx(rslt))) return 0;
162
- }
170
+ if (!(rslt = mx1(rslt))) return 0;
163
171
  return rslt;
164
172
  }
173
+ template <const prelexer mx1, const prelexer mx2, const prelexer... mxs>
174
+ const char* sequence(const char* src) {
175
+ const char* rslt = src;
176
+ if (!(rslt = mx1(rslt))) return 0;
177
+ return sequence<mx2, mxs...>(rslt);
178
+ }
179
+
165
180
 
166
181
  // Match a pattern or not. Always succeeds.
167
182
  // Regex equivalent: /(?:literal)?/
@@ -1,5 +1,6 @@
1
1
  #include <iostream>
2
2
  #include <typeinfo>
3
+ #include <string>
3
4
 
4
5
  #include "listize.hpp"
5
6
  #include "to_string.hpp"
@@ -15,8 +16,9 @@ namespace Sass {
15
16
 
16
17
  Expression* Listize::operator()(Selector_List* sel)
17
18
  {
18
- List* l = new (ctx.mem) List(sel->pstate(), sel->length(), List::COMMA);
19
+ List* l = SASS_MEMORY_NEW(ctx.mem, List, sel->pstate(), sel->length(), SASS_COMMA);
19
20
  for (size_t i = 0, L = sel->length(); i < L; ++i) {
21
+ if (!(*sel)[i]) continue;
20
22
  *l << (*sel)[i]->perform(this);
21
23
  }
22
24
  return l;
@@ -25,17 +27,17 @@ namespace Sass {
25
27
  Expression* Listize::operator()(Compound_Selector* sel)
26
28
  {
27
29
  To_String to_string;
28
- string str;
30
+ std::string str;
29
31
  for (size_t i = 0, L = sel->length(); i < L; ++i) {
30
32
  Expression* e = (*sel)[i]->perform(this);
31
33
  if (e) str += e->perform(&to_string);
32
34
  }
33
- return new (ctx.mem) String_Constant(sel->pstate(), str);
35
+ return SASS_MEMORY_NEW(ctx.mem, String_Quoted, sel->pstate(), str);
34
36
  }
35
37
 
36
38
  Expression* Listize::operator()(Complex_Selector* sel)
37
39
  {
38
- List* l = new (ctx.mem) List(sel->pstate(), 2);
40
+ List* l = SASS_MEMORY_NEW(ctx.mem, List, sel->pstate(), 2);
39
41
 
40
42
  Compound_Selector* head = sel->head();
41
43
  if (head && !head->is_empty_reference())
@@ -44,16 +46,22 @@ namespace Sass {
44
46
  if (hh) *l << hh;
45
47
  }
46
48
 
49
+ To_String to_string;
50
+ std::string reference = ! sel->reference() ? ""
51
+ : sel->reference()->perform(&to_string);
47
52
  switch(sel->combinator())
48
53
  {
49
54
  case Complex_Selector::PARENT_OF:
50
- *l << new (ctx.mem) String_Constant(sel->pstate(), ">");
55
+ *l << SASS_MEMORY_NEW(ctx.mem, String_Quoted, sel->pstate(), ">");
51
56
  break;
52
57
  case Complex_Selector::ADJACENT_TO:
53
- *l << new (ctx.mem) String_Constant(sel->pstate(), "+");
58
+ *l << SASS_MEMORY_NEW(ctx.mem, String_Quoted, sel->pstate(), "+");
59
+ break;
60
+ case Complex_Selector::REFERENCE:
61
+ *l << SASS_MEMORY_NEW(ctx.mem, String_Quoted, sel->pstate(), "/" + reference + "/");
54
62
  break;
55
63
  case Complex_Selector::PRECEDES:
56
- *l << new (ctx.mem) String_Constant(sel->pstate(), "~");
64
+ *l << SASS_MEMORY_NEW(ctx.mem, String_Quoted, sel->pstate(), "~");
57
65
  break;
58
66
  case Complex_Selector::ANCESTOR_OF:
59
67
  break;
@@ -71,13 +79,9 @@ namespace Sass {
71
79
  return l;
72
80
  }
73
81
 
74
- Expression* Listize::operator()(Selector_Reference* sel)
75
- {
76
- return 0;
77
- }
78
-
79
82
  Expression* Listize::fallback_impl(AST_Node* n)
80
83
  {
81
- return static_cast<Expression*>(n);
84
+ return dynamic_cast<Expression*>(n);
82
85
  }
86
+
83
87
  }
@@ -10,7 +10,6 @@
10
10
  #include "environment.hpp"
11
11
 
12
12
  namespace Sass {
13
- using namespace std;
14
13
 
15
14
  typedef Environment<AST_Node*> Env;
16
15
  struct Backtrace;
@@ -30,7 +29,6 @@ namespace Sass {
30
29
  Expression* operator()(Selector_List*);
31
30
  Expression* operator()(Complex_Selector*);
32
31
  Expression* operator()(Compound_Selector*);
33
- Expression* operator()(Selector_Reference*);
34
32
 
35
33
  template <typename U>
36
34
  Expression* fallback(U x) { return fallback_impl(x); }