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
cb03bb0b
Commit
cb03bb0b
authored
Mar 20, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working on getting expressions to print out. Next step is evaluation.
parent
7ca92b95
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
123 additions
and
82 deletions
+123
-82
document_parser.cpp
document_parser.cpp
+4
-9
lists.scss
lists.scss
+13
-0
node.cpp
node.cpp
+105
-2
node.hpp
node.hpp
+1
-71
No files found.
document_parser.cpp
View file @
cb03bb0b
...
...
@@ -304,7 +304,8 @@ namespace Sass {
// if it's a singleton, return it directly; don't wrap it
if
(
peek
<
exactly
<
';'
>
>
(
position
)
||
peek
<
exactly
<
'}'
>
>
(
position
)
||
peek
<
exactly
<
')'
>
>
(
position
))
peek
<
exactly
<
')'
>
>
(
position
)
||
peek
<
exactly
<
','
>
>
(
position
))
{
return
expr1
;
}
Node
space_list
(
line_number
,
Node
::
space_list
,
2
);
...
...
@@ -312,7 +313,8 @@ namespace Sass {
while
(
!
(
peek
<
exactly
<
';'
>
>
(
position
)
||
peek
<
exactly
<
'}'
>
>
(
position
)
||
peek
<
exactly
<
')'
>
>
(
position
)))
peek
<
exactly
<
')'
>
>
(
position
)
||
peek
<
exactly
<
','
>
>
(
position
)))
{
space_list
<<
parse_expression
();
}
return
space_list
;
...
...
@@ -393,13 +395,6 @@ namespace Sass {
}
}
// const char* Document::look_for_rule(const char* start)
// {
// const char* p = start ? start : position;
...
...
lists.scss
View file @
cb03bb0b
$x
:
1
2
3
;
div
{
a
:
42
$x
43
;
b
:
1
,
2
3
,
4
;
c
:
1
/
2
;
d
:
(
10px
/
3em
);
d
:
(
10
/
5px
);
}
/*div {
a: a, b, c, d;
b: a b, c d;
c: a (b, c) d;
...
...
@@ -11,3 +22,4 @@ div {
i: 4 - (2) 3;
j: 3 + $x;
}
*/
\ No newline at end of file
node.cpp
View file @
cb03bb0b
...
...
@@ -13,6 +13,108 @@ namespace Sass {
size_t
Node
::
fresh
=
0
;
size_t
Node
::
copied
=
0
;
string
Node
::
to_string
(
const
string
&
prefix
)
{
switch
(
type
)
{
case
selector_group
:
{
// really only needed for arg to :not
string
result
(
children
->
at
(
0
).
to_string
(
""
));
for
(
int
i
=
1
;
i
<
children
->
size
();
++
i
)
{
result
+=
", "
;
result
+=
children
->
at
(
i
).
to_string
(
""
);
}
return
result
;
}
break
;
case
selector
:
{
string
result
;
if
(
!
has_backref
&&
!
prefix
.
empty
())
{
result
+=
prefix
;
result
+=
' '
;
}
if
(
children
->
at
(
0
).
type
==
selector_combinator
)
{
result
+=
string
(
children
->
at
(
0
).
token
);
result
+=
' '
;
}
else
{
result
+=
children
->
at
(
0
).
to_string
(
prefix
);
}
for
(
int
i
=
1
;
i
<
children
->
size
();
++
i
)
{
result
+=
children
->
at
(
i
).
to_string
(
prefix
);
}
return
result
;
}
break
;
case
selector_combinator
:
{
if
(
std
::
isspace
(
token
.
begin
[
0
]))
return
string
(
" "
);
else
return
string
(
" "
)
+=
string
(
token
)
+=
string
(
" "
);
}
break
;
case
simple_selector_sequence
:
{
string
result
;
for
(
int
i
=
0
;
i
<
children
->
size
();
++
i
)
{
result
+=
children
->
at
(
i
).
to_string
(
prefix
);
}
return
result
;
}
break
;
case
pseudo_negation
:
{
string
result
(
children
->
at
(
0
).
to_string
(
prefix
));
result
+=
children
->
at
(
1
).
to_string
(
prefix
);
result
+=
')'
;
return
result
;
}
break
;
case
functional_pseudo
:
{
string
result
(
children
->
at
(
0
).
to_string
(
prefix
));
for
(
int
i
=
1
;
i
<
children
->
size
();
++
i
)
{
result
+=
children
->
at
(
i
).
to_string
(
prefix
);
}
result
+=
')'
;
return
result
;
}
break
;
case
attribute_selector
:
{
string
result
(
"["
);
result
+=
children
->
at
(
0
).
to_string
(
prefix
);
result
+=
children
->
at
(
1
).
to_string
(
prefix
);
result
+=
children
->
at
(
2
).
to_string
(
prefix
);
result
+=
']'
;
return
result
;
}
break
;
case
backref
:
{
return
prefix
;
}
break
;
case
comma_list
:
{
string
result
(
children
->
at
(
0
).
to_string
(
prefix
));
for
(
int
i
=
1
;
i
<
children
->
size
();
++
i
)
{
result
+=
", "
;
result
+=
children
->
at
(
i
).
to_string
(
prefix
);
}
return
result
;
}
break
;
case
space_list
:
{
string
result
(
children
->
at
(
0
).
to_string
(
prefix
));
for
(
int
i
=
1
;
i
<
children
->
size
();
++
i
)
{
result
+=
" "
;
result
+=
children
->
at
(
i
).
to_string
(
prefix
);
}
return
result
;
}
break
;
case
value
:
{
return
string
(
token
);
}
break
;
default
:
{
// return string(token);
}
break
;
}
}
void
Node
::
echo
(
stringstream
&
buf
,
size_t
depth
)
{
string
indentation
(
2
*
depth
,
' '
);
switch
(
type
)
{
...
...
@@ -56,7 +158,7 @@ namespace Sass {
case
rule
:
buf
<<
indentation
;
children
->
at
(
0
).
echo
(
buf
,
depth
);
buf
<<
':'
;
buf
<<
": "
;
children
->
at
(
1
).
echo
(
buf
,
depth
);
buf
<<
';'
<<
endl
;
break
;
...
...
@@ -142,7 +244,7 @@ namespace Sass {
buf
<<
";"
;
break
;
case
property
:
buf
<<
string
(
token
)
<<
":"
;
buf
<<
string
(
token
)
<<
":
"
;
break
;
case
values
:
for
(
int
i
=
0
;
i
<
children
->
size
();
++
i
)
{
...
...
@@ -155,6 +257,7 @@ namespace Sass {
if
(
depth
==
0
)
buf
<<
endl
;
break
;
default
:
buf
<<
to_string
(
""
);
break
;
}
}
...
...
node.hpp
View file @
cb03bb0b
...
...
@@ -155,77 +155,7 @@ namespace Sass {
return
*
this
;
}
string
to_string
(
const
string
&
prefix
)
{
if
(
type
==
selector_group
)
{
// really only needed for arg to :not
string
result
(
children
->
at
(
0
).
to_string
(
""
));
for
(
int
i
=
1
;
i
<
children
->
size
();
++
i
)
{
result
+=
", "
;
result
+=
children
->
at
(
i
).
to_string
(
""
);
}
return
result
;
}
else
if
(
type
==
selector
)
{
string
result
;
if
(
!
has_backref
&&
!
prefix
.
empty
())
{
result
+=
prefix
;
result
+=
' '
;
}
if
(
children
->
at
(
0
).
type
==
selector_combinator
)
{
result
+=
string
(
children
->
at
(
0
).
token
);
result
+=
' '
;
}
else
{
result
+=
children
->
at
(
0
).
to_string
(
prefix
);
}
for
(
int
i
=
1
;
i
<
children
->
size
();
++
i
)
{
result
+=
children
->
at
(
i
).
to_string
(
prefix
);
}
return
result
;
}
else
if
(
type
==
selector_combinator
)
{
if
(
std
::
isspace
(
token
.
begin
[
0
]))
return
string
(
" "
);
else
return
string
(
" "
)
+=
string
(
token
)
+=
string
(
" "
);
}
else
if
(
type
==
simple_selector_sequence
)
{
string
result
;
for
(
int
i
=
0
;
i
<
children
->
size
();
++
i
)
{
result
+=
children
->
at
(
i
).
to_string
(
prefix
);
}
return
result
;
}
else
if
(
type
==
pseudo_negation
)
{
string
result
(
children
->
at
(
0
).
to_string
(
prefix
));
result
+=
children
->
at
(
1
).
to_string
(
prefix
);
// for (int i = 1; i < children->size(); ++i) {
// result += children->at(i).to_string("");
// }
result
+=
')'
;
return
result
;
}
else
if
(
type
==
functional_pseudo
)
{
string
result
(
children
->
at
(
0
).
to_string
(
prefix
));
for
(
int
i
=
1
;
i
<
children
->
size
();
++
i
)
{
result
+=
children
->
at
(
i
).
to_string
(
prefix
);
}
result
+=
')'
;
return
result
;
}
else
if
(
type
==
attribute_selector
)
{
string
result
(
"["
);
result
+=
children
->
at
(
0
).
to_string
(
prefix
);
result
+=
children
->
at
(
1
).
to_string
(
prefix
);
result
+=
children
->
at
(
2
).
to_string
(
prefix
);
result
+=
']'
;
return
result
;
}
else
if
(
type
==
backref
)
{
return
prefix
;
}
else
{
return
string
(
token
);
}
}
string
to_string
(
const
string
&
prefix
);
void
release
()
const
{
children
=
0
;
}
...
...
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