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
cefe1e26
Commit
cefe1e26
authored
Feb 27, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fleshing out the classes for documents, nodes, and tokens.
parent
04188848
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
140 additions
and
4 deletions
+140
-4
document.cpp
src/document.cpp
+28
-0
document.hpp
src/document.hpp
+7
-2
node.cpp
src/node.cpp
+16
-0
node.hpp
src/node.hpp
+26
-2
token.cpp
src/token.cpp
+17
-0
token.hpp
src/token.hpp
+13
-0
vectest.cpp
src/vectest.cpp
+33
-0
No files found.
src/document.cpp
View file @
cefe1e26
#include <cstdio>
#include "document.hpp"
namespace
Sass
{
Document
::
Document
(
char
*
_path
,
char
*
_source
)
{
path
=
_path
;
if
(
!
source
)
{
std
::
FILE
*
f
;
f
=
std
::
fopen
(
path
,
"rb"
);
// if (!f) {
// printf("ERROR: could not open file %s", path);
// abort();
// }
std
::
fseek
(
f
,
0
,
SEEK_END
);
int
len
=
std
::
ftell
(
f
);
std
::
rewind
(
f
);
// char *buf = (char *)malloc(len * sizeof(char) + 1);
source
=
new
char
[
len
+
1
];
std
::
fread
(
source
,
sizeof
(
char
),
len
,
f
);
source
[
len
]
=
'\0'
;
std
::
fclose
(
f
);
}
else
{
source
=
_source
;
}
}
}
\ No newline at end of file
src/document.hpp
View file @
cefe1e26
...
...
@@ -2,11 +2,15 @@
#include "node.hpp"
namespace
Sass
{
using
std
::
vector
;
struct
Document
{
using
std
::
vector
;
char
*
path
;
char
*
source
;
unsigned
int
position
;
unsigned
int
line_number
;
vector
<
Node
>
statements
;
Document
(
char
*
_path
,
char
*
_source
=
0
);
};
}
\ No newline at end of file
src/node.cpp
View file @
cefe1e26
#include "node.hpp"
namespace
Sass
{
Node
::
Node
()
{
}
Node
::
Node
(
Node_Type
_type
,
Token
&
_token
)
{
type
=
_type
;
token
=
_token
;
}
void
Node
::
push_child
(
Node
&
node
)
{
children
.
push_back
(
node
);
}
void
Node
::
push_opt_child
(
Node
&
node
)
{
opt_children
.
push_back
(
node
);
}
}
\ No newline at end of file
src/node.hpp
View file @
cefe1e26
...
...
@@ -2,5 +2,29 @@
#include "token.hpp"
namespace
Sass
{
using
std
::
vector
;
struct
Node
{
\ No newline at end of file
enum
Node_Type
{
null
,
comment
,
rule_set
,
declaration
,
selector_group
,
selector
,
simple_selector_sequence
,
simple_selector
,
property
,
value
};
Node_Type
type
;
Token
token
;
vector
<
Node
>
children
;
vector
<
Node
>
opt_children
;
Node
();
Node
(
Node_Type
_type
,
Token
&
_token
);
void
push_child
(
Node
&
node
);
void
push_opt_child
(
Node
&
node
);
};
}
\ No newline at end of file
src/token.cpp
0 → 100644
View file @
cefe1e26
#include "token.hpp"
namespace
Sass
{
Token
::
Token
()
{
begin
=
0
;
end
=
0
;
line_number
=
1
;
}
Token
::
Token
(
const
char
*
_begin
,
const
char
*
_end
,
unsigned
int
_line_number
)
{
begin
=
_begin
;
end
=
_end
;
line_number
=
_line_number
;
}
}
\ No newline at end of file
src/token.hpp
0 → 100644
View file @
cefe1e26
namespace
Sass
{
struct
Token
{
const
char
*
begin
;
const
char
*
end
;
unsigned
int
line_number
;
Token
();
Token
(
const
char
*
_begin
,
const
char
*
_end
,
unsigned
int
_line_number
);
inline
bool
is_null
()
{
return
begin
==
0
||
end
==
0
;
}
};
}
\ No newline at end of file
src/vectest.cpp
0 → 100644
View file @
cefe1e26
#include <vector>
#include <iostream>
using
namespace
std
;
struct
box
{
vector
<
int
>
vec
;
vector
<
box
>
vec2
;
};
int
main
()
{
box
b
;
b
.
vec
.
push_back
(
1
);
b
.
vec
.
push_back
(
2
);
b
.
vec
.
push_back
(
3
);
box
c
=
b
;
c
.
vec
.
push_back
(
4
);
cout
<<
b
.
vec
.
size
()
<<
endl
;
cout
<<
c
.
vec
.
size
()
<<
endl
;
c
.
vec
[
0
]
=
42
;
cout
<<
b
.
vec
[
0
]
<<
endl
;
cout
<<
c
.
vec
[
0
]
<<
endl
;
b
.
vec2
.
push_back
(
c
);
cout
<<
b
.
vec2
[
0
].
vec
[
0
]
<<
endl
;
return
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