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
205c762a
Commit
205c762a
authored
Apr 20, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Makin' a 'nuther test pass.
parent
66f27795
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
12 deletions
+51
-12
document_parser.cpp
src/document_parser.cpp
+33
-11
node.cpp
src/node.cpp
+17
-1
node.hpp
src/node.hpp
+1
-0
No files found.
src/document_parser.cpp
View file @
205c762a
...
@@ -15,7 +15,13 @@ namespace Sass {
...
@@ -15,7 +15,13 @@ namespace Sass {
}
}
else
if
(
peek
<
import
>
(
position
))
{
else
if
(
peek
<
import
>
(
position
))
{
// TO DO: don't splice in place at parse-time -- use an expansion node
// TO DO: don't splice in place at parse-time -- use an expansion node
root
+=
parse_import
();
Node
import
(
parse_import
());
if
(
import
.
type
==
Node
::
css_import
)
{
root
<<
import
;
}
else
{
root
+=
import
;
}
if
(
!
lex
<
exactly
<
';'
>
>
())
syntax_error
(
"top-level @import directive must be terminated by ';'"
);
if
(
!
lex
<
exactly
<
';'
>
>
())
syntax_error
(
"top-level @import directive must be terminated by ';'"
);
}
}
else
if
(
peek
<
mixin
>
(
position
))
{
else
if
(
peek
<
mixin
>
(
position
))
{
...
@@ -40,7 +46,16 @@ namespace Sass {
...
@@ -40,7 +46,16 @@ namespace Sass {
Node
Document
::
parse_import
()
Node
Document
::
parse_import
()
{
{
lex
<
import
>
();
lex
<
import
>
();
if
(
!
lex
<
string_constant
>
())
syntax_error
(
"@import directive requires a quoted path"
);
if
(
lex
<
uri_prefix
>
())
{
const
char
*
beg
=
position
;
const
char
*
end
=
find_first
<
exactly
<
')'
>
>
(
position
);
Node
result
(
Node
::
css_import
,
line_number
,
Token
::
make
(
beg
,
end
));
position
=
end
;
lex
<
exactly
<
')'
>
>
();
return
result
;
}
if
(
!
lex
<
string_constant
>
())
syntax_error
(
"@import directive requires a url or quoted path"
);
// TO DO: BETTER PATH HANDLING
// TO DO: BETTER PATH HANDLING
string
import_path
(
lexed
.
unquote
());
string
import_path
(
lexed
.
unquote
());
const
char
*
curr_path_start
=
path
.
c_str
();
const
char
*
curr_path_start
=
path
.
c_str
();
...
@@ -413,17 +428,24 @@ namespace Sass {
...
@@ -413,17 +428,24 @@ namespace Sass {
syntax_error
(
"@import directive not allowed inside mixin definition"
);
syntax_error
(
"@import directive not allowed inside mixin definition"
);
}
}
Node
imported_tree
(
parse_import
());
Node
imported_tree
(
parse_import
());
for
(
int
i
=
0
;
i
<
imported_tree
.
size
();
++
i
)
{
if
(
imported_tree
.
type
==
Node
::
css_import
)
{
if
(
imported_tree
[
i
].
type
==
Node
::
comment
||
cerr
<<
"css import inside block"
<<
endl
;
imported_tree
[
i
].
type
==
Node
::
rule
)
{
block
<<
imported_tree
;
block
[
0
].
has_statements
=
true
;
block
.
has_statements
=
true
;
}
}
else
if
(
imported_tree
[
i
].
type
==
Node
::
ruleset
)
{
else
{
block
[
0
].
has_blocks
=
true
;
for
(
int
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
;
}
else
if
(
imported_tree
[
i
].
type
==
Node
::
ruleset
)
{
block
[
0
].
has_blocks
=
true
;
}
block
<<
imported_tree
[
i
];
}
}
block
<<
imported_tree
[
i
]
;
semicolon
=
true
;
}
}
semicolon
=
true
;
}
}
else
if
(
peek
<
include
>
(
position
))
{
else
if
(
peek
<
include
>
(
position
))
{
block
<<
parse_mixin_call
();
block
<<
parse_mixin_call
();
...
...
src/node.cpp
View file @
205c762a
...
@@ -174,6 +174,15 @@ namespace Sass {
...
@@ -174,6 +174,15 @@ namespace Sass {
return
"/"
;
return
"/"
;
}
break
;
}
break
;
case
css_import
:
{
stringstream
ss
;
ss
<<
"@import url("
;
ss
<<
content
.
token
.
to_string
();
cerr
<<
content
.
token
.
to_string
()
<<
endl
;
ss
<<
")"
;
return
ss
.
str
();
}
case
function_call
:
{
case
function_call
:
{
stringstream
ss
;
stringstream
ss
;
ss
<<
at
(
0
).
to_string
(
""
);
ss
<<
at
(
0
).
to_string
(
""
);
...
@@ -398,6 +407,7 @@ namespace Sass {
...
@@ -398,6 +407,7 @@ namespace Sass {
}
}
for
(
int
i
=
0
;
i
<
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
size
();
++
i
)
{
at
(
i
).
emit_nested_css
(
buf
,
depth
,
prefixes
);
at
(
i
).
emit_nested_css
(
buf
,
depth
,
prefixes
);
if
(
at
(
i
).
type
==
css_import
)
buf
<<
endl
;
}
}
break
;
break
;
...
@@ -430,7 +440,7 @@ namespace Sass {
...
@@ -430,7 +440,7 @@ namespace Sass {
buf
<<
" {"
;
buf
<<
" {"
;
for
(
int
i
=
0
;
i
<
block
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
block
.
size
();
++
i
)
{
Type
stm_type
=
block
[
i
].
type
;
Type
stm_type
=
block
[
i
].
type
;
if
(
stm_type
==
comment
||
stm_type
==
rule
)
{
if
(
stm_type
==
comment
||
stm_type
==
rule
||
stm_type
==
css_import
)
{
block
[
i
].
emit_nested_css
(
buf
,
depth
+
1
);
// NEED OVERLOADED VERSION FOR COMMENTS AND RULES
block
[
i
].
emit_nested_css
(
buf
,
depth
+
1
);
// NEED OVERLOADED VERSION FOR COMMENTS AND RULES
}
}
}
}
...
@@ -464,6 +474,12 @@ namespace Sass {
...
@@ -464,6 +474,12 @@ namespace Sass {
at
(
1
).
emit_nested_css
(
buf
,
depth
);
// values
at
(
1
).
emit_nested_css
(
buf
,
depth
);
// values
buf
<<
";"
;
buf
<<
";"
;
break
;
break
;
case
css_import
:
buf
<<
endl
<<
string
(
2
*
depth
,
' '
);
buf
<<
to_string
(
""
);
buf
<<
";"
;
break
;
case
property
:
case
property
:
buf
<<
string
(
content
.
token
)
<<
": "
;
buf
<<
string
(
content
.
token
)
<<
": "
;
...
...
src/node.hpp
View file @
205c762a
...
@@ -81,6 +81,7 @@ namespace Sass {
...
@@ -81,6 +81,7 @@ namespace Sass {
value_schema
,
value_schema
,
string_schema
,
string_schema
,
css_import
,
function_call
,
function_call
,
mixin
,
mixin
,
parameters
,
parameters
,
...
...
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