Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
55c20f98
Commit
55c20f98
authored
Apr 27, 2012
by
Andrew Nesbitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated libsass
parent
39bb89f9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
112 additions
and
119 deletions
+112
-119
Makefile
libsass/Makefile
+3
-2
context.cpp
libsass/context.cpp
+2
-4
context.hpp
libsass/context.hpp
+3
-3
document.cpp
libsass/document.cpp
+3
-2
document_parser.cpp
libsass/document_parser.cpp
+15
-21
eval_apply.cpp
libsass/eval_apply.cpp
+20
-16
functions.cpp
libsass/functions.cpp
+6
-8
functions.hpp
libsass/functions.hpp
+1
-1
node.cpp
libsass/node.cpp
+36
-37
node.hpp
libsass/node.hpp
+2
-3
node_comparisons.cpp
libsass/node_comparisons.cpp
+2
-3
prelexer.hpp
libsass/prelexer.hpp
+2
-2
sass_interface.cpp
libsass/sass_interface.cpp
+10
-10
sass_interface.h
libsass/sass_interface.h
+7
-7
No files found.
libsass/Makefile
View file @
55c20f98
...
...
@@ -11,7 +11,7 @@ CPP_FILES = \
prelexer.cpp
libsass
:
libsass_objs
ar rs libsass.a
\
ar r
v
s libsass.a
\
sass_interface.o
\
context.o
\
functions.o
\
...
...
@@ -24,7 +24,7 @@ libsass: libsass_objs
prelexer.o
libsass_objs
:
sass_interface.cpp $(CPP_FILES)
g++
-O2
-c
-combine
sass_interface.cpp
$(CPP_FILES)
g++
-O2
-
Wall
-
c
-combine
sass_interface.cpp
$(CPP_FILES)
clean
:
rm
-rf
*
.o
*
.a
\ No newline at end of file
libsass/context.cpp
View file @
55c20f98
...
...
@@ -52,8 +52,7 @@ namespace Sass {
Context
::~
Context
()
{
int
i
;
for
(
i
=
0
;
i
<
source_refs
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
source_refs
.
size
();
++
i
)
{
delete
[]
source_refs
[
i
];
}
// cerr << "Deallocated " << i << " source string(s)." << endl;
...
...
@@ -117,4 +116,4 @@ namespace Sass {
register_function
(
not_descriptor
,
not_impl
);
}
}
\ No newline at end of file
}
libsass/context.hpp
View file @
55c20f98
...
...
@@ -40,14 +40,14 @@ namespace Sass {
};
struct
Context
{
string
sass_path
;
string
css_path
;
vector
<
string
>
include_paths
;
Environment
global_env
;
map
<
pair
<
string
,
size_t
>
,
Function
>
function_env
;
vector
<
char
*>
source_refs
;
// all the source c-strings
vector
<
vector
<
Node
>*>
registry
;
// all the child vectors
vector
<
string
>
include_paths
;
size_t
ref_count
;
string
sass_path
;
string
css_path
;
void
collect_include_paths
(
const
char
*
paths_str
);
Context
(
const
char
*
paths_str
=
0
);
...
...
libsass/document.cpp
View file @
55c20f98
...
...
@@ -139,9 +139,11 @@ namespace Sass {
case
expanded
:
root
.
emit_expanded_css
(
output
,
""
);
break
;
default
:
break
;
}
string
retval
(
output
.
str
());
if
(
!
retval
.
empty
())
retval
.
resize
(
retval
.
size
()
-
1
);
return
retval
;
}
}
\ No newline at end of file
}
libsass/document_parser.cpp
View file @
55c20f98
...
...
@@ -85,6 +85,8 @@ namespace Sass {
catch
(
string
&
path
)
{
read_error
(
"error reading file
\"
"
+
path
+
"
\"
"
);
}
// unreached statement
return
Node
(
Node
::
none
);
}
Node
Document
::
parse_mixin_definition
()
...
...
@@ -370,10 +372,9 @@ namespace Sass {
else
if
(
peek
<
exactly
<
'['
>
>
(
position
))
{
return
parse_attribute_selector
();
}
else
{
syntax_error
(
"invalid selector after "
+
lexed
.
to_string
());
}
}
syntax_error
(
"invalid selector after "
+
lexed
.
to_string
());
// unreached statement
return
Node
(
Node
::
none
);}
Node
Document
::
parse_pseudo
()
{
if
(
lex
<
pseudo_not
>
())
{
...
...
@@ -420,9 +421,9 @@ namespace Sass {
else
if
(
lex
<
sequence
<
pseudo_prefix
,
identifier
>
>
())
{
return
Node
(
Node
::
pseudo
,
line_number
,
lexed
);
}
else
{
syntax_error
(
"unrecognized pseudo-class or pseudo-element"
);
}
syntax_error
(
"unrecognized pseudo-class or pseudo-element"
);
// unreached statement
return
Node
(
Node
::
none
);
}
Node
Document
::
parse_attribute_selector
()
...
...
@@ -477,7 +478,7 @@ namespace Sass {
block
.
has_statements
=
true
;
}
else
{
for
(
in
t
i
=
0
;
i
<
imported_tree
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
imported_tree
.
size
();
++
i
)
{
if
(
imported_tree
[
i
].
type
==
Node
::
comment
||
imported_tree
[
i
].
type
==
Node
::
rule
)
{
block
[
0
].
has_statements
=
true
;
...
...
@@ -503,16 +504,7 @@ namespace Sass {
block
<<
parse_propset
();
block
[
0
].
has_statements
=
true
;
}
// else if (look_for_rule(position)) {
// block << parse_rule();
// block.has_statements = true;
// semicolon = true;
// }
// else if (!peek< exactly<';'> >()) {
// block << parse_ruleset();
// block.has_blocks = true;
// }
else
if
(
const
char
*
p
=
lookahead_for_selector
(
position
))
{
else
if
(
lookahead_for_selector
(
position
))
{
block
<<
parse_ruleset
(
definition
);
block
[
0
].
has_blocks
=
true
;
}
...
...
@@ -834,6 +826,8 @@ namespace Sass {
}
syntax_error
(
"error reading values after "
+
lexed
.
to_string
());
// unreached statement
return
Node
(
Node
::
none
);
}
extern
const
char
hash_lbrace
[]
=
"#{"
;
...
...
@@ -852,7 +846,8 @@ namespace Sass {
Node
schema
(
Node
::
string_schema
,
context
.
registry
,
line_number
,
1
);
while
(
i
<
str
.
end
)
{
if
(
p
=
find_first_in_interval
<
sequence
<
negate
<
exactly
<
'\\'
>
>
,
exactly
<
hash_lbrace
>
>
>
(
i
,
str
.
end
))
{
p
=
find_first_in_interval
<
sequence
<
negate
<
exactly
<
'\\'
>
>
,
exactly
<
hash_lbrace
>
>
>
(
i
,
str
.
end
);
if
(
p
)
{
if
(
i
<
p
)
schema
<<
Node
(
Node
::
identifier
,
line_number
,
Token
::
make
(
i
,
p
));
// accumulate the preceding segment if it's nonempty
const
char
*
j
=
find_first_in_interval
<
exactly
<
rbrace
>
>
(
p
,
str
.
end
);
// find the closing brace
if
(
j
)
{
...
...
@@ -1122,4 +1117,4 @@ namespace Sass {
//
// return p;
// }
//
}
\ No newline at end of file
// }
libsass/eval_apply.cpp
View file @
55c20f98
...
...
@@ -45,7 +45,7 @@ namespace Sass {
}
break
;
case
Node
:
:
root
:
{
for
(
in
t
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
eval
(
expr
[
i
],
env
,
f_env
,
registry
);
}
return
expr
;
...
...
@@ -54,7 +54,7 @@ namespace Sass {
case
Node
:
:
block
:
{
Environment
current
;
current
.
link
(
env
);
for
(
in
t
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
eval
(
expr
[
i
],
current
,
f_env
,
registry
);
}
return
expr
;
...
...
@@ -63,7 +63,7 @@ namespace Sass {
case
Node
:
:
assignment
:
{
Node
val
(
expr
[
1
]);
if
(
val
.
type
==
Node
::
comma_list
||
val
.
type
==
Node
::
space_list
)
{
for
(
in
t
i
=
0
;
i
<
val
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
val
.
size
();
++
i
)
{
if
(
val
[
i
].
eval_me
)
val
[
i
]
=
eval
(
val
[
i
],
env
,
f_env
,
registry
);
}
}
...
...
@@ -83,7 +83,7 @@ namespace Sass {
case
Node
:
:
rule
:
{
Node
rhs
(
expr
[
1
]);
if
(
rhs
.
type
==
Node
::
comma_list
||
rhs
.
type
==
Node
::
space_list
)
{
for
(
in
t
i
=
0
;
i
<
rhs
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
rhs
.
size
();
++
i
)
{
if
(
rhs
[
i
].
eval_me
)
rhs
[
i
]
=
eval
(
rhs
[
i
],
env
,
f_env
,
registry
);
}
}
...
...
@@ -104,7 +104,7 @@ namespace Sass {
case
Node
:
:
disjunction
:
{
Node
result
;
for
(
in
t
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
// if (expr[i].type == Node::relation ||
// expr[i].type == Node::function_call && expr[0].content.token.to_string() == "not") {
result
=
eval
(
expr
[
i
],
env
,
f_env
,
registry
);
...
...
@@ -116,7 +116,7 @@ namespace Sass {
case
Node
:
:
conjunction
:
{
Node
result
;
for
(
in
t
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
result
=
eval
(
expr
[
i
],
env
,
f_env
,
registry
);
if
(
result
.
type
==
Node
::
boolean
&&
result
.
content
.
boolean_value
==
false
)
return
result
;
}
...
...
@@ -142,6 +142,9 @@ namespace Sass {
case
Node
:
:
gte
:
return
(
lhs
>=
rhs
)
?
T
:
F
;
case
Node
:
:
lt
:
return
(
lhs
<
rhs
)
?
T
:
F
;
case
Node
:
:
lte
:
return
(
lhs
<=
rhs
)
?
T
:
F
;
default:
eval_error
(
"unknown comparison operator "
+
expr
.
content
.
token
.
to_string
(),
expr
.
line_number
,
expr
.
file_name
);
return
Node
(
Node
::
none
);
}
}
break
;
...
...
@@ -150,7 +153,7 @@ namespace Sass {
acc
<<
eval
(
expr
[
0
],
env
,
f_env
,
registry
);
Node
rhs
(
eval
(
expr
[
2
],
env
,
f_env
,
registry
));
accumulate
(
expr
[
1
].
type
,
acc
,
rhs
,
registry
);
for
(
in
t
i
=
3
;
i
<
expr
.
size
();
i
+=
2
)
{
for
(
size_
t
i
=
3
;
i
<
expr
.
size
();
i
+=
2
)
{
Node
rhs
(
eval
(
expr
[
i
+
1
],
env
,
f_env
,
registry
));
accumulate
(
expr
[
i
].
type
,
acc
,
rhs
,
registry
);
}
...
...
@@ -163,7 +166,7 @@ namespace Sass {
acc
<<
eval
(
expr
[
0
],
env
,
f_env
,
registry
);
Node
rhs
(
eval
(
expr
[
2
],
env
,
f_env
,
registry
));
accumulate
(
expr
[
1
].
type
,
acc
,
rhs
,
registry
);
for
(
in
t
i
=
3
;
i
<
expr
.
size
();
i
+=
2
)
{
for
(
size_
t
i
=
3
;
i
<
expr
.
size
();
i
+=
2
)
{
Node
rhs
(
eval
(
expr
[
i
+
1
],
env
,
f_env
,
registry
));
accumulate
(
expr
[
i
].
type
,
acc
,
rhs
,
registry
);
}
...
...
@@ -248,7 +251,7 @@ namespace Sass {
case
Node
:
:
string_schema
:
case
Node
:
:
value_schema
:
{
// cerr << "evaluating schema of size " << expr.size() << endl;
for
(
in
t
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
expr
[
i
]
=
eval
(
expr
[
i
],
env
,
f_env
,
registry
);
}
return
expr
;
...
...
@@ -258,6 +261,8 @@ namespace Sass {
return
expr
;
}
}
return
expr
;
}
Node
accumulate
(
Node
::
Type
op
,
Node
&
acc
,
Node
&
rhs
,
vector
<
vector
<
Node
>*>&
registry
)
...
...
@@ -367,13 +372,13 @@ namespace Sass {
Node
body
(
mixin
[
2
].
clone
(
registry
));
Environment
bindings
;
// bind arguments
for
(
in
t
i
=
0
,
j
=
0
;
i
<
args
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
,
j
=
0
;
i
<
args
.
size
();
++
i
)
{
if
(
args
[
i
].
type
==
Node
::
assignment
)
{
Node
arg
(
args
[
i
]);
Token
name
(
arg
[
0
].
content
.
token
);
// check that the keyword arg actually names a formal parameter
bool
valid_param
=
false
;
for
(
in
t
k
=
0
;
k
<
params
.
size
();
++
k
)
{
for
(
size_
t
k
=
0
;
k
<
params
.
size
();
++
k
)
{
Node
param_k
=
params
[
k
];
if
(
param_k
.
type
==
Node
::
assignment
)
param_k
=
param_k
[
0
];
if
(
arg
[
0
]
==
param_k
)
{
...
...
@@ -400,7 +405,7 @@ namespace Sass {
}
}
// plug the holes with default arguments if any
for
(
in
t
i
=
0
;
i
<
params
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
params
.
size
();
++
i
)
{
if
(
params
[
i
].
type
==
Node
::
assignment
)
{
Node
param
(
params
[
i
]);
Token
name
(
param
[
0
].
content
.
token
);
...
...
@@ -411,7 +416,7 @@ namespace Sass {
}
// lexically link the new environment and eval the mixin's body
bindings
.
link
(
env
.
global
?
*
env
.
global
:
env
);
for
(
in
t
i
=
0
;
i
<
body
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
body
.
size
();
++
i
)
{
body
[
i
]
=
eval
(
body
[
i
],
bindings
,
f_env
,
registry
);
}
return
body
;
...
...
@@ -421,7 +426,7 @@ namespace Sass {
{
map
<
Token
,
Node
>
bindings
;
// bind arguments
for
(
in
t
i
=
0
,
j
=
0
;
i
<
args
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
,
j
=
0
;
i
<
args
.
size
();
++
i
)
{
if
(
args
[
i
].
type
==
Node
::
assignment
)
{
Node
arg
(
args
[
i
]);
Token
name
(
arg
[
0
].
content
.
token
);
...
...
@@ -436,4 +441,4 @@ namespace Sass {
return
f
(
bindings
,
registry
);
}
}
\ No newline at end of file
}
libsass/functions.cpp
View file @
55c20f98
...
...
@@ -568,12 +568,11 @@ namespace Sass {
else
if
(
!
n1
.
is_numeric
()
&&
!
n2
.
is_numeric
())
{
eval_error
(
"arguments to comparable must be numeric"
,
n1
.
line_number
,
n1
.
file_name
);
}
else
{
Node
F
(
Node
::
boolean
);
F
.
line_number
=
n1
.
line_number
;
F
.
content
.
boolean_value
=
false
;
return
F
;
}
Node
F
(
Node
::
boolean
);
F
.
line_number
=
n1
.
line_number
;
F
.
content
.
boolean_value
=
false
;
return
F
;
}
// Boolean Functions ///////////////////////////////////////////////////
...
...
@@ -597,4 +596,4 @@ namespace Sass {
}
}
\ No newline at end of file
}
libsass/functions.hpp
View file @
55c20f98
...
...
@@ -30,7 +30,7 @@ namespace Sass {
while
(
d
[
len
+
1
])
++
len
;
parameters
.
reserve
(
len
);
for
(
in
t
i
=
0
;
i
<
len
;
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
len
;
++
i
)
{
const
char
*
p
=
d
[
i
+
1
];
Token
name
(
Token
::
make
(
p
,
p
+
std
::
strlen
(
p
)));
parameters
.
push_back
(
name
);
...
...
libsass/node.cpp
View file @
55c20f98
This diff is collapsed.
Click to expand it.
libsass/node.hpp
View file @
55c20f98
...
...
@@ -190,7 +190,7 @@ namespace Sass {
Node
&
operator
+=
(
const
Node
&
n
)
{
for
(
in
t
i
=
0
;
i
<
n
.
size
();
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
n
.
size
();
++
i
)
{
content
.
children
->
push_back
(
n
[
i
]);
}
return
*
this
;
...
...
@@ -278,4 +278,4 @@ namespace Sass {
~
Node
()
{
++
destructed
;
}
};
}
\ No newline at end of file
}
libsass/node_comparisons.cpp
View file @
55c20f98
...
...
@@ -25,7 +25,7 @@ namespace Sass {
case
space_list
:
case
expression
:
case
term
:
{
for
(
in
t
i
=
0
;
i
<
size
();
++
i
)
{
for
(
size_
t
i
=
0
;
i
<
size
();
++
i
)
{
if
(
at
(
i
)
==
rhs
[
i
])
continue
;
else
return
false
;
}
...
...
@@ -101,4 +101,4 @@ namespace Sass {
bool
Node
::
operator
>=
(
const
Node
&
rhs
)
const
{
return
!
(
*
this
<
rhs
);
}
}
\ No newline at end of file
}
libsass/prelexer.hpp
View file @
55c20f98
...
...
@@ -388,8 +388,8 @@ namespace Sass {
template
<
prelexer
mx
>
const
char
*
find_first_in_interval
(
const
char
*
beg
,
const
char
*
end
)
{
while
((
beg
<
end
)
&&
*
beg
)
{
const
char
*
p
;
if
(
p
=
mx
(
beg
)
)
return
p
;
const
char
*
p
=
mx
(
beg
)
;
if
(
p
)
return
p
;
++
beg
;
}
return
0
;
...
...
libsass/sass_interface.cpp
View file @
55c20f98
...
...
@@ -13,26 +13,28 @@ extern "C" {
using
namespace
std
;
sass_context
*
sass_new_context
()
{
return
(
sass_context
*
)
malloc
(
sizeof
(
sass_context
));
}
{
return
(
sass_context
*
)
calloc
(
1
,
sizeof
(
sass_context
));
}
void
sass_free_context
(
sass_context
*
ctx
)
{
free
(
ctx
->
output_string
);
if
(
ctx
->
output_string
)
free
(
ctx
->
output_string
);
free
(
ctx
);
}
sass_file_context
*
sass_new_file_context
()
{
return
(
sass_file_context
*
)
malloc
(
sizeof
(
sass_file_context
));
}
{
return
(
sass_file_context
*
)
calloc
(
1
,
sizeof
(
sass_file_context
));
}
void
sass_free_file_context
(
sass_file_context
*
ctx
)
{
free
(
ctx
->
output_string
);
if
(
ctx
->
output_string
)
free
(
ctx
->
output_string
);
free
(
ctx
);
}
sass_folder_context
*
sass_new_folder_context
()
{
return
(
sass_folder_context
*
)
malloc
(
sizeof
(
sass_folder_context
));
}
{
return
(
sass_folder_context
*
)
calloc
(
1
,
sizeof
(
sass_folder_context
));
}
static
char
*
process_document
(
Sass
::
Document
&
doc
,
int
style
)
{
using
namespace
Sass
;
...
...
@@ -47,8 +49,7 @@ extern "C" {
// cerr << "Destructions:\t" << Node::destructed << endl;
// cerr << "Registry size:\t" << doc.context.registry.size() << endl;
int
i
;
for
(
i
=
0
;
i
<
doc
.
context
.
registry
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
doc
.
context
.
registry
.
size
();
++
i
)
{
delete
doc
.
context
.
registry
[
i
];
}
// cerr << "Deallocations:\t" << i << endl;
...
...
@@ -133,4 +134,4 @@ extern "C" {
return
1
;
}
}
\ No newline at end of file
}
libsass/sass_interface.h
View file @
55c20f98
...
...
@@ -2,10 +2,10 @@
extern
"C"
{
#endif
#define SASS_STYLE_NESTED 0
;
#define SASS_STYLE_EXPANDED 1
;
#define SASS_STYLE_COMPACT 2
;
#define SASS_STYLE_COMPRESSED 3
;
#define SASS_STYLE_NESTED 0
#define SASS_STYLE_EXPANDED 1
#define SASS_STYLE_COMPACT 2
#define SASS_STYLE_COMPRESSED 3
struct
sass_options
{
int
output_style
;
...
...
@@ -36,9 +36,9 @@ struct sass_folder_context {
char
*
error_message
;
};
struct
sass_context
*
sass_new_context
();
struct
sass_file_context
*
sass_new_file_context
();
struct
sass_folder_context
*
sass_new_folder_context
();
struct
sass_context
*
sass_new_context
(
void
);
struct
sass_file_context
*
sass_new_file_context
(
void
);
struct
sass_folder_context
*
sass_new_folder_context
(
void
);
void
sass_free_context
(
struct
sass_context
*
ctx
);
void
sass_free_file_context
(
struct
sass_file_context
*
ctx
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment