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
3663a724
Commit
3663a724
authored
Apr 23, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working on namespaced properties. Still trying to get them to emit correctly.
parent
ce72880f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
9 deletions
+73
-9
document.hpp
document.hpp
+1
-0
document_parser.cpp
document_parser.cpp
+30
-8
node.cpp
node.cpp
+41
-1
node.hpp
node.hpp
+1
-0
No files found.
document.hpp
View file @
3663a724
...
@@ -118,6 +118,7 @@ namespace Sass {
...
@@ -118,6 +118,7 @@ namespace Sass {
Node
parse_arguments
();
Node
parse_arguments
();
Node
parse_argument
();
Node
parse_argument
();
Node
parse_assignment
();
Node
parse_assignment
();
Node
parse_propset
();
Node
parse_ruleset
(
bool
definition
=
false
);
Node
parse_ruleset
(
bool
definition
=
false
);
Node
parse_selector_group
();
Node
parse_selector_group
();
Node
parse_selector
();
Node
parse_selector
();
...
...
document_parser.cpp
View file @
3663a724
...
@@ -38,10 +38,9 @@ namespace Sass {
...
@@ -38,10 +38,9 @@ namespace Sass {
root
<<
parse_assignment
();
root
<<
parse_assignment
();
if
(
!
lex
<
exactly
<
';'
>
>
())
syntax_error
(
"top-level variable binding must be terminated by ';'"
);
if
(
!
lex
<
exactly
<
';'
>
>
())
syntax_error
(
"top-level variable binding must be terminated by ';'"
);
}
}
// else if (peek< sequence< identifier, optional_spaces, exactly<':'> > >(position)) {
else
if
(
peek
<
sequence
<
identifier
,
optional_spaces
,
exactly
<
':'
>
,
optional_spaces
,
exactly
<
'{'
>
>
>
(
position
))
{
// root << parse_propset();
root
<<
parse_propset
();
// }
}
// else if (look_for_selector_group(position)) {
else
if
(
lookahead_for_selector
(
position
))
{
else
if
(
lookahead_for_selector
(
position
))
{
root
<<
parse_ruleset
();
root
<<
parse_ruleset
();
}
}
...
@@ -184,6 +183,29 @@ namespace Sass {
...
@@ -184,6 +183,29 @@ namespace Sass {
assn
<<
var
<<
val
;
assn
<<
var
<<
val
;
return
assn
;
return
assn
;
}
}
Node
Document
::
parse_propset
()
{
lex
<
identifier
>
();
Node
property_segment
(
Node
::
identifier
,
line_number
,
lexed
);
lex
<
exactly
<
':'
>
>
();
lex
<
exactly
<
'{'
>
>
();
Node
block
(
Node
::
block
,
context
.
registry
,
line_number
,
1
);
while
(
!
lex
<
exactly
<
'}'
>
>
())
{
if
(
peek
<
sequence
<
identifier
,
optional_spaces
,
exactly
<
':'
>
,
optional_spaces
,
exactly
<
'{'
>
>
>
(
position
))
{
block
<<
parse_propset
();
}
else
{
block
<<
parse_rule
();
lex
<
exactly
<
';'
>
>
();
}
}
if
(
block
.
size
()
==
0
)
syntax_error
(
"namespaced property cannot be empty"
);
Node
propset
(
Node
::
propset
,
context
.
registry
,
line_number
,
2
);
propset
<<
property_segment
;
propset
<<
block
;
return
propset
;
}
Node
Document
::
parse_ruleset
(
bool
definition
)
Node
Document
::
parse_ruleset
(
bool
definition
)
{
{
...
@@ -473,9 +495,10 @@ namespace Sass {
...
@@ -473,9 +495,10 @@ namespace Sass {
block
<<
parse_assignment
();
block
<<
parse_assignment
();
semicolon
=
true
;
semicolon
=
true
;
}
}
// else if (peek< sequence< identifier, optional_spaces, exactly<':'> > >(position)) {
else
if
(
peek
<
sequence
<
identifier
,
optional_spaces
,
exactly
<
':'
>
,
optional_spaces
,
exactly
<
'{'
>
>
>
(
position
))
{
// block << parse_propset();
block
<<
parse_propset
();
// }
block
[
0
].
has_statements
=
true
;
}
// else if (look_for_rule(position)) {
// else if (look_for_rule(position)) {
// block << parse_rule();
// block << parse_rule();
// block.has_statements = true;
// block.has_statements = true;
...
@@ -485,7 +508,6 @@ namespace Sass {
...
@@ -485,7 +508,6 @@ namespace Sass {
// block << parse_ruleset();
// block << parse_ruleset();
// block.has_blocks = true;
// block.has_blocks = true;
// }
// }
//else if (const char* p = look_for_selector_group(position)) {
else
if
(
const
char
*
p
=
lookahead_for_selector
(
position
))
{
else
if
(
const
char
*
p
=
lookahead_for_selector
(
position
))
{
block
<<
parse_ruleset
(
definition
);
block
<<
parse_ruleset
(
definition
);
block
[
0
].
has_blocks
=
true
;
block
[
0
].
has_blocks
=
true
;
...
...
node.cpp
View file @
3663a724
...
@@ -443,9 +443,12 @@ namespace Sass {
...
@@ -443,9 +443,12 @@ 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
||
stm_type
==
css_import
)
{
if
(
stm_type
==
comment
||
stm_type
==
rule
||
stm_type
==
css_import
||
stm_type
==
propset
)
{
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
}
}
// else if (stm_type == propset) {
// block[i].emit_nested_css(buf, depth, new_prefixes);
// }
}
}
buf
<<
" }"
<<
endl
;
buf
<<
" }"
<<
endl
;
++
depth
;
// if we printed content at this level, we need to indent any nested rulesets
++
depth
;
// if we printed content at this level, we need to indent any nested rulesets
...
@@ -471,6 +474,23 @@ namespace Sass {
...
@@ -471,6 +474,23 @@ namespace Sass {
{
{
switch
(
type
)
switch
(
type
)
{
{
case
propset
:
{
emit_propset
(
buf
,
depth
,
""
);
// string prefix(string(2*depth, ' ') + at(0).content.token.to_string() + "-");
// Node rules(at(1));
// for (int i = 0; i < rules.size(); ++i) {
// buf << prefix;
// if (rules[i].type == propset) {
// rules[i].emit_nested_css(buf, depth+1);
// }
// else {
// rules[i][0].emit_nested_css(buf, depth);
// rules[i][1].emit_nested_css(buf, depth);
// buf << ';';
// }
// }
}
break
;
case
rule
:
case
rule
:
buf
<<
endl
<<
string
(
2
*
depth
,
' '
);
buf
<<
endl
<<
string
(
2
*
depth
,
' '
);
at
(
0
).
emit_nested_css
(
buf
,
depth
);
// property
at
(
0
).
emit_nested_css
(
buf
,
depth
);
// property
...
@@ -505,6 +525,26 @@ namespace Sass {
...
@@ -505,6 +525,26 @@ namespace Sass {
break
;
break
;
}
}
}
}
void
Node
::
emit_propset
(
stringstream
&
buf
,
size_t
depth
,
const
string
&
prefix
)
{
string
new_prefix
(
prefix
);
if
(
new_prefix
.
empty
())
new_prefix
+=
"
\n
"
;
else
new_prefix
+=
"-"
;
new_prefix
+=
at
(
0
).
content
.
token
.
to_string
();
Node
rules
(
at
(
1
));
for
(
int
i
=
0
;
i
<
rules
.
size
();
++
i
)
{
buf
<<
new_prefix
;
if
(
rules
[
i
].
type
==
propset
)
{
rules
[
i
].
emit_propset
(
buf
,
depth
+
1
,
new_prefix
);
}
else
{
rules
[
i
][
0
].
emit_nested_css
(
buf
,
depth
);
rules
[
i
][
1
].
emit_nested_css
(
buf
,
depth
);
buf
<<
';'
;
}
}
}
void
Node
::
emit_expanded_css
(
stringstream
&
buf
,
const
string
&
prefix
)
{
void
Node
::
emit_expanded_css
(
stringstream
&
buf
,
const
string
&
prefix
)
{
// switch (type) {
// switch (type) {
...
...
node.hpp
View file @
3663a724
...
@@ -210,6 +210,7 @@ namespace Sass {
...
@@ -210,6 +210,7 @@ namespace Sass {
size_t
depth
,
size_t
depth
,
const
vector
<
string
>&
prefixes
);
const
vector
<
string
>&
prefixes
);
void
emit_nested_css
(
stringstream
&
buf
,
size_t
depth
);
void
emit_nested_css
(
stringstream
&
buf
,
size_t
depth
);
void
emit_propset
(
stringstream
&
buf
,
size_t
depth
,
const
string
&
prefix
);
void
emit_expanded_css
(
stringstream
&
buf
,
const
string
&
prefix
);
void
emit_expanded_css
(
stringstream
&
buf
,
const
string
&
prefix
);
Node
clone
(
vector
<
vector
<
Node
>*>&
registry
)
const
;
Node
clone
(
vector
<
vector
<
Node
>*>&
registry
)
const
;
...
...
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