sassc4 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.gitmodules +3 -0
- data/.travis.yml +16 -0
- data/CHANGELOG.md +97 -0
- data/CODE_OF_CONDUCT.md +10 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +80 -0
- data/Rakefile +51 -0
- data/ext/depend +4 -0
- data/ext/extconf.rb +92 -0
- data/ext/libsass/VERSION +1 -0
- data/ext/libsass/contrib/plugin.cpp +60 -0
- data/ext/libsass/include/sass/base.h +97 -0
- data/ext/libsass/include/sass/context.h +174 -0
- data/ext/libsass/include/sass/functions.h +139 -0
- data/ext/libsass/include/sass/values.h +145 -0
- data/ext/libsass/include/sass/version.h +12 -0
- data/ext/libsass/include/sass.h +15 -0
- data/ext/libsass/include/sass2scss.h +120 -0
- data/ext/libsass/src/MurmurHash2.hpp +91 -0
- data/ext/libsass/src/ast.cpp +953 -0
- data/ext/libsass/src/ast.hpp +1064 -0
- data/ext/libsass/src/ast2c.cpp +80 -0
- data/ext/libsass/src/ast2c.hpp +39 -0
- data/ext/libsass/src/ast_def_macros.hpp +140 -0
- data/ext/libsass/src/ast_fwd_decl.cpp +31 -0
- data/ext/libsass/src/ast_fwd_decl.hpp +274 -0
- data/ext/libsass/src/ast_helpers.hpp +316 -0
- data/ext/libsass/src/ast_sel_cmp.cpp +396 -0
- data/ext/libsass/src/ast_sel_super.cpp +539 -0
- data/ext/libsass/src/ast_sel_unify.cpp +275 -0
- data/ext/libsass/src/ast_sel_weave.cpp +616 -0
- data/ext/libsass/src/ast_selectors.cpp +1070 -0
- data/ext/libsass/src/ast_selectors.hpp +523 -0
- data/ext/libsass/src/ast_supports.cpp +114 -0
- data/ext/libsass/src/ast_supports.hpp +121 -0
- data/ext/libsass/src/ast_values.cpp +1154 -0
- data/ext/libsass/src/ast_values.hpp +498 -0
- data/ext/libsass/src/b64/cencode.h +32 -0
- data/ext/libsass/src/b64/encode.h +79 -0
- data/ext/libsass/src/backtrace.cpp +50 -0
- data/ext/libsass/src/backtrace.hpp +29 -0
- data/ext/libsass/src/base64vlq.cpp +47 -0
- data/ext/libsass/src/base64vlq.hpp +30 -0
- data/ext/libsass/src/bind.cpp +312 -0
- data/ext/libsass/src/bind.hpp +15 -0
- data/ext/libsass/src/c2ast.cpp +64 -0
- data/ext/libsass/src/c2ast.hpp +14 -0
- data/ext/libsass/src/c99func.c +54 -0
- data/ext/libsass/src/cencode.c +106 -0
- data/ext/libsass/src/check_nesting.cpp +393 -0
- data/ext/libsass/src/check_nesting.hpp +70 -0
- data/ext/libsass/src/color_maps.cpp +652 -0
- data/ext/libsass/src/color_maps.hpp +323 -0
- data/ext/libsass/src/color_spaces.cpp +241 -0
- data/ext/libsass/src/color_spaces.hpp +227 -0
- data/ext/libsass/src/constants.cpp +199 -0
- data/ext/libsass/src/constants.hpp +200 -0
- data/ext/libsass/src/context.cpp +870 -0
- data/ext/libsass/src/context.hpp +140 -0
- data/ext/libsass/src/cssize.cpp +521 -0
- data/ext/libsass/src/cssize.hpp +71 -0
- data/ext/libsass/src/dart_helpers.hpp +199 -0
- data/ext/libsass/src/debug.hpp +43 -0
- data/ext/libsass/src/debugger.hpp +964 -0
- data/ext/libsass/src/emitter.cpp +297 -0
- data/ext/libsass/src/emitter.hpp +101 -0
- data/ext/libsass/src/environment.cpp +260 -0
- data/ext/libsass/src/environment.hpp +124 -0
- data/ext/libsass/src/error_handling.cpp +239 -0
- data/ext/libsass/src/error_handling.hpp +248 -0
- data/ext/libsass/src/eval.cpp +1543 -0
- data/ext/libsass/src/eval.hpp +110 -0
- data/ext/libsass/src/eval_selectors.cpp +75 -0
- data/ext/libsass/src/expand.cpp +875 -0
- data/ext/libsass/src/expand.hpp +98 -0
- data/ext/libsass/src/extender.cpp +1226 -0
- data/ext/libsass/src/extender.hpp +399 -0
- data/ext/libsass/src/extension.cpp +43 -0
- data/ext/libsass/src/extension.hpp +89 -0
- data/ext/libsass/src/file.cpp +531 -0
- data/ext/libsass/src/file.hpp +124 -0
- data/ext/libsass/src/fn_colors.cpp +836 -0
- data/ext/libsass/src/fn_colors.hpp +99 -0
- data/ext/libsass/src/fn_lists.cpp +285 -0
- data/ext/libsass/src/fn_lists.hpp +34 -0
- data/ext/libsass/src/fn_maps.cpp +94 -0
- data/ext/libsass/src/fn_maps.hpp +30 -0
- data/ext/libsass/src/fn_miscs.cpp +248 -0
- data/ext/libsass/src/fn_miscs.hpp +40 -0
- data/ext/libsass/src/fn_numbers.cpp +246 -0
- data/ext/libsass/src/fn_numbers.hpp +45 -0
- data/ext/libsass/src/fn_selectors.cpp +205 -0
- data/ext/libsass/src/fn_selectors.hpp +35 -0
- data/ext/libsass/src/fn_strings.cpp +268 -0
- data/ext/libsass/src/fn_strings.hpp +34 -0
- data/ext/libsass/src/fn_utils.cpp +159 -0
- data/ext/libsass/src/fn_utils.hpp +62 -0
- data/ext/libsass/src/inspect.cpp +1126 -0
- data/ext/libsass/src/inspect.hpp +101 -0
- data/ext/libsass/src/json.cpp +1436 -0
- data/ext/libsass/src/json.hpp +117 -0
- data/ext/libsass/src/kwd_arg_macros.hpp +28 -0
- data/ext/libsass/src/lexer.cpp +122 -0
- data/ext/libsass/src/lexer.hpp +304 -0
- data/ext/libsass/src/listize.cpp +70 -0
- data/ext/libsass/src/listize.hpp +37 -0
- data/ext/libsass/src/mapping.hpp +19 -0
- data/ext/libsass/src/memory/allocator.cpp +48 -0
- data/ext/libsass/src/memory/allocator.hpp +138 -0
- data/ext/libsass/src/memory/config.hpp +20 -0
- data/ext/libsass/src/memory/memory_pool.hpp +186 -0
- data/ext/libsass/src/memory/shared_ptr.cpp +33 -0
- data/ext/libsass/src/memory/shared_ptr.hpp +332 -0
- data/ext/libsass/src/memory.hpp +12 -0
- data/ext/libsass/src/operation.hpp +223 -0
- data/ext/libsass/src/operators.cpp +267 -0
- data/ext/libsass/src/operators.hpp +30 -0
- data/ext/libsass/src/ordered_map.hpp +112 -0
- data/ext/libsass/src/output.cpp +320 -0
- data/ext/libsass/src/output.hpp +47 -0
- data/ext/libsass/src/parser.cpp +3059 -0
- data/ext/libsass/src/parser.hpp +395 -0
- data/ext/libsass/src/parser_selectors.cpp +189 -0
- data/ext/libsass/src/permutate.hpp +164 -0
- data/ext/libsass/src/plugins.cpp +188 -0
- data/ext/libsass/src/plugins.hpp +57 -0
- data/ext/libsass/src/position.cpp +163 -0
- data/ext/libsass/src/position.hpp +147 -0
- data/ext/libsass/src/prelexer.cpp +1780 -0
- data/ext/libsass/src/prelexer.hpp +484 -0
- data/ext/libsass/src/remove_placeholders.cpp +86 -0
- data/ext/libsass/src/remove_placeholders.hpp +37 -0
- data/ext/libsass/src/sass.cpp +156 -0
- data/ext/libsass/src/sass.hpp +147 -0
- data/ext/libsass/src/sass2scss.cpp +895 -0
- data/ext/libsass/src/sass_context.cpp +742 -0
- data/ext/libsass/src/sass_context.hpp +129 -0
- data/ext/libsass/src/sass_functions.cpp +210 -0
- data/ext/libsass/src/sass_functions.hpp +50 -0
- data/ext/libsass/src/sass_values.cpp +362 -0
- data/ext/libsass/src/sass_values.hpp +82 -0
- data/ext/libsass/src/settings.hpp +19 -0
- data/ext/libsass/src/source.cpp +69 -0
- data/ext/libsass/src/source.hpp +95 -0
- data/ext/libsass/src/source_data.hpp +32 -0
- data/ext/libsass/src/source_map.cpp +202 -0
- data/ext/libsass/src/source_map.hpp +65 -0
- data/ext/libsass/src/stylesheet.cpp +22 -0
- data/ext/libsass/src/stylesheet.hpp +57 -0
- data/ext/libsass/src/to_value.cpp +114 -0
- data/ext/libsass/src/to_value.hpp +46 -0
- data/ext/libsass/src/units.cpp +507 -0
- data/ext/libsass/src/units.hpp +110 -0
- data/ext/libsass/src/utf8/checked.h +336 -0
- data/ext/libsass/src/utf8/core.h +332 -0
- data/ext/libsass/src/utf8/unchecked.h +235 -0
- data/ext/libsass/src/utf8.h +34 -0
- data/ext/libsass/src/utf8_string.cpp +104 -0
- data/ext/libsass/src/utf8_string.hpp +38 -0
- data/ext/libsass/src/util.cpp +723 -0
- data/ext/libsass/src/util.hpp +105 -0
- data/ext/libsass/src/util_string.cpp +125 -0
- data/ext/libsass/src/util_string.hpp +73 -0
- data/ext/libsass/src/values.cpp +140 -0
- data/ext/libsass/src/values.hpp +12 -0
- data/lib/sassc/dependency.rb +17 -0
- data/lib/sassc/engine.rb +141 -0
- data/lib/sassc/error.rb +37 -0
- data/lib/sassc/functions_handler.rb +73 -0
- data/lib/sassc/import_handler.rb +50 -0
- data/lib/sassc/importer.rb +31 -0
- data/lib/sassc/native/native_context_api.rb +147 -0
- data/lib/sassc/native/native_functions_api.rb +159 -0
- data/lib/sassc/native/sass2scss_api.rb +10 -0
- data/lib/sassc/native/sass_input_style.rb +13 -0
- data/lib/sassc/native/sass_output_style.rb +12 -0
- data/lib/sassc/native/sass_value.rb +97 -0
- data/lib/sassc/native/string_list.rb +10 -0
- data/lib/sassc/native.rb +64 -0
- data/lib/sassc/sass_2_scss.rb +9 -0
- data/lib/sassc/script/functions.rb +8 -0
- data/lib/sassc/script/value/bool.rb +32 -0
- data/lib/sassc/script/value/color.rb +95 -0
- data/lib/sassc/script/value/list.rb +136 -0
- data/lib/sassc/script/value/map.rb +69 -0
- data/lib/sassc/script/value/number.rb +389 -0
- data/lib/sassc/script/value/string.rb +96 -0
- data/lib/sassc/script/value.rb +137 -0
- data/lib/sassc/script/value_conversion/base.rb +13 -0
- data/lib/sassc/script/value_conversion/bool.rb +13 -0
- data/lib/sassc/script/value_conversion/color.rb +18 -0
- data/lib/sassc/script/value_conversion/list.rb +25 -0
- data/lib/sassc/script/value_conversion/map.rb +21 -0
- data/lib/sassc/script/value_conversion/number.rb +13 -0
- data/lib/sassc/script/value_conversion/string.rb +17 -0
- data/lib/sassc/script/value_conversion.rb +69 -0
- data/lib/sassc/script.rb +17 -0
- data/lib/sassc/util/normalized_map.rb +117 -0
- data/lib/sassc/util.rb +231 -0
- data/lib/sassc/version.rb +5 -0
- data/lib/sassc.rb +57 -0
- data/sassc.gemspec +69 -0
- data/test/css_color_level4_test.rb +168 -0
- data/test/custom_importer_test.rb +127 -0
- data/test/engine_test.rb +314 -0
- data/test/error_test.rb +29 -0
- data/test/fixtures/paths.scss +10 -0
- data/test/functions_test.rb +340 -0
- data/test/native_test.rb +213 -0
- data/test/output_style_test.rb +107 -0
- data/test/sass_2_scss_test.rb +14 -0
- data/test/test_helper.rb +45 -0
- metadata +396 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#ifndef SASS_ENVIRONMENT_H
|
|
2
|
+
#define SASS_ENVIRONMENT_H
|
|
3
|
+
|
|
4
|
+
// sass.hpp must go before all system headers to get the
|
|
5
|
+
// __EXTENSIONS__ fix on Solaris.
|
|
6
|
+
#include "sass.hpp"
|
|
7
|
+
|
|
8
|
+
#include <map>
|
|
9
|
+
#include <string>
|
|
10
|
+
#include "ast_fwd_decl.hpp"
|
|
11
|
+
#include "ast_def_macros.hpp"
|
|
12
|
+
|
|
13
|
+
namespace Sass {
|
|
14
|
+
|
|
15
|
+
// this defeats the whole purpose of environment being templatable!!
|
|
16
|
+
typedef environment_map<sass::string, AST_Node_Obj>::iterator EnvIter;
|
|
17
|
+
|
|
18
|
+
class EnvResult {
|
|
19
|
+
public:
|
|
20
|
+
EnvIter it;
|
|
21
|
+
bool found;
|
|
22
|
+
public:
|
|
23
|
+
EnvResult(EnvIter it, bool found)
|
|
24
|
+
: it(it), found(found) {}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
template <typename T>
|
|
28
|
+
class Environment {
|
|
29
|
+
// TODO: test with map
|
|
30
|
+
environment_map<sass::string, T> local_frame_;
|
|
31
|
+
ADD_PROPERTY(Environment*, parent)
|
|
32
|
+
ADD_PROPERTY(bool, is_shadow)
|
|
33
|
+
|
|
34
|
+
public:
|
|
35
|
+
Environment(bool is_shadow = false);
|
|
36
|
+
Environment(Environment* env, bool is_shadow = false);
|
|
37
|
+
Environment(Environment& env, bool is_shadow = false);
|
|
38
|
+
|
|
39
|
+
// link parent to create a stack
|
|
40
|
+
void link(Environment& env);
|
|
41
|
+
void link(Environment* env);
|
|
42
|
+
|
|
43
|
+
// this is used to find the global frame
|
|
44
|
+
// which is the second last on the stack
|
|
45
|
+
bool is_lexical() const;
|
|
46
|
+
|
|
47
|
+
// only match the real root scope
|
|
48
|
+
// there is still a parent around
|
|
49
|
+
// not sure what it is actually use for
|
|
50
|
+
// I guess we store functions etc. there
|
|
51
|
+
bool is_global() const;
|
|
52
|
+
|
|
53
|
+
// scope operates on the current frame
|
|
54
|
+
|
|
55
|
+
environment_map<sass::string, T>& local_frame();
|
|
56
|
+
|
|
57
|
+
bool has_local(const sass::string& key) const;
|
|
58
|
+
|
|
59
|
+
EnvResult find_local(const sass::string& key);
|
|
60
|
+
|
|
61
|
+
T& get_local(const sass::string& key);
|
|
62
|
+
|
|
63
|
+
// set variable on the current frame
|
|
64
|
+
void set_local(const sass::string& key, const T& val);
|
|
65
|
+
void set_local(const sass::string& key, T&& val);
|
|
66
|
+
|
|
67
|
+
void del_local(const sass::string& key);
|
|
68
|
+
|
|
69
|
+
// global operates on the global frame
|
|
70
|
+
// which is the second last on the stack
|
|
71
|
+
Environment* global_env();
|
|
72
|
+
// get the env where the variable already exists
|
|
73
|
+
// if it does not yet exist, we return current env
|
|
74
|
+
Environment* lexical_env(const sass::string& key);
|
|
75
|
+
|
|
76
|
+
bool has_global(const sass::string& key);
|
|
77
|
+
|
|
78
|
+
T& get_global(const sass::string& key);
|
|
79
|
+
|
|
80
|
+
// set a variable on the global frame
|
|
81
|
+
void set_global(const sass::string& key, const T& val);
|
|
82
|
+
void set_global(const sass::string& key, T&& val);
|
|
83
|
+
|
|
84
|
+
void del_global(const sass::string& key);
|
|
85
|
+
|
|
86
|
+
// see if we have a lexical variable
|
|
87
|
+
// move down the stack but stop before we
|
|
88
|
+
// reach the global frame (is not included)
|
|
89
|
+
bool has_lexical(const sass::string& key) const;
|
|
90
|
+
|
|
91
|
+
// see if we have a lexical we could update
|
|
92
|
+
// either update already existing lexical value
|
|
93
|
+
// or we create a new one on the current frame
|
|
94
|
+
void set_lexical(const sass::string& key, T&& val);
|
|
95
|
+
void set_lexical(const sass::string& key, const T& val);
|
|
96
|
+
|
|
97
|
+
// look on the full stack for key
|
|
98
|
+
// include all scopes available
|
|
99
|
+
bool has(const sass::string& key) const;
|
|
100
|
+
|
|
101
|
+
// look on the full stack for key
|
|
102
|
+
// include all scopes available
|
|
103
|
+
T& get(const sass::string& key);
|
|
104
|
+
|
|
105
|
+
// look on the full stack for key
|
|
106
|
+
// include all scopes available
|
|
107
|
+
EnvResult find(const sass::string& key);
|
|
108
|
+
|
|
109
|
+
// use array access for getter and setter functions
|
|
110
|
+
T& operator[](const sass::string& key);
|
|
111
|
+
|
|
112
|
+
#ifdef DEBUG
|
|
113
|
+
size_t print(sass::string prefix = "");
|
|
114
|
+
#endif
|
|
115
|
+
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// define typedef for our use case
|
|
119
|
+
typedef Environment<AST_Node_Obj> Env;
|
|
120
|
+
typedef sass::vector<Env*> EnvStack;
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
#endif
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
|
3
|
+
#include "sass.hpp"
|
|
4
|
+
|
|
5
|
+
#include "ast.hpp"
|
|
6
|
+
#include "prelexer.hpp"
|
|
7
|
+
#include "backtrace.hpp"
|
|
8
|
+
#include "error_handling.hpp"
|
|
9
|
+
|
|
10
|
+
#include <iostream>
|
|
11
|
+
|
|
12
|
+
namespace Sass {
|
|
13
|
+
|
|
14
|
+
namespace Exception {
|
|
15
|
+
|
|
16
|
+
Base::Base(SourceSpan pstate, sass::string msg, Backtraces traces)
|
|
17
|
+
: std::runtime_error(msg.c_str()), msg(msg),
|
|
18
|
+
prefix("Error"), pstate(pstate), traces(traces)
|
|
19
|
+
{ }
|
|
20
|
+
|
|
21
|
+
InvalidSass::InvalidSass(SourceSpan pstate, Backtraces traces, sass::string msg)
|
|
22
|
+
: Base(pstate, msg, traces)
|
|
23
|
+
{ }
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
InvalidParent::InvalidParent(Selector* parent, Backtraces traces, Selector* selector)
|
|
27
|
+
: Base(selector->pstate(), def_msg, traces), parent(parent), selector(selector)
|
|
28
|
+
{
|
|
29
|
+
msg = "Invalid parent selector for "
|
|
30
|
+
"\"" + selector->to_string(Sass_Inspect_Options()) + "\": "
|
|
31
|
+
"\"" + parent->to_string(Sass_Inspect_Options()) + "\"";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
InvalidVarKwdType::InvalidVarKwdType(SourceSpan pstate, Backtraces traces, sass::string name, const Argument* arg)
|
|
35
|
+
: Base(pstate, def_msg, traces), name(name), arg(arg)
|
|
36
|
+
{
|
|
37
|
+
msg = "Variable keyword argument map must have string keys.\n" +
|
|
38
|
+
name + " is not a string in " + arg->to_string() + ".";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
InvalidArgumentType::InvalidArgumentType(SourceSpan pstate, Backtraces traces, sass::string fn, sass::string arg, sass::string type, const Value* value)
|
|
42
|
+
: Base(pstate, def_msg, traces), fn(fn), arg(arg), type(type), value(value)
|
|
43
|
+
{
|
|
44
|
+
msg = arg + ": \"";
|
|
45
|
+
if (value) msg += value->to_string(Sass_Inspect_Options());
|
|
46
|
+
msg += "\" is not a " + type + " for `" + fn + "'";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
MissingArgument::MissingArgument(SourceSpan pstate, Backtraces traces, sass::string fn, sass::string arg, sass::string fntype)
|
|
50
|
+
: Base(pstate, def_msg, traces), fn(fn), arg(arg), fntype(fntype)
|
|
51
|
+
{
|
|
52
|
+
msg = fntype + " " + fn + " is missing argument " + arg + ".";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
InvalidSyntax::InvalidSyntax(SourceSpan pstate, Backtraces traces, sass::string msg)
|
|
56
|
+
: Base(pstate, msg, traces)
|
|
57
|
+
{ }
|
|
58
|
+
|
|
59
|
+
NestingLimitError::NestingLimitError(SourceSpan pstate, Backtraces traces, sass::string msg)
|
|
60
|
+
: Base(pstate, msg, traces)
|
|
61
|
+
{ }
|
|
62
|
+
|
|
63
|
+
DuplicateKeyError::DuplicateKeyError(Backtraces traces, const Map& dup, const Expression& org)
|
|
64
|
+
: Base(org.pstate(), def_msg, traces), dup(dup), org(org)
|
|
65
|
+
{
|
|
66
|
+
msg = "Duplicate key " + dup.get_duplicate_key()->inspect() + " in map (" + org.inspect() + ").";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
TypeMismatch::TypeMismatch(Backtraces traces, const Expression& var, const sass::string type)
|
|
70
|
+
: Base(var.pstate(), def_msg, traces), var(var), type(type)
|
|
71
|
+
{
|
|
72
|
+
msg = var.to_string() + " is not an " + type + ".";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
InvalidValue::InvalidValue(Backtraces traces, const Expression& val)
|
|
76
|
+
: Base(val.pstate(), def_msg, traces), val(val)
|
|
77
|
+
{
|
|
78
|
+
msg = val.to_string() + " isn't a valid CSS value.";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
StackError::StackError(Backtraces traces, const AST_Node& node)
|
|
82
|
+
: Base(node.pstate(), def_msg, traces), node(node)
|
|
83
|
+
{
|
|
84
|
+
msg = "stack level too deep";
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
EndlessExtendError::EndlessExtendError(Backtraces traces, const AST_Node& node)
|
|
88
|
+
: Base(node.pstate(), def_msg, traces), node(node)
|
|
89
|
+
{
|
|
90
|
+
msg = "Extend is creating an absurdly big selector, aborting!";
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
IncompatibleUnits::IncompatibleUnits(const Units& lhs, const Units& rhs)
|
|
94
|
+
{
|
|
95
|
+
msg = "Incompatible units: '" + rhs.unit() + "' and '" + lhs.unit() + "'.";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
IncompatibleUnits::IncompatibleUnits(const UnitType lhs, const UnitType rhs)
|
|
99
|
+
{
|
|
100
|
+
msg = sass::string("Incompatible units: '") + unit_to_string(rhs) + "' and '" + unit_to_string(lhs) + "'.";
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
AlphaChannelsNotEqual::AlphaChannelsNotEqual(const Expression* lhs, const Expression* rhs, enum Sass_OP op)
|
|
104
|
+
: OperationError(), lhs(lhs), rhs(rhs), op(op)
|
|
105
|
+
{
|
|
106
|
+
msg = "Alpha channels must be equal: " +
|
|
107
|
+
lhs->to_string({ NESTED, 5 }) +
|
|
108
|
+
" " + sass_op_to_name(op) + " " +
|
|
109
|
+
rhs->to_string({ NESTED, 5 }) + ".";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
ZeroDivisionError::ZeroDivisionError(const Expression& lhs, const Expression& rhs)
|
|
113
|
+
: OperationError(), lhs(lhs), rhs(rhs)
|
|
114
|
+
{
|
|
115
|
+
msg = "divided by 0";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
UndefinedOperation::UndefinedOperation(const Expression* lhs, const Expression* rhs, enum Sass_OP op)
|
|
119
|
+
: OperationError(), lhs(lhs), rhs(rhs), op(op)
|
|
120
|
+
{
|
|
121
|
+
msg = def_op_msg + ": \"" +
|
|
122
|
+
lhs->to_string({ NESTED, 5 }) +
|
|
123
|
+
" " + sass_op_to_name(op) + " " +
|
|
124
|
+
rhs->to_string({ TO_SASS, 5 }) +
|
|
125
|
+
"\".";
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
InvalidNullOperation::InvalidNullOperation(const Expression* lhs, const Expression* rhs, enum Sass_OP op)
|
|
129
|
+
: UndefinedOperation(lhs, rhs, op)
|
|
130
|
+
{
|
|
131
|
+
msg = def_op_null_msg + ": \"" + lhs->inspect() + " " + sass_op_to_name(op) + " " + rhs->inspect() + "\".";
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
SassValueError::SassValueError(Backtraces traces, SourceSpan pstate, OperationError& err)
|
|
135
|
+
: Base(pstate, err.what(), traces)
|
|
136
|
+
{
|
|
137
|
+
msg = err.what();
|
|
138
|
+
prefix = err.errtype();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
TopLevelParent::TopLevelParent(Backtraces traces, SourceSpan pstate)
|
|
142
|
+
: Base(pstate, "Top-level selectors may not contain the parent selector \"&\".", traces)
|
|
143
|
+
{
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
UnsatisfiedExtend::UnsatisfiedExtend(Backtraces traces, Extension extension)
|
|
148
|
+
: Base(extension.target->pstate(), "The target selector was not found.\n"
|
|
149
|
+
"Use \"@extend " + extension.target->to_string() + " !optional\" to avoid this error.", traces)
|
|
150
|
+
{
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
ExtendAcrossMedia::ExtendAcrossMedia(Backtraces traces, Extension extension)
|
|
155
|
+
: Base(extension.target->pstate(), "You may not @extend selectors across media queries.\n"
|
|
156
|
+
"Use \"@extend " + extension.target->to_string() + " !optional\" to avoid this error.", traces)
|
|
157
|
+
{
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
void warn(sass::string msg, SourceSpan pstate)
|
|
166
|
+
{
|
|
167
|
+
std::cerr << "Warning: " << msg << std::endl;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
void warning(sass::string msg, SourceSpan pstate)
|
|
171
|
+
{
|
|
172
|
+
sass::string cwd(Sass::File::get_cwd());
|
|
173
|
+
sass::string abs_path(Sass::File::rel2abs(pstate.getPath(), cwd, cwd));
|
|
174
|
+
sass::string rel_path(Sass::File::abs2rel(pstate.getPath(), cwd, cwd));
|
|
175
|
+
sass::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.getPath()));
|
|
176
|
+
|
|
177
|
+
std::cerr << "WARNING on line " << pstate.getLine() << ", column " << pstate.getColumn() << " of " << output_path << ":" << std::endl;
|
|
178
|
+
std::cerr << msg << std::endl << std::endl;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
void warn(sass::string msg, SourceSpan pstate, Backtrace* bt)
|
|
182
|
+
{
|
|
183
|
+
warn(msg, pstate);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
void deprecated_function(sass::string msg, SourceSpan pstate)
|
|
187
|
+
{
|
|
188
|
+
sass::string cwd(Sass::File::get_cwd());
|
|
189
|
+
sass::string abs_path(Sass::File::rel2abs(pstate.getPath(), cwd, cwd));
|
|
190
|
+
sass::string rel_path(Sass::File::abs2rel(pstate.getPath(), cwd, cwd));
|
|
191
|
+
sass::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.getPath()));
|
|
192
|
+
|
|
193
|
+
std::cerr << "DEPRECATION WARNING: " << msg << std::endl;
|
|
194
|
+
std::cerr << "will be an error in future versions of Sass." << std::endl;
|
|
195
|
+
std::cerr << " on line " << pstate.getLine() << " of " << output_path << std::endl;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
void deprecated(sass::string msg, sass::string msg2, bool with_column, SourceSpan pstate)
|
|
199
|
+
{
|
|
200
|
+
sass::string cwd(Sass::File::get_cwd());
|
|
201
|
+
sass::string abs_path(Sass::File::rel2abs(pstate.getPath(), cwd, cwd));
|
|
202
|
+
sass::string rel_path(Sass::File::abs2rel(pstate.getPath(), cwd, cwd));
|
|
203
|
+
sass::string output_path(Sass::File::path_for_console(rel_path, pstate.getPath(), pstate.getPath()));
|
|
204
|
+
|
|
205
|
+
std::cerr << "DEPRECATION WARNING on line " << pstate.getLine();
|
|
206
|
+
// if (with_column) std::cerr << ", column " << pstate.column + pstate.offset.column + 1;
|
|
207
|
+
if (output_path.length()) std::cerr << " of " << output_path;
|
|
208
|
+
std::cerr << ":" << std::endl;
|
|
209
|
+
std::cerr << msg << std::endl;
|
|
210
|
+
if (msg2.length()) std::cerr << msg2 << std::endl;
|
|
211
|
+
std::cerr << std::endl;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
void deprecated_bind(sass::string msg, SourceSpan pstate)
|
|
215
|
+
{
|
|
216
|
+
sass::string cwd(Sass::File::get_cwd());
|
|
217
|
+
sass::string abs_path(Sass::File::rel2abs(pstate.getPath(), cwd, cwd));
|
|
218
|
+
sass::string rel_path(Sass::File::abs2rel(pstate.getPath(), cwd, cwd));
|
|
219
|
+
sass::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.getPath()));
|
|
220
|
+
|
|
221
|
+
std::cerr << "WARNING: " << msg << std::endl;
|
|
222
|
+
std::cerr << " on line " << pstate.getLine() << " of " << output_path << std::endl;
|
|
223
|
+
std::cerr << "This will be an error in future versions of Sass." << std::endl;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// should be replaced with error with backtraces
|
|
227
|
+
void coreError(sass::string msg, SourceSpan pstate)
|
|
228
|
+
{
|
|
229
|
+
Backtraces traces;
|
|
230
|
+
throw Exception::InvalidSyntax(pstate, traces, msg);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
void error(sass::string msg, SourceSpan pstate, Backtraces& traces)
|
|
234
|
+
{
|
|
235
|
+
traces.push_back(Backtrace(pstate));
|
|
236
|
+
throw Exception::InvalidSyntax(pstate, traces, msg);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
#ifndef SASS_ERROR_HANDLING_H
|
|
2
|
+
#define SASS_ERROR_HANDLING_H
|
|
3
|
+
|
|
4
|
+
// sass.hpp must go before all system headers to get the
|
|
5
|
+
// __EXTENSIONS__ fix on Solaris.
|
|
6
|
+
#include "sass.hpp"
|
|
7
|
+
|
|
8
|
+
#include <string>
|
|
9
|
+
#include <sstream>
|
|
10
|
+
#include <stdexcept>
|
|
11
|
+
#include "units.hpp"
|
|
12
|
+
#include "position.hpp"
|
|
13
|
+
#include "backtrace.hpp"
|
|
14
|
+
#include "ast_fwd_decl.hpp"
|
|
15
|
+
#include "sass/functions.h"
|
|
16
|
+
|
|
17
|
+
namespace Sass {
|
|
18
|
+
|
|
19
|
+
struct Backtrace;
|
|
20
|
+
|
|
21
|
+
namespace Exception {
|
|
22
|
+
|
|
23
|
+
const sass::string def_msg = "Invalid sass detected";
|
|
24
|
+
const sass::string def_op_msg = "Undefined operation";
|
|
25
|
+
const sass::string def_op_null_msg = "Invalid null operation";
|
|
26
|
+
const sass::string def_nesting_limit = "Code too deeply nested";
|
|
27
|
+
|
|
28
|
+
class Base : public std::runtime_error {
|
|
29
|
+
protected:
|
|
30
|
+
sass::string msg;
|
|
31
|
+
sass::string prefix;
|
|
32
|
+
public:
|
|
33
|
+
SourceSpan pstate;
|
|
34
|
+
Backtraces traces;
|
|
35
|
+
public:
|
|
36
|
+
Base(SourceSpan pstate, sass::string msg, Backtraces traces);
|
|
37
|
+
virtual const char* errtype() const { return prefix.c_str(); }
|
|
38
|
+
virtual const char* what() const throw() { return msg.c_str(); }
|
|
39
|
+
virtual ~Base() throw() {};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
class InvalidSass : public Base {
|
|
43
|
+
public:
|
|
44
|
+
InvalidSass(SourceSpan pstate, Backtraces traces, sass::string msg);
|
|
45
|
+
virtual ~InvalidSass() throw() {};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
class InvalidParent : public Base {
|
|
49
|
+
protected:
|
|
50
|
+
Selector* parent;
|
|
51
|
+
Selector* selector;
|
|
52
|
+
public:
|
|
53
|
+
InvalidParent(Selector* parent, Backtraces traces, Selector* selector);
|
|
54
|
+
virtual ~InvalidParent() throw() {};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
class MissingArgument : public Base {
|
|
58
|
+
protected:
|
|
59
|
+
sass::string fn;
|
|
60
|
+
sass::string arg;
|
|
61
|
+
sass::string fntype;
|
|
62
|
+
public:
|
|
63
|
+
MissingArgument(SourceSpan pstate, Backtraces traces, sass::string fn, sass::string arg, sass::string fntype);
|
|
64
|
+
virtual ~MissingArgument() throw() {};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
class InvalidArgumentType : public Base {
|
|
68
|
+
protected:
|
|
69
|
+
sass::string fn;
|
|
70
|
+
sass::string arg;
|
|
71
|
+
sass::string type;
|
|
72
|
+
const Value* value;
|
|
73
|
+
public:
|
|
74
|
+
InvalidArgumentType(SourceSpan pstate, Backtraces traces, sass::string fn, sass::string arg, sass::string type, const Value* value = 0);
|
|
75
|
+
virtual ~InvalidArgumentType() throw() {};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
class InvalidVarKwdType : public Base {
|
|
79
|
+
protected:
|
|
80
|
+
sass::string name;
|
|
81
|
+
const Argument* arg;
|
|
82
|
+
public:
|
|
83
|
+
InvalidVarKwdType(SourceSpan pstate, Backtraces traces, sass::string name, const Argument* arg = 0);
|
|
84
|
+
virtual ~InvalidVarKwdType() throw() {};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
class InvalidSyntax : public Base {
|
|
88
|
+
public:
|
|
89
|
+
InvalidSyntax(SourceSpan pstate, Backtraces traces, sass::string msg);
|
|
90
|
+
virtual ~InvalidSyntax() throw() {};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
class NestingLimitError : public Base {
|
|
94
|
+
public:
|
|
95
|
+
NestingLimitError(SourceSpan pstate, Backtraces traces, sass::string msg = def_nesting_limit);
|
|
96
|
+
virtual ~NestingLimitError() throw() {};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
class DuplicateKeyError : public Base {
|
|
100
|
+
protected:
|
|
101
|
+
const Map& dup;
|
|
102
|
+
const Expression& org;
|
|
103
|
+
public:
|
|
104
|
+
DuplicateKeyError(Backtraces traces, const Map& dup, const Expression& org);
|
|
105
|
+
virtual const char* errtype() const { return "Error"; }
|
|
106
|
+
virtual ~DuplicateKeyError() throw() {};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
class TypeMismatch : public Base {
|
|
110
|
+
protected:
|
|
111
|
+
const Expression& var;
|
|
112
|
+
const sass::string type;
|
|
113
|
+
public:
|
|
114
|
+
TypeMismatch(Backtraces traces, const Expression& var, const sass::string type);
|
|
115
|
+
virtual const char* errtype() const { return "Error"; }
|
|
116
|
+
virtual ~TypeMismatch() throw() {};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
class InvalidValue : public Base {
|
|
120
|
+
protected:
|
|
121
|
+
const Expression& val;
|
|
122
|
+
public:
|
|
123
|
+
InvalidValue(Backtraces traces, const Expression& val);
|
|
124
|
+
virtual const char* errtype() const { return "Error"; }
|
|
125
|
+
virtual ~InvalidValue() throw() {};
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
class StackError : public Base {
|
|
129
|
+
protected:
|
|
130
|
+
const AST_Node& node;
|
|
131
|
+
public:
|
|
132
|
+
StackError(Backtraces traces, const AST_Node& node);
|
|
133
|
+
virtual const char* errtype() const { return "SystemStackError"; }
|
|
134
|
+
virtual ~StackError() throw() {};
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
class EndlessExtendError : public Base {
|
|
138
|
+
protected:
|
|
139
|
+
const AST_Node& node;
|
|
140
|
+
public:
|
|
141
|
+
EndlessExtendError(Backtraces traces, const AST_Node& node);
|
|
142
|
+
virtual const char* errtype() const { return "EndlessExtendError"; }
|
|
143
|
+
virtual ~EndlessExtendError() throw() {};
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/* common virtual base class (has no pstate or trace) */
|
|
147
|
+
class OperationError : public std::runtime_error {
|
|
148
|
+
protected:
|
|
149
|
+
sass::string msg;
|
|
150
|
+
public:
|
|
151
|
+
OperationError(sass::string msg = def_op_msg)
|
|
152
|
+
: std::runtime_error(msg.c_str()), msg(msg)
|
|
153
|
+
{};
|
|
154
|
+
public:
|
|
155
|
+
virtual const char* errtype() const { return "Error"; }
|
|
156
|
+
virtual const char* what() const throw() { return msg.c_str(); }
|
|
157
|
+
virtual ~OperationError() throw() {};
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
class ZeroDivisionError : public OperationError {
|
|
161
|
+
protected:
|
|
162
|
+
const Expression& lhs;
|
|
163
|
+
const Expression& rhs;
|
|
164
|
+
public:
|
|
165
|
+
ZeroDivisionError(const Expression& lhs, const Expression& rhs);
|
|
166
|
+
virtual const char* errtype() const { return "ZeroDivisionError"; }
|
|
167
|
+
virtual ~ZeroDivisionError() throw() {};
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
class IncompatibleUnits : public OperationError {
|
|
171
|
+
protected:
|
|
172
|
+
// const Sass::UnitType lhs;
|
|
173
|
+
// const Sass::UnitType rhs;
|
|
174
|
+
public:
|
|
175
|
+
IncompatibleUnits(const Units& lhs, const Units& rhs);
|
|
176
|
+
IncompatibleUnits(const UnitType lhs, const UnitType rhs);
|
|
177
|
+
virtual ~IncompatibleUnits() throw() {};
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
class UndefinedOperation : public OperationError {
|
|
181
|
+
protected:
|
|
182
|
+
const Expression* lhs;
|
|
183
|
+
const Expression* rhs;
|
|
184
|
+
const Sass_OP op;
|
|
185
|
+
public:
|
|
186
|
+
UndefinedOperation(const Expression* lhs, const Expression* rhs, enum Sass_OP op);
|
|
187
|
+
// virtual const char* errtype() const { return "Error"; }
|
|
188
|
+
virtual ~UndefinedOperation() throw() {};
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
class InvalidNullOperation : public UndefinedOperation {
|
|
192
|
+
public:
|
|
193
|
+
InvalidNullOperation(const Expression* lhs, const Expression* rhs, enum Sass_OP op);
|
|
194
|
+
virtual ~InvalidNullOperation() throw() {};
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
class AlphaChannelsNotEqual : public OperationError {
|
|
198
|
+
protected:
|
|
199
|
+
const Expression* lhs;
|
|
200
|
+
const Expression* rhs;
|
|
201
|
+
const Sass_OP op;
|
|
202
|
+
public:
|
|
203
|
+
AlphaChannelsNotEqual(const Expression* lhs, const Expression* rhs, enum Sass_OP op);
|
|
204
|
+
// virtual const char* errtype() const { return "Error"; }
|
|
205
|
+
virtual ~AlphaChannelsNotEqual() throw() {};
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
class SassValueError : public Base {
|
|
209
|
+
public:
|
|
210
|
+
SassValueError(Backtraces traces, SourceSpan pstate, OperationError& err);
|
|
211
|
+
virtual ~SassValueError() throw() {};
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
class TopLevelParent : public Base {
|
|
215
|
+
public:
|
|
216
|
+
TopLevelParent(Backtraces traces, SourceSpan pstate);
|
|
217
|
+
virtual ~TopLevelParent() throw() {};
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
class UnsatisfiedExtend : public Base {
|
|
221
|
+
public:
|
|
222
|
+
UnsatisfiedExtend(Backtraces traces, Extension extension);
|
|
223
|
+
virtual ~UnsatisfiedExtend() throw() {};
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
class ExtendAcrossMedia : public Base {
|
|
227
|
+
public:
|
|
228
|
+
ExtendAcrossMedia(Backtraces traces, Extension extension);
|
|
229
|
+
virtual ~ExtendAcrossMedia() throw() {};
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
void warn(sass::string msg, SourceSpan pstate);
|
|
235
|
+
void warn(sass::string msg, SourceSpan pstate, Backtrace* bt);
|
|
236
|
+
void warning(sass::string msg, SourceSpan pstate);
|
|
237
|
+
|
|
238
|
+
void deprecated_function(sass::string msg, SourceSpan pstate);
|
|
239
|
+
void deprecated(sass::string msg, sass::string msg2, bool with_column, SourceSpan pstate);
|
|
240
|
+
void deprecated_bind(sass::string msg, SourceSpan pstate);
|
|
241
|
+
// void deprecated(sass::string msg, SourceSpan pstate, Backtrace* bt);
|
|
242
|
+
|
|
243
|
+
void coreError(sass::string msg, SourceSpan pstate);
|
|
244
|
+
void error(sass::string msg, SourceSpan pstate, Backtraces& traces);
|
|
245
|
+
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
#endif
|