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
d7596999
Commit
d7596999
authored
Mar 09, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working on selector combinators. Don't try to compile this.
parent
7fdf5765
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
102 deletions
+25
-102
combinators.scss
combinators.scss
+9
-0
document_parser.cpp
document_parser.cpp
+15
-1
node.cpp
node.cpp
+0
-65
node.hpp
node.hpp
+1
-36
No files found.
combinators.scss
0 → 100644
View file @
d7596999
a
+
b
>
c
{
d
e
{
color
:
blue
;
background
:
white
;
}
color
:
red
;
background
:
gray
;
}
\ No newline at end of file
document_parser.cpp
View file @
d7596999
...
@@ -47,8 +47,22 @@ namespace Sass {
...
@@ -47,8 +47,22 @@ namespace Sass {
Node
Document
::
parse_selector
()
Node
Document
::
parse_selector
()
{
{
Node
selector
(
line_number
,
Node
::
selector
,
1
);
selector
<<
parse_simple_selector_sequence
();
while
(
lex
<
adjacent_to
>
()
||
lex
<
precedes
>
()
||
lex
<
parent_of
>
()
||
lex
<
sequence
<
ancestor_of
,
negate
<
exactly
<
'{'
>
>
>
())
{
selector
<<
Node
(
line_number
,
Node
::
selector_combinator
,
lexed
);
selector
<<
parse_simple_selector_sequence
();
}
return
selector
;
}
Node
Document
::
parse_simple_selector_sequence
()
{
lex
<
identifier
>
();
lex
<
identifier
>
();
return
Node
(
line_number
,
Node
::
s
elector
,
lexed
);
return
Node
(
line_number
,
Node
::
s
imple_selector_sequence
,
lexed
);
}
}
Node
Document
::
parse_block
()
Node
Document
::
parse_block
()
...
...
node.cpp
View file @
d7596999
...
@@ -57,12 +57,10 @@ namespace Sass {
...
@@ -57,12 +57,10 @@ namespace Sass {
}
}
}
}
void
Node
::
emit_nested_css
(
stringstream
&
buf
,
void
Node
::
emit_nested_css
(
stringstream
&
buf
,
size_t
depth
,
size_t
depth
,
const
vector
<
string
>&
prefixes
)
const
vector
<
string
>&
prefixes
)
{
{
string
indentation
(
2
*
depth
,
' '
);
switch
(
type
)
{
switch
(
type
)
{
case
ruleset
:
{
case
ruleset
:
{
Node
sel_group
(
children
->
at
(
0
));
Node
sel_group
(
children
->
at
(
0
));
...
@@ -143,69 +141,6 @@ namespace Sass {
...
@@ -143,69 +141,6 @@ namespace Sass {
}
}
}
}
// void Node::emit_nested_css(stringstream& buf,
// const string& prefix,
// size_t depth) {
// string indentation(2 * depth, ' ');
// vector<Node>* contents;
// if (type == ruleset) {
// Node block(children->at(1));
// contents = block.children;
// has_rules_or_comments = block.has_rules_or_comments;
// has_rulesets = block.has_rulesets;
// }
// switch (type) {
// case ruleset:
// if (has_rules_or_comments) {
// buf << indentation;
// children->at(0).emit_nested_css(buf, prefix, depth); // selector group
// buf << " {";
// for (int i = 0; i < contents->size(); ++i) {
// if (contents->at(i).type == comment || contents->at(i).type == rule) contents->at(i).emit_nested_css(buf, "", depth + 1); // rules
// }
// buf << " }" << endl;
// }
// if (has_rulesets) {
// for (int i = 0; i < contents->size(); ++i) { // do each nested ruleset
// if (contents->at(i).type == ruleset) contents->at(i).emit_nested_css(buf, prefix + (prefix.empty() ? "" : " ") + string((*children)[0].token), depth + (has_rules_or_comments ? 1 : 0));
// }
// }
// if (depth == 0 && prefix.empty()) buf << endl;
// break;
// case rule:
// buf << endl << indentation;
// children->at(0).emit_nested_css(buf, "", depth); // property
// children->at(1).emit_nested_css(buf, "", depth); // values
// buf << ";";
// break;
// case property:
// buf << string(token) << ":";
// break;
// case values:
// for (int i = 0; i < children->size(); ++i) {
// buf << " " << string((*children)[i].token);
// }
// break;
// case selector_group:
// children->at(0).emit_nested_css(buf, prefix, depth);
// for (int i = 1; i < children->size(); ++i) {
// children->at(i).emit_nested_css(buf, prefix, depth);
// }
// break;
// case selector:
// buf << prefix << (prefix.empty() ? "" : " ") << string(token);
// break;
// case comment:
// if (depth != 0) buf << endl;
// buf << indentation << string(token);
// if (depth == 0) buf << endl;
// break;
// }
// }
void
Node
::
emit_expanded_css
(
stringstream
&
buf
,
const
string
&
prefix
)
{
void
Node
::
emit_expanded_css
(
stringstream
&
buf
,
const
string
&
prefix
)
{
// switch (type) {
// switch (type) {
// case selector:
// case selector:
...
...
node.hpp
View file @
d7596999
...
@@ -6,42 +6,6 @@ namespace Sass {
...
@@ -6,42 +6,6 @@ namespace Sass {
using
std
::
vector
;
using
std
::
vector
;
using
std
::
stringstream
;
using
std
::
stringstream
;
// struct Node {
// enum Node_Type {
// nil,
// comment,
// ruleset,
// clauses,
// selector_group,
// selector,
// simple_selector_sequence,
// simple_selector,
// rule,
// property,
// values,
// value
// };
//
// static unsigned int fresh;
// static unsigned int copied;
//
// Node_Type type;
// Token token;
// vector<Node>* children;
// vector<Node>* opt_children;
//
// Node();
// Node(Node_Type _type);
// Node(Node_Type _type, Token& _token);
// Node(const Node& n);
//
// void push_child(const Node& node);
// void push_opt_child(const Node& node);
// void dump(unsigned int depth = 0);
// void emit_nested_css(stringstream& buf, const string& prefix, size_t depth);
// void emit_expanded_css(stringstream& buf, const string& prefix);
// };
struct
Node
{
struct
Node
{
enum
Type
{
enum
Type
{
nil
,
nil
,
...
@@ -50,6 +14,7 @@ namespace Sass {
...
@@ -50,6 +14,7 @@ namespace Sass {
propset
,
propset
,
selector_group
,
selector_group
,
selector
,
selector
,
selector_combinator
,
simple_selector_sequence
,
simple_selector_sequence
,
type_selector
,
type_selector
,
class_selector
,
class_selector
,
...
...
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