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
5bd4581b
Commit
5bd4581b
authored
Oct 04, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'expand-eval-apply'
Conflicts: eval_apply.cpp
parents
580c318b
e44e4923
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
35 deletions
+37
-35
document_parser.cpp
document_parser.cpp
+9
-17
eval_apply.cpp
eval_apply.cpp
+0
-0
eval_apply.hpp
eval_apply.hpp
+4
-2
node.cpp
node.cpp
+4
-2
node.hpp
node.hpp
+12
-7
node_emitters.cpp
node_emitters.cpp
+2
-1
sass_interface.cpp
sass_interface.cpp
+6
-6
No files found.
document_parser.cpp
View file @
5bd4581b
...
...
@@ -202,7 +202,7 @@ namespace Sass {
if
(
!
lex
<
identifier
>
())
throw_syntax_error
(
"invalid name in @include directive"
);
Node
name
(
context
.
new_Node
(
Node
::
identifier
,
path
,
line
,
lexed
));
Node
args
(
parse_arguments
());
Node
the_call
(
context
.
new_Node
(
Node
::
expansion
,
path
,
line
,
2
));
Node
the_call
(
context
.
new_Node
(
Node
::
mixin_call
,
path
,
line
,
2
));
the_call
<<
name
<<
args
;
return
the_call
;
}
...
...
@@ -215,12 +215,10 @@ namespace Sass {
if
(
lex
<
exactly
<
'('
>
>
())
{
if
(
!
peek
<
exactly
<
')'
>
>
(
position
))
{
Node
arg
(
parse_argument
(
Node
::
none
));
arg
.
should_eval
()
=
true
;
args
<<
arg
;
if
(
arg
.
type
()
==
Node
::
assignment
)
arg_type
=
Node
::
assignment
;
while
(
lex
<
exactly
<
','
>
>
())
{
Node
arg
(
parse_argument
(
arg_type
));
arg
.
should_eval
()
=
true
;
args
<<
arg
;
if
(
arg
.
type
()
==
Node
::
assignment
)
arg_type
=
Node
::
assignment
;
}
...
...
@@ -239,6 +237,7 @@ namespace Sass {
Node
var
(
context
.
new_Node
(
Node
::
variable
,
path
,
line
,
lexed
));
lex
<
exactly
<
':'
>
>
();
Node
val
(
parse_space_list
());
val
.
should_eval
()
=
true
;
Node
assn
(
context
.
new_Node
(
Node
::
assignment
,
path
,
line
,
2
));
assn
<<
var
<<
val
;
return
assn
;
...
...
@@ -254,23 +253,14 @@ namespace Sass {
Node
var
(
context
.
new_Node
(
Node
::
variable
,
path
,
line
,
lexed
));
lex
<
exactly
<
':'
>
>
();
Node
val
(
parse_space_list
());
val
.
should_eval
()
=
true
;
Node
assn
(
context
.
new_Node
(
Node
::
assignment
,
path
,
line
,
2
));
assn
<<
var
<<
val
;
return
assn
;
}
return
parse_space_list
();
// if (peek< sequence < variable, spaces_and_comments, exactly<':'> > >()) {
// lex< variable >();
// Node var(context.new_Node(Node::variable, path, line, lexed));
// lex< exactly<':'> >();
// Node val(parse_space_list());
// Node assn(context.new_Node(Node::assignment, path, line, 2));
// assn << var << val;
// return assn;
// }
// else {
// return parse_space_list();
// }
Node
val
(
parse_space_list
());
val
.
should_eval
()
=
true
;
return
val
;
}
Node
Document
::
parse_assignment
()
...
...
@@ -598,7 +588,7 @@ namespace Sass {
semicolon
=
true
;
}
else
if
(
lex
<
extend
>
())
{
if
(
surrounding_ruleset
.
is_null
_ptr
())
throw_syntax_error
(
"@extend directive may only be used within rules"
);
if
(
surrounding_ruleset
.
is_null
())
throw_syntax_error
(
"@extend directive may only be used within rules"
);
Node
extendee
(
parse_simple_selector_sequence
());
context
.
extensions
.
insert
(
pair
<
Node
,
Node
>
(
extendee
,
surrounding_ruleset
));
context
.
has_extensions
=
true
;
...
...
@@ -1016,6 +1006,7 @@ namespace Sass {
if
(
lex
<
interpolant
>
())
{
Token
insides
(
Token
::
make
(
lexed
.
begin
+
2
,
lexed
.
end
-
1
));
Node
interp_node
(
Document
::
make_from_token
(
context
,
insides
,
path
,
line
).
parse_list
());
interp_node
.
should_eval
()
=
true
;
schema
<<
interp_node
;
}
else
if
(
lex
<
identifier
>
())
{
...
...
@@ -1080,6 +1071,7 @@ namespace Sass {
else
if
(
lex
<
interpolant
>
())
{
Token
insides
(
Token
::
make
(
lexed
.
begin
+
2
,
lexed
.
end
-
1
));
Node
interp_node
(
Document
::
make_from_token
(
context
,
insides
,
path
,
line
).
parse_list
());
interp_node
.
should_eval
()
=
true
;
schema
<<
interp_node
;
}
else
if
(
lex
<
sequence
<
identifier
,
exactly
<
':'
>
>
>
())
{
...
...
eval_apply.cpp
View file @
5bd4581b
This diff is collapsed.
Click to expand it.
eval_apply.hpp
View file @
5bd4581b
...
...
@@ -12,9 +12,11 @@
namespace
Sass
{
using
std
::
map
;
void
expand
(
Node
expr
,
Node
prefix
,
Environment
&
env
,
map
<
string
,
Function
>&
f_env
,
Node_Factory
&
new_Node
,
Context
&
ctx
,
bool
function_name
=
false
);
Node
eval
(
Node
expr
,
Node
prefix
,
Environment
&
env
,
map
<
string
,
Function
>&
f_env
,
Node_Factory
&
new_Node
,
Context
&
ctx
,
bool
function_name
=
false
);
Node
function_eval
(
string
name
,
Node
stm
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
Context
&
ctx
,
bool
toplevel
=
false
);
Node
eval_arguments
(
Node
args
,
Node
prefix
,
Environment
&
env
,
map
<
string
,
Function
>&
f_env
,
Node_Factory
&
new_Node
,
Context
&
ctx
);
Node
eval_function
(
string
name
,
Node
stm
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
Context
&
ctx
,
bool
toplevel
=
false
);
Node
reduce
(
Node
list
,
size_t
head
,
Node
acc
,
Node_Factory
&
new_Node
);
Node
accumulate
(
Node
::
Type
op
,
Node
acc
,
Node
rhs
,
Node_Factory
&
new_Node
);
double
operate
(
Node
op
,
double
lhs
,
double
rhs
);
...
...
node.cpp
View file @
5bd4581b
...
...
@@ -18,8 +18,9 @@ namespace Sass {
switch
(
type
())
{
case
block
:
case
expansion
:
case
mixin_call
:
case
root
:
case
if_directive
:
case
for_through_directive
:
case
for_to_directive
:
case
each_directive
:
...
...
@@ -33,8 +34,9 @@ namespace Sass {
for
(
size_t
i
=
0
;
i
<
size
();
++
i
)
{
switch
(
at
(
i
).
type
())
{
case
expansion
:
case
mixin_call
:
case
block
:
case
if_directive
:
case
for_through_directive
:
case
for_to_directive
:
case
each_directive
:
...
...
node.hpp
View file @
5bd4581b
...
...
@@ -150,11 +150,11 @@ namespace Sass {
identifier_schema
,
css_import
,
function
,
function_call
,
mixin
,
function
,
mixin_call
,
parameters
,
expansion
,
arguments
,
if_directive
,
...
...
@@ -177,8 +177,8 @@ namespace Sass {
Node
(
Node_Impl
*
ip
=
0
);
Type
type
()
const
;
Type
type
(
Type
);
bool
is_none
()
const
;
bool
has_children
()
const
;
bool
has_statements
()
const
;
bool
has_blocks
()
const
;
...
...
@@ -204,6 +204,7 @@ namespace Sass {
Node
&
back
()
const
;
Node
&
operator
[](
size_t
i
)
const
;
void
pop_back
();
void
pop_all
();
Node
&
push_back
(
Node
n
);
Node
&
push_front
(
Node
n
);
Node
&
operator
<<
(
Node
n
);
...
...
@@ -220,7 +221,7 @@ namespace Sass {
Token
token
()
const
;
Token
unit
()
const
;
bool
is_null
_ptr
()
const
{
return
!
ip_
;
}
bool
is_null
()
const
{
return
!
ip_
;
}
bool
is
(
Node
n
)
const
{
return
ip_
==
n
.
ip_
;
}
void
flatten
();
...
...
@@ -369,7 +370,7 @@ namespace Sass {
case
Node
:
:
for_to_directive
:
case
Node
:
:
each_directive
:
case
Node
:
:
while_directive
:
case
Node
:
:
expansion
:
{
case
Node
:
:
mixin_call
:
{
has_expansions
=
true
;
}
break
;
...
...
@@ -401,7 +402,7 @@ namespace Sass {
case
Node
:
:
for_to_directive
:
case
Node
:
:
each_directive
:
case
Node
:
:
while_directive
:
case
Node
:
:
expansion
:
has_expansions
=
true
;
break
;
case
Node
:
:
mixin_call
:
has_expansions
=
true
;
break
;
case
Node
:
:
backref
:
has_backref
=
true
;
break
;
...
...
@@ -413,6 +414,9 @@ namespace Sass {
void
pop_back
()
{
children
.
pop_back
();
}
void
pop_all
()
{
for
(
size_t
i
=
0
,
S
=
size
();
i
<
S
;
++
i
)
pop_back
();
}
bool
&
boolean_value
()
{
return
value
.
boolean
;
}
...
...
@@ -430,8 +434,8 @@ namespace Sass {
inline
Node
::
Node
(
Node_Impl
*
ip
)
:
ip_
(
ip
)
{
}
inline
Node
::
Type
Node
::
type
()
const
{
return
ip_
->
type
;
}
inline
Node
::
Type
Node
::
type
(
Type
t
)
{
return
ip_
->
type
=
t
;
}
inline
bool
Node
::
is_none
()
const
{
return
!
ip_
;
}
inline
bool
Node
::
has_children
()
const
{
return
ip_
->
has_children
;
}
inline
bool
Node
::
has_statements
()
const
{
return
ip_
->
has_statements
;
}
inline
bool
Node
::
has_blocks
()
const
{
return
ip_
->
has_blocks
;
}
...
...
@@ -457,6 +461,7 @@ namespace Sass {
inline
Node
&
Node
::
back
()
const
{
return
ip_
->
back
();
}
inline
Node
&
Node
::
operator
[](
size_t
i
)
const
{
return
at
(
i
);
}
inline
void
Node
::
pop_back
()
{
ip_
->
pop_back
();
}
inline
void
Node
::
pop_all
()
{
ip_
->
pop_all
();
}
inline
Node
&
Node
::
push_back
(
Node
n
)
{
ip_
->
push_back
(
n
);
...
...
node_emitters.cpp
View file @
5bd4581b
...
...
@@ -124,6 +124,7 @@ namespace Sass {
if
(
size
()
==
0
)
return
""
;
string
result
(
at
(
0
).
to_string
());
for
(
size_t
i
=
1
,
S
=
size
();
i
<
S
;
++
i
)
{
if
(
at
(
i
).
is_null
())
continue
;
if
(
at
(
i
).
type
()
==
list
&&
at
(
i
).
size
()
==
0
)
continue
;
result
+=
is_comma_separated
()
?
", "
:
" "
;
result
+=
at
(
i
).
to_string
();
...
...
@@ -270,7 +271,7 @@ namespace Sass {
return
result
;
}
break
;
case
expansion
:
{
case
mixin_call
:
{
// ignore it
return
""
;
}
break
;
...
...
sass_interface.cpp
View file @
5bd4581b
...
...
@@ -41,12 +41,12 @@ extern "C" {
{
using
namespace
Sass
;
doc
.
parse_scss
();
e
val
(
doc
.
root
,
doc
.
context
.
new_Node
(
Node
::
none
,
doc
.
path
,
doc
.
line
,
0
),
doc
.
context
.
global_env
,
doc
.
context
.
function_env
,
doc
.
context
.
new_Node
,
doc
.
context
);
e
xpand
(
doc
.
root
,
doc
.
context
.
new_Node
(
Node
::
none
,
doc
.
path
,
doc
.
line
,
0
),
doc
.
context
.
global_env
,
doc
.
context
.
function_env
,
doc
.
context
.
new_Node
,
doc
.
context
);
extend_selectors
(
doc
.
context
.
pending_extensions
,
doc
.
context
.
extensions
,
doc
.
context
.
new_Node
);
string
output
(
doc
.
emit_css
(
static_cast
<
Document
::
CSS_Style
>
(
style
)));
char
*
c_output
=
(
char
*
)
malloc
(
output
.
size
()
+
1
);
...
...
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