sassc 0.0.10 → 0.0.11
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 +4 -4
- data/README.md +1 -1
- data/ext/libsass/.gitignore +6 -0
- data/ext/libsass/.travis.yml +5 -1
- data/ext/libsass/Makefile +12 -3
- data/ext/libsass/Makefile.am +16 -28
- data/ext/libsass/Readme.md +1 -0
- data/ext/libsass/appveyor.yml +1 -2
- data/ext/libsass/ast.cpp +9 -0
- data/ext/libsass/ast.hpp +152 -55
- data/ext/libsass/ast_factory.hpp +2 -0
- data/ext/libsass/ast_fwd_decl.hpp +1 -0
- data/ext/libsass/backtrace.hpp +2 -2
- data/ext/libsass/bind.cpp +15 -13
- data/ext/libsass/configure.ac +17 -5
- data/ext/libsass/constants.cpp +22 -2
- data/ext/libsass/constants.hpp +21 -2
- data/ext/libsass/context.cpp +79 -57
- data/ext/libsass/context.hpp +23 -9
- data/ext/libsass/contextualize.cpp +2 -28
- data/ext/libsass/contextualize.hpp +6 -10
- data/ext/libsass/contextualize_eval.cpp +93 -0
- data/ext/libsass/contextualize_eval.hpp +44 -0
- data/ext/libsass/contrib/plugin.cpp +57 -0
- data/ext/libsass/cssize.cpp +3 -1
- data/ext/libsass/debugger.hpp +242 -83
- data/ext/libsass/emitter.cpp +1 -1
- data/ext/libsass/emitter.hpp +1 -1
- data/ext/libsass/environment.hpp +109 -25
- data/ext/libsass/error_handling.cpp +3 -3
- data/ext/libsass/error_handling.hpp +0 -1
- data/ext/libsass/eval.cpp +145 -61
- data/ext/libsass/eval.hpp +9 -1
- data/ext/libsass/expand.cpp +134 -60
- data/ext/libsass/expand.hpp +5 -2
- data/ext/libsass/extend.cpp +7 -5
- data/ext/libsass/file.cpp +176 -123
- data/ext/libsass/file.hpp +44 -7
- data/ext/libsass/functions.cpp +36 -17
- data/ext/libsass/functions.hpp +2 -2
- data/ext/libsass/inspect.cpp +23 -14
- data/ext/libsass/inspect.hpp +1 -0
- data/ext/libsass/json.cpp +132 -135
- data/ext/libsass/lexer.cpp +133 -0
- data/ext/libsass/lexer.hpp +239 -0
- data/ext/libsass/listize.cpp +83 -0
- data/ext/libsass/listize.hpp +41 -0
- data/ext/libsass/operation.hpp +2 -0
- data/ext/libsass/output.cpp +5 -6
- data/ext/libsass/parser.cpp +426 -388
- data/ext/libsass/parser.hpp +97 -109
- data/ext/libsass/plugins.cpp +15 -2
- data/ext/libsass/plugins.hpp +6 -4
- data/ext/libsass/position.cpp +52 -17
- data/ext/libsass/position.hpp +19 -17
- data/ext/libsass/prelexer.cpp +202 -235
- data/ext/libsass/prelexer.hpp +73 -333
- data/ext/libsass/sass.cpp +21 -11
- data/ext/libsass/sass.h +6 -6
- data/ext/libsass/sass_context.cpp +167 -81
- data/ext/libsass/sass_context.h +26 -6
- data/ext/libsass/sass_functions.cpp +49 -40
- data/ext/libsass/sass_functions.h +55 -43
- data/ext/libsass/sass_interface.cpp +9 -8
- data/ext/libsass/sass_interface.h +3 -3
- data/ext/libsass/sass_version.h +8 -0
- data/ext/libsass/sass_version.h.in +8 -0
- data/ext/libsass/script/ci-build-libsass +3 -3
- data/ext/libsass/script/ci-report-coverage +2 -1
- data/ext/libsass/source_map.cpp +2 -2
- data/ext/libsass/util.cpp +60 -11
- data/ext/libsass/util.hpp +6 -1
- data/ext/libsass/win/libsass.filters +12 -0
- data/ext/libsass/win/libsass.vcxproj +10 -0
- data/lib/sassc.rb +3 -1
- data/lib/sassc/cache_stores/base.rb +2 -0
- data/lib/sassc/dependency.rb +3 -1
- data/lib/sassc/engine.rb +31 -16
- data/lib/sassc/error.rb +3 -2
- data/lib/sassc/functions_handler.rb +54 -0
- data/lib/sassc/import_handler.rb +41 -0
- data/lib/sassc/importer.rb +4 -31
- data/lib/sassc/native.rb +1 -1
- data/lib/sassc/native/native_context_api.rb +3 -2
- data/lib/sassc/script.rb +0 -51
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +1 -0
- data/test/custom_importer_test.rb +72 -69
- data/test/engine_test.rb +53 -54
- data/test/functions_test.rb +40 -39
- data/test/native_test.rb +145 -149
- data/test/output_style_test.rb +98 -0
- data/test/test_helper.rb +21 -7
- metadata +28 -2
data/ext/libsass/parser.hpp
CHANGED
@@ -25,10 +25,12 @@ namespace Sass {
|
|
25
25
|
class Parser : public ParserState {
|
26
26
|
private:
|
27
27
|
void add_single_file (Import* imp, string import_path);
|
28
|
+
void import_single_file (Import* imp, string import_path);
|
28
29
|
public:
|
29
30
|
class AST_Node;
|
30
31
|
|
31
32
|
enum Syntactic_Context { nothing, mixin_def, function_def };
|
33
|
+
bool do_import(const string& import_path, Import* imp, vector<Sass_Importer_Entry> importers, bool only_one = true);
|
32
34
|
|
33
35
|
Context& ctx;
|
34
36
|
vector<Block*> block_stack;
|
@@ -48,7 +50,7 @@ namespace Sass {
|
|
48
50
|
|
49
51
|
Parser(Context& ctx, const ParserState& pstate)
|
50
52
|
: ParserState(pstate), ctx(ctx), block_stack(0), stack(0), last_media_block(0),
|
51
|
-
source(0), position(0), end(0), before_token(pstate), after_token(pstate), pstate(
|
53
|
+
source(0), position(0), end(0), before_token(pstate), after_token(pstate), pstate(pstate), indentation(0)
|
52
54
|
{ in_at_root = false; stack.push_back(nothing); }
|
53
55
|
|
54
56
|
// static Parser from_string(const string& src, Context& ctx, ParserState pstate = ParserState("[STRING]"));
|
@@ -71,140 +73,119 @@ namespace Sass {
|
|
71
73
|
|
72
74
|
bool peek_newline(const char* start = 0);
|
73
75
|
|
76
|
+
// skip over spaces, tabs and line comments
|
74
77
|
template <prelexer mx>
|
75
|
-
const char*
|
78
|
+
const char* sneak(const char* start = 0)
|
76
79
|
{
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
else {
|
92
|
-
return 0;
|
93
|
-
}
|
94
|
-
}
|
95
|
-
else if (mx == optional_spaces) {
|
96
|
-
it_before_token = optional_spaces(start);
|
97
|
-
}
|
98
|
-
else if (mx == line_comment_prefix || mx == block_comment_prefix) {
|
99
|
-
it_before_token = position;
|
100
|
-
}
|
101
|
-
else {
|
102
|
-
it_before_token = optional_spaces_and_comments(start);
|
103
|
-
}
|
104
|
-
const char* it_after_token = mx(it_before_token);
|
105
|
-
if (it_after_token) {
|
106
|
-
return it_after_token;
|
107
|
-
}
|
108
|
-
else {
|
109
|
-
return 0;
|
80
|
+
|
81
|
+
// maybe use optional start position from arguments?
|
82
|
+
const char* it_position = start ? start : position;
|
83
|
+
|
84
|
+
// skip white-space?
|
85
|
+
if (mx == spaces ||
|
86
|
+
mx == no_spaces ||
|
87
|
+
mx == css_comments ||
|
88
|
+
mx == css_whitespace ||
|
89
|
+
mx == optional_spaces ||
|
90
|
+
mx == optional_css_comments ||
|
91
|
+
mx == optional_css_whitespace
|
92
|
+
) {
|
93
|
+
return it_position;
|
110
94
|
}
|
95
|
+
|
96
|
+
// skip over spaces, tabs and sass line comments
|
97
|
+
const char* pos = optional_css_whitespace(it_position);
|
98
|
+
// always return a valid position
|
99
|
+
return pos ? pos : it_position;
|
100
|
+
|
111
101
|
}
|
112
102
|
|
113
|
-
//
|
114
|
-
//
|
115
|
-
// some matchers don't accept certain white-space
|
103
|
+
// peek will only skip over space, tabs and line comment
|
104
|
+
// return the position where the lexer match will occur
|
116
105
|
template <prelexer mx>
|
117
|
-
const char*
|
106
|
+
const char* peek(const char* start = 0)
|
118
107
|
{
|
119
108
|
|
120
|
-
//
|
121
|
-
|
122
|
-
|
123
|
-
// advance position for next call
|
124
|
-
before_token = after_token;
|
109
|
+
// sneak up to the actual token we want to lex
|
110
|
+
// this should skip over white-space if desired
|
111
|
+
const char* it_before_token = sneak < mx >(start);
|
125
112
|
|
126
|
-
//
|
127
|
-
|
113
|
+
// match the given prelexer
|
114
|
+
return mx(it_before_token);
|
128
115
|
|
129
|
-
|
130
|
-
// a block comment can be preceded by spaces and/or line comments
|
131
|
-
it_before_token = zero_plus< alternatives<spaces, line_comment> >(position);
|
132
|
-
}
|
133
|
-
else if (mx == url || mx == no_spaces) {
|
134
|
-
// parse everything literally
|
135
|
-
it_before_token = position;
|
136
|
-
}
|
116
|
+
}
|
137
117
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
118
|
+
// white-space handling is built into the lexer
|
119
|
+
// this way you do not need to parse it yourself
|
120
|
+
// some matchers don't accept certain white-space
|
121
|
+
// we do not support start arg, since we manipulate
|
122
|
+
// sourcemap offset and we modify the position pointer!
|
123
|
+
// lex will only skip over space, tabs and line comment
|
124
|
+
template <prelexer mx>
|
125
|
+
const char* lex(bool lazy = true)
|
126
|
+
{
|
147
127
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
it_before_token = position;
|
153
|
-
}
|
128
|
+
// position considered before lexed token
|
129
|
+
// we can skip whitespace or comments for
|
130
|
+
// lazy developers (but we need control)
|
131
|
+
const char* it_before_token = position;
|
154
132
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
}
|
159
|
-
else {
|
160
|
-
// most can be preceded by spaces and comments
|
161
|
-
it_before_token = optional_spaces_and_comments(position);
|
162
|
-
}
|
133
|
+
// sneak up to the actual token we want to lex
|
134
|
+
// this should skip over white-space if desired
|
135
|
+
if (lazy) it_before_token = sneak < mx >(position);
|
163
136
|
|
164
137
|
// now call matcher to get position after token
|
165
138
|
const char* it_after_token = mx(it_before_token);
|
139
|
+
|
166
140
|
// assertion that we got a valid match
|
167
141
|
if (it_after_token == 0) return 0;
|
142
|
+
// assertion that we actually lexed something
|
143
|
+
if (it_after_token == it_before_token) return 0;
|
168
144
|
|
169
|
-
//
|
170
|
-
|
171
|
-
if (*position == '\n') {
|
172
|
-
++ before_token.line;
|
173
|
-
before_token.column = 0;
|
174
|
-
} else {
|
175
|
-
++ before_token.column;
|
176
|
-
}
|
177
|
-
++position;
|
178
|
-
}
|
179
|
-
|
180
|
-
// copy position
|
181
|
-
after_token = before_token;
|
145
|
+
// create new lexed token object (holds all parse result information)
|
146
|
+
lexed = Token(position, it_before_token, it_after_token);
|
182
147
|
|
183
|
-
|
148
|
+
// advance position (add whitespace before current token)
|
149
|
+
before_token = after_token.add(position, it_before_token);
|
184
150
|
|
185
|
-
//
|
186
|
-
|
187
|
-
if (*position == '\n') {
|
188
|
-
++ size.line;
|
189
|
-
size.column = 0;
|
190
|
-
} else {
|
191
|
-
++ size.column;
|
192
|
-
}
|
193
|
-
++position;
|
194
|
-
}
|
195
|
-
|
196
|
-
after_token = after_token + size;
|
151
|
+
// update after_token position for current token
|
152
|
+
after_token.add(it_before_token, it_after_token);
|
197
153
|
|
198
|
-
//
|
199
|
-
|
200
|
-
Position pos(before_token.file, before_token.line, before_token.column);
|
201
|
-
pstate = ParserState(path, lexed, pos, size);
|
154
|
+
// ToDo: could probably do this incremetal on original object (API wants offset?)
|
155
|
+
pstate = ParserState(path, source, lexed, before_token, after_token - before_token);
|
202
156
|
|
203
157
|
// advance internal char iterator
|
204
158
|
return position = it_after_token;
|
205
159
|
|
206
160
|
}
|
207
161
|
|
162
|
+
// lex_css skips over space, tabs, line and block comment
|
163
|
+
// all block comments will be consumed and thrown away
|
164
|
+
// source-map position will point to token after the comment
|
165
|
+
template <prelexer mx>
|
166
|
+
const char* lex_css()
|
167
|
+
{
|
168
|
+
// copy old token
|
169
|
+
Token prev = lexed;
|
170
|
+
// throw away comments
|
171
|
+
// update srcmap position
|
172
|
+
lex < css_comments >();
|
173
|
+
// now lex a new token
|
174
|
+
const char* pos = lex< mx >();
|
175
|
+
// maybe restore prev token
|
176
|
+
if (pos == 0) lexed = prev;
|
177
|
+
// return match
|
178
|
+
return pos;
|
179
|
+
}
|
180
|
+
|
181
|
+
// all block comments will be skipped and thrown away
|
182
|
+
template <prelexer mx>
|
183
|
+
const char* peek_css(const char* start = 0)
|
184
|
+
{
|
185
|
+
// now peek a token (skip comments first)
|
186
|
+
return peek< mx >(peek < css_comments >(start));
|
187
|
+
}
|
188
|
+
|
208
189
|
#ifdef __clang__
|
209
190
|
|
210
191
|
#pragma clang diagnostic pop
|
@@ -212,6 +193,11 @@ namespace Sass {
|
|
212
193
|
#endif
|
213
194
|
|
214
195
|
void error(string msg, Position pos);
|
196
|
+
// generate message with given and expected sample
|
197
|
+
// text before and in the middle are configurable
|
198
|
+
void css_error(const string& msg,
|
199
|
+
const string& prefix = " after ",
|
200
|
+
const string& middle = ", was: ");
|
215
201
|
void read_bom();
|
216
202
|
|
217
203
|
Block* parse();
|
@@ -220,8 +206,8 @@ namespace Sass {
|
|
220
206
|
Parameters* parse_parameters();
|
221
207
|
Parameter* parse_parameter();
|
222
208
|
Mixin_Call* parse_mixin_call();
|
223
|
-
Arguments* parse_arguments();
|
224
|
-
Argument* parse_argument();
|
209
|
+
Arguments* parse_arguments(bool has_url = false);
|
210
|
+
Argument* parse_argument(bool has_url = false);
|
225
211
|
Assignment* parse_assignment();
|
226
212
|
// Propset* parse_propset();
|
227
213
|
Ruleset* parse_ruleset(Selector_Lookahead lookahead);
|
@@ -282,6 +268,8 @@ namespace Sass {
|
|
282
268
|
Error* parse_error();
|
283
269
|
Debug* parse_debug();
|
284
270
|
|
271
|
+
void parse_block_comments(Block* block);
|
272
|
+
|
285
273
|
Selector_Lookahead lookahead_for_selector(const char* start = 0);
|
286
274
|
Selector_Lookahead lookahead_for_extension_target(const char* start = 0);
|
287
275
|
|
data/ext/libsass/plugins.cpp
CHANGED
@@ -45,7 +45,8 @@ namespace Sass {
|
|
45
45
|
{
|
46
46
|
|
47
47
|
typedef const char* (*__plugin_version__)(void);
|
48
|
-
typedef
|
48
|
+
typedef Sass_Function_List (*__plugin_load_fns__)(void);
|
49
|
+
typedef Sass_Importer_List (*__plugin_load_imps__)(void);
|
49
50
|
|
50
51
|
if (LOAD_LIB(plugin, path))
|
51
52
|
{
|
@@ -57,9 +58,21 @@ namespace Sass {
|
|
57
58
|
// try to get import address for "libsass_load_functions"
|
58
59
|
if (LOAD_LIB_FN(__plugin_load_fns__, plugin_load_functions, "libsass_load_functions"))
|
59
60
|
{
|
60
|
-
|
61
|
+
Sass_Function_List fns = plugin_load_functions();
|
61
62
|
while (fns && *fns) { functions.push_back(*fns); ++ fns; }
|
62
63
|
}
|
64
|
+
// try to get import address for "libsass_load_importers"
|
65
|
+
if (LOAD_LIB_FN(__plugin_load_imps__, plugin_load_importers, "libsass_load_importers"))
|
66
|
+
{
|
67
|
+
Sass_Importer_List imps = plugin_load_importers();
|
68
|
+
while (imps && *imps) { importers.push_back(*imps); ++ imps; }
|
69
|
+
}
|
70
|
+
// try to get import address for "libsass_load_headers"
|
71
|
+
if (LOAD_LIB_FN(__plugin_load_imps__, plugin_load_headers, "libsass_load_headers"))
|
72
|
+
{
|
73
|
+
Sass_Importer_List imps = plugin_load_headers();
|
74
|
+
while (imps && *imps) { headers.push_back(*imps); ++ imps; }
|
75
|
+
}
|
63
76
|
// success
|
64
77
|
return true;
|
65
78
|
}
|
data/ext/libsass/plugins.hpp
CHANGED
@@ -42,12 +42,14 @@ namespace Sass {
|
|
42
42
|
size_t load_plugins(const string& path);
|
43
43
|
|
44
44
|
public: // public accessors
|
45
|
-
|
46
|
-
const vector<
|
45
|
+
const vector<Sass_Importer_Entry> get_headers(void) { return headers; };
|
46
|
+
const vector<Sass_Importer_Entry> get_importers(void) { return importers; };
|
47
|
+
const vector<Sass_Function_Entry> get_functions(void) { return functions; };
|
47
48
|
|
48
49
|
private: // private vars
|
49
|
-
|
50
|
-
vector<
|
50
|
+
vector<Sass_Importer_Entry> headers;
|
51
|
+
vector<Sass_Importer_Entry> importers;
|
52
|
+
vector<Sass_Function_Entry> functions;
|
51
53
|
|
52
54
|
};
|
53
55
|
|
data/ext/libsass/position.cpp
CHANGED
@@ -19,20 +19,42 @@ namespace Sass {
|
|
19
19
|
Offset::Offset(const size_t line, const size_t column)
|
20
20
|
: line(line), column(column) { }
|
21
21
|
|
22
|
+
// init/create instance from const char substring
|
23
|
+
Offset Offset::init(const char* beg, const char* end)
|
24
|
+
{
|
25
|
+
Offset offset(0, 0);
|
26
|
+
if (end == 0) {
|
27
|
+
end += strlen(beg);
|
28
|
+
}
|
29
|
+
offset.add(beg, end);
|
30
|
+
return offset;
|
31
|
+
}
|
32
|
+
|
22
33
|
// increase offset by given string (mostly called by lexer)
|
23
34
|
// increase line counter and count columns on the last line
|
24
|
-
|
35
|
+
// ToDo: make the col count utf8 aware
|
36
|
+
Offset Offset::add(const char* begin, const char* end)
|
25
37
|
{
|
26
|
-
|
38
|
+
if (end == 0) return *this;
|
27
39
|
while (begin < end && *begin) {
|
28
40
|
if (*begin == '\n') {
|
29
|
-
++
|
30
|
-
|
41
|
+
++ line;
|
42
|
+
// start new line
|
43
|
+
column = 0;
|
31
44
|
} else {
|
32
|
-
++
|
45
|
+
++ column;
|
33
46
|
}
|
34
47
|
++begin;
|
35
48
|
}
|
49
|
+
return *this;
|
50
|
+
}
|
51
|
+
|
52
|
+
// increase offset by given string (mostly called by lexer)
|
53
|
+
// increase line counter and count columns on the last line
|
54
|
+
Offset Offset::inc(const char* begin, const char* end) const
|
55
|
+
{
|
56
|
+
Offset offset(line, column);
|
57
|
+
offset.add(begin, end);
|
36
58
|
return offset;
|
37
59
|
}
|
38
60
|
|
@@ -48,12 +70,17 @@ namespace Sass {
|
|
48
70
|
|
49
71
|
void Offset::operator+= (const Offset &off)
|
50
72
|
{
|
51
|
-
*this = Offset(line + off.line, off.line > 0 ? off.column :
|
73
|
+
*this = Offset(line + off.line, off.line > 0 ? off.column : column + off.column);
|
52
74
|
}
|
53
75
|
|
54
76
|
Offset Offset::operator+ (const Offset &off) const
|
55
77
|
{
|
56
|
-
return Offset(line + off.line, off.line > 0 ? off.column :
|
78
|
+
return Offset(line + off.line, off.line > 0 ? off.column : column + off.column);
|
79
|
+
}
|
80
|
+
|
81
|
+
Offset Offset::operator- (const Offset &off) const
|
82
|
+
{
|
83
|
+
return Offset(line - off.line, off.line == line ? column - off.column : column);
|
57
84
|
}
|
58
85
|
|
59
86
|
Position::Position(const size_t file)
|
@@ -69,17 +96,20 @@ namespace Sass {
|
|
69
96
|
: Offset(line, column), file(file) { }
|
70
97
|
|
71
98
|
|
72
|
-
ParserState::ParserState(string path)
|
73
|
-
: Position(
|
99
|
+
ParserState::ParserState(string path, const char* src, const size_t file)
|
100
|
+
: Position(file, 0, 0), path(path), src(src), offset(0, 0), token() { }
|
74
101
|
|
75
|
-
ParserState::ParserState(string path, const
|
76
|
-
: Position(
|
102
|
+
ParserState::ParserState(string path, const char* src, Position position, Offset offset)
|
103
|
+
: Position(position), path(path), src(src), offset(offset), token() { }
|
77
104
|
|
78
|
-
ParserState::ParserState(string path, Position position, Offset offset)
|
79
|
-
: Position(position), path(path), offset(offset), token() { }
|
105
|
+
ParserState::ParserState(string path, const char* src, Token token, Position position, Offset offset)
|
106
|
+
: Position(position), path(path), src(src), offset(offset), token(token) { }
|
80
107
|
|
81
|
-
|
82
|
-
|
108
|
+
Position Position::add(const char* begin, const char* end)
|
109
|
+
{
|
110
|
+
Offset::add(begin, end);
|
111
|
+
return *this;
|
112
|
+
}
|
83
113
|
|
84
114
|
Position Position::inc(const char* begin, const char* end) const
|
85
115
|
{
|
@@ -100,12 +130,17 @@ namespace Sass {
|
|
100
130
|
|
101
131
|
void Position::operator+= (const Offset &off)
|
102
132
|
{
|
103
|
-
*this = Position(file, line + off.line, off.line > 0 ? off.column :
|
133
|
+
*this = Position(file, line + off.line, off.line > 0 ? off.column : column + off.column);
|
104
134
|
}
|
105
135
|
|
106
136
|
const Position Position::operator+ (const Offset &off) const
|
107
137
|
{
|
108
|
-
return Position(file, line + off.line, off.line > 0 ? off.column :
|
138
|
+
return Position(file, line + off.line, off.line > 0 ? off.column : column + off.column);
|
139
|
+
}
|
140
|
+
|
141
|
+
const Offset Position::operator- (const Offset &off) const
|
142
|
+
{
|
143
|
+
return Offset(line - off.line, off.line == line ? column - off.column : column);
|
109
144
|
}
|
110
145
|
|
111
146
|
/* not used anymore - remove?
|
data/ext/libsass/position.hpp
CHANGED
@@ -19,13 +19,18 @@ namespace Sass {
|
|
19
19
|
Offset(const size_t line, const size_t column);
|
20
20
|
|
21
21
|
// return new position, incremented by the given string
|
22
|
+
Offset add(const char* begin, const char* end);
|
22
23
|
Offset inc(const char* begin, const char* end) const;
|
23
24
|
|
25
|
+
// init/create instance from const char substring
|
26
|
+
static Offset init(const char* beg, const char* end);
|
27
|
+
|
24
28
|
public: // overload operators for position
|
25
29
|
void operator+= (const Offset &pos);
|
26
30
|
bool operator== (const Offset &pos) const;
|
27
31
|
bool operator!= (const Offset &pos) const;
|
28
32
|
Offset operator+ (const Offset &off) const;
|
33
|
+
Offset operator- (const Offset &off) const;
|
29
34
|
|
30
35
|
public: // overload output stream operator
|
31
36
|
// friend ostream& operator<<(ostream& strm, const Offset& off);
|
@@ -52,7 +57,9 @@ namespace Sass {
|
|
52
57
|
bool operator== (const Position &pos) const;
|
53
58
|
bool operator!= (const Position &pos) const;
|
54
59
|
const Position operator+ (const Offset &off) const;
|
60
|
+
const Offset operator- (const Offset &off) const;
|
55
61
|
// return new position, incremented by the given string
|
62
|
+
Position add(const char* begin, const char* end);
|
56
63
|
Position inc(const char* begin, const char* end) const;
|
57
64
|
|
58
65
|
public: // overload output stream operator
|
@@ -69,25 +76,19 @@ namespace Sass {
|
|
69
76
|
const char* prefix;
|
70
77
|
const char* begin;
|
71
78
|
const char* end;
|
72
|
-
const char* suffix;
|
73
|
-
Position start;
|
74
|
-
Position stop;
|
75
79
|
|
76
80
|
Token()
|
77
|
-
: prefix(0), begin(0), end(0)
|
78
|
-
Token(const char* b, const char* e
|
79
|
-
: prefix(b), begin(b), end(e)
|
80
|
-
Token(const char*
|
81
|
-
: prefix(
|
82
|
-
Token(const char* p, const char* b, const char* e
|
83
|
-
: prefix(p), begin(b), end(e)
|
81
|
+
: prefix(0), begin(0), end(0) { }
|
82
|
+
Token(const char* b, const char* e)
|
83
|
+
: prefix(b), begin(b), end(e) { }
|
84
|
+
Token(const char* str)
|
85
|
+
: prefix(str), begin(str), end(str + strlen(str)) { }
|
86
|
+
Token(const char* p, const char* b, const char* e)
|
87
|
+
: prefix(p), begin(b), end(e) { }
|
84
88
|
|
85
89
|
size_t length() const { return end - begin; }
|
86
90
|
string ws_before() const { return string(prefix, begin); }
|
87
91
|
string to_string() const { return string(begin, end); }
|
88
|
-
string ws_after() const { return string(end, suffix); }
|
89
|
-
|
90
|
-
// string unquote() const;
|
91
92
|
|
92
93
|
operator bool() { return begin && end && begin >= end; }
|
93
94
|
operator string() { return to_string(); }
|
@@ -98,17 +99,18 @@ namespace Sass {
|
|
98
99
|
class ParserState : public Position {
|
99
100
|
|
100
101
|
public: // c-tor
|
101
|
-
ParserState(string path);
|
102
|
-
ParserState(string path, const
|
103
|
-
ParserState(string path, Position position, Offset offset = Offset(0, 0));
|
104
|
-
ParserState(string path, Token token, Position position, Offset offset = Offset(0, 0));
|
102
|
+
ParserState(string path, const char* src = 0, const size_t file = string::npos);
|
103
|
+
ParserState(string path, const char* src, Position position, Offset offset = Offset(0, 0));
|
104
|
+
ParserState(string path, const char* src, Token token, Position position, Offset offset = Offset(0, 0));
|
105
105
|
|
106
106
|
public: // down casts
|
107
107
|
Offset off() { return *this; };
|
108
108
|
Position pos() { return *this; };
|
109
|
+
ParserState pstate() { return *this; };
|
109
110
|
|
110
111
|
public:
|
111
112
|
string path;
|
113
|
+
const char* src;
|
112
114
|
Offset offset;
|
113
115
|
Token token;
|
114
116
|
|