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
2e424258
Commit
2e424258
authored
Feb 28, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Putting parsing functions in place. Don't try to compile yet.
parent
b47fadb1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
12 deletions
+52
-12
document.cpp
src/document.cpp
+27
-6
document.hpp
src/document.hpp
+4
-0
node.cpp
src/node.cpp
+6
-2
node.hpp
src/node.hpp
+7
-4
token.cpp
src/token.cpp
+7
-0
token.hpp
src/token.hpp
+1
-0
No files found.
src/document.cpp
View file @
2e424258
...
@@ -31,10 +31,8 @@ namespace Sass {
...
@@ -31,10 +31,8 @@ namespace Sass {
}
}
void
Document
::
parse_stylesheet
()
{
void
Document
::
parse_stylesheet
()
{
printf
(
"ABOUT TO MUNCH LEADING SPACES
\n
"
);
try_munching
<
optional_spaces
>
();
try_munching
<
optional_spaces
>
();
while
(
*
position
)
{
while
(
*
position
)
{
printf
(
"LOOPING OVER STATEMENTS
\n
"
);
statements
.
push_back
(
parse_statement
());
statements
.
push_back
(
parse_statement
());
try_munching
<
optional_spaces
>
();
try_munching
<
optional_spaces
>
();
}
}
...
@@ -42,10 +40,34 @@ namespace Sass {
...
@@ -42,10 +40,34 @@ namespace Sass {
Node
Document
::
parse_statement
()
{
Node
Document
::
parse_statement
()
{
if
(
try_munching
<
block_comment
>
())
{
if
(
try_munching
<
block_comment
>
())
{
printf
(
"MUNCHING A COMMENT
\n
"
);
return
Node
(
Node
::
comment
,
top
);
return
Node
(
Node
::
comment
,
top
);
}
}
else
return
Node
();
else
return
parse_ruleset
();
}
Node
Document
::
parse_ruleset
()
{
Node
ruleset
(
Node
::
ruleset
);
ruleset
.
push_child
(
parse_selector
());
ruleset
.
push_child
(
parse_declarations
());
return
ruleset
;
}
Node
Document
::
parse_selector
()
{
try_munching
<
identifier
>
();
return
Node
(
Node
::
selector
,
top
);
}
Node
Document
::
parse_declarations
()
{
try_munching
<
exactly
<
'{'
>
>
();
while
(
!
try_munching
<
exactly
<
'}'
>
>
())
{
try_munching
<
identifier
>
();
Token
id
=
top
;
if
(
try_munching
<
exactly
<
':'
>
>
())
{
Node
rule
(
Node
::
rule
);
rule
.
push_child
(
Node
(
Node
::
property
,
id
));
rule
.
push_child
(
Node
(
Node
::
value
,
parse_value
()));
return
rule
;
}
}
}
}
}
}
\ No newline at end of file
src/document.hpp
View file @
2e424258
...
@@ -56,6 +56,9 @@ namespace Sass {
...
@@ -56,6 +56,9 @@ namespace Sass {
void
parse_stylesheet
();
void
parse_stylesheet
();
Node
parse_statement
();
Node
parse_statement
();
Node
parse_ruleset
();
Node
parse_selector
();
Node
parse_declarations
();
};
};
}
}
\ No newline at end of file
src/node.cpp
View file @
2e424258
...
@@ -2,14 +2,17 @@
...
@@ -2,14 +2,17 @@
namespace
Sass
{
namespace
Sass
{
Node
::
Node
()
{
}
Node
::
Node
()
{
}
Node
::
Node
(
Node_Type
_type
)
{
type
=
_type
;
}
Node
::
Node
(
Node_Type
_type
,
Token
&
_token
)
{
Node
::
Node
(
Node_Type
_type
,
Token
&
_token
)
{
type
=
_type
;
type
=
_type
;
token
=
_token
;
token
=
_token
;
}
}
void
Node
::
push_child
(
Node
&
node
)
{
void
Node
::
push_child
(
const
Node
&
node
)
{
children
.
push_back
(
node
);
children
.
push_back
(
node
);
}
}
void
Node
::
push_opt_child
(
Node
&
node
)
{
void
Node
::
push_opt_child
(
const
Node
&
node
)
{
opt_children
.
push_back
(
node
);
opt_children
.
push_back
(
node
);
}
}
}
}
\ No newline at end of file
src/node.hpp
View file @
2e424258
...
@@ -7,12 +7,13 @@ namespace Sass {
...
@@ -7,12 +7,13 @@ namespace Sass {
enum
Node_Type
{
enum
Node_Type
{
null
,
null
,
comment
,
comment
,
rule
_
set
,
ruleset
,
declaration
,
declaration
s
,
selector_group
,
selector_group
,
selector
,
selector
,
simple_selector_sequence
,
simple_selector_sequence
,
simple_selector
,
simple_selector
,
rule
,
property
,
property
,
value
,
value
,
lookahead_sequence
,
lookahead_sequence
,
...
@@ -25,8 +26,9 @@ namespace Sass {
...
@@ -25,8 +26,9 @@ namespace Sass {
vector
<
Node
>
opt_children
;
vector
<
Node
>
opt_children
;
Node
();
Node
();
Node
(
Node_Type
_type
);
Node
(
Node_Type
_type
,
Token
&
_token
);
Node
(
Node_Type
_type
,
Token
&
_token
);
void
push_child
(
Node
&
node
);
void
push_child
(
const
Node
&
node
);
void
push_opt_child
(
Node
&
node
);
void
push_opt_child
(
const
Node
&
node
);
};
};
}
}
\ No newline at end of file
src/token.cpp
View file @
2e424258
...
@@ -15,5 +15,11 @@ namespace Sass {
...
@@ -15,5 +15,11 @@ namespace Sass {
else
begin
=
_begin
,
end
=
_end
;
else
begin
=
_begin
,
end
=
_end
;
line_number
=
_line_number
;
line_number
=
_line_number
;
}
}
Token
::
Token
(
const
Token
&
t
)
{
type
=
t
.
type
;
begin
=
t
.
begin
;
end
=
t
.
end
;
line_number
=
t
.
line_number
;
}
}
}
\ No newline at end of file
src/token.hpp
View file @
2e424258
...
@@ -14,6 +14,7 @@ namespace Sass {
...
@@ -14,6 +14,7 @@ namespace Sass {
const
char
*
_begin
,
const
char
*
_begin
,
const
char
*
_end
,
const
char
*
_end
,
unsigned
int
_line_number
);
unsigned
int
_line_number
);
Token
(
const
Token
&
t
);
inline
bool
is_null
()
{
return
begin
==
0
||
end
==
0
;
}
inline
bool
is_null
()
{
return
begin
==
0
||
end
==
0
;
}
inline
operator
string
()
{
return
string
(
begin
,
end
-
begin
);
}
inline
operator
string
()
{
return
string
(
begin
,
end
-
begin
);
}
};
};
...
...
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