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
a339e8e5
Commit
a339e8e5
authored
Mar 30, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Full-on arbitrarily nested scopes for variables.
parent
974822d7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
13 deletions
+47
-13
document_parser.cpp
document_parser.cpp
+4
-4
eval_apply.cpp
eval_apply.cpp
+11
-2
mixins.scss
mixins.scss
+2
-6
sassc.cpp
sassc.cpp
+3
-1
input.scss
spec/basic/20_scoped_variables/input.scss
+18
-0
output.css
spec/basic/20_scoped_variables/output.css
+9
-0
No files found.
document_parser.cpp
View file @
a339e8e5
...
...
@@ -17,11 +17,12 @@ namespace Sass {
lex
<
exactly
<
';'
>
>
();
}
else
if
(
peek
<
mixin
>
(
position
))
{
context
.
pending
.
push_back
(
parse_mixin_definition
());
Node
mixin
(
parse_mixin_definition
());
context
.
pending
.
push_back
(
mixin
);
root
<<
mixin
;
}
else
if
(
peek
<
include
>
(
position
))
{
Node
call
(
parse_mixin_call
());
// call << root;
root
<<
call
;
root
[
0
].
has_expansions
=
true
;
lex
<
exactly
<
';'
>
>
();
...
...
@@ -31,6 +32,7 @@ namespace Sass {
Node
assn
(
parse_assignment
());
lex
<
exactly
<
';'
>
>
();
context
.
pending
.
push_back
(
assn
);
root
<<
assn
;
}
else
{
root
<<
parse_ruleset
();
...
...
@@ -337,7 +339,6 @@ namespace Sass {
}
else
if
(
peek
<
include
>
(
position
))
{
Node
call
(
parse_mixin_call
());
// call << block;
block
<<
call
;
// block.has_expansions = true;
block
[
0
].
has_expansions
=
true
;
...
...
@@ -375,7 +376,6 @@ namespace Sass {
while
(
lex
<
block_comment
>
())
{
block
<<
Node
(
line_number
,
Node
::
comment
,
lexed
);
block
[
0
].
has_rules_or_comments
=
true
;
cerr
<<
"Parsing a terminal comment: "
<<
string
(
lexed
)
<<
endl
;
}
}
return
block
;
...
...
eval_apply.cpp
View file @
a339e8e5
...
...
@@ -36,13 +36,22 @@ namespace Sass {
return
expr
;
}
break
;
case
Node
:
:
block
:
{
case
Node
:
:
root
:
{
for
(
int
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
eval
(
expr
[
i
],
env
);
}
return
expr
;
}
break
;
case
Node
:
:
block
:
{
Environment
current
;
current
.
link
(
env
);
for
(
int
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
eval
(
expr
[
i
],
current
);
}
return
expr
;
}
break
;
case
Node
:
:
assignment
:
{
Node
val
(
expr
[
1
]);
if
(
val
.
type
==
Node
::
comma_list
||
val
.
type
==
Node
::
space_list
)
{
...
...
@@ -71,7 +80,7 @@ namespace Sass {
}
}
else
{
expr
[
1
]
=
eval
(
rhs
,
env
);
if
(
rhs
.
eval_me
)
expr
[
1
]
=
eval
(
rhs
,
env
);
}
return
expr
;
}
break
;
...
...
mixins.scss
View file @
a339e8e5
...
...
@@ -3,12 +3,10 @@ $y: global-y;
$z
:
global-z
;
@mixin
foo
(
$x
,
$y
)
{
/* begin foo */
margin
:
$x
$y
;
blip
{
hey
:
now
;
}
/* end foo */
}
@mixin
foogoo
(
$x
,
$y
,
$z
)
{
...
...
@@ -16,17 +14,15 @@ $z: global-z;
}
@mixin
hux
(
$y
)
{
/* begin hux */
color
:
$y
;
@include
foo
(
called-from-hux
);
/* end hux */
}
div
{
@include
foo
(
1
,
2
);
@include
foo
(
1
);
@include
foogoo
(
1
,
2
);
@include
foogoo
(
$y
/*
blah
*/
:
kwd-y
,
$z
:
kwd-z
);
@include
foogoo
(
$y
:
kwd-y
,
$z
:
kwd-z
);
}
div
{
...
...
@@ -56,7 +52,6 @@ div {
}
div
{
/* calls to nullary mixins may omit the empty argument list */
@include
bung
;
}
...
...
@@ -66,6 +61,7 @@ div {
}
@mixin
ruleset
()
{
moo
:
goo
;
hoo
{
color
:
boo
;
}
...
...
sassc.cpp
View file @
a339e8e5
...
...
@@ -2,6 +2,7 @@
#include <string>
#include <map>
#include "document.hpp"
#include "eval_apply.hpp"
using
namespace
Sass
;
using
namespace
std
;
...
...
@@ -30,7 +31,8 @@ int main(int argc, char* argv[]) {
Document
doc
(
path
,
0
);
doc
.
parse_scss
();
cerr
<<
"SUCCESSFULLY PARSED DOCUMENT"
<<
endl
;
doc
.
eval_pending
();
// doc.eval_pending();
eval
(
doc
.
root
,
doc
.
context
.
global_env
);
cerr
<<
"SUCCESSFULLY EVALED DOCUMENT"
<<
endl
;
string
output
=
doc
.
emit_css
(
style
);
...
...
spec/basic/20_scoped_variables/input.scss
0 → 100644
View file @
a339e8e5
@mixin
foo
()
{
/* begin foo */
/* assigning to $x */
$x
:
inside
foo
;
x
:
$x
;
/* end foo */
}
outer
{
/* assigning to $x */
$x
:
inside
outer
scope
;
blah
:
blah
;
inner
{
@include
foo
();
x
:
$x
;
}
}
\ No newline at end of file
spec/basic/20_scoped_variables/output.css
0 → 100644
View file @
a339e8e5
outer
{
/* assigning to $x */
blah
:
blah
;
}
outer
inner
{
/* begin foo */
/* assigning to $x */
x
:
inside
foo
;
/* end foo */
x
:
inside
outer
scope
;
}
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