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
a9c41491
Commit
a9c41491
authored
Feb 28, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bam! Robust tokenizing!
parent
9010aa33
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
67 additions
and
4 deletions
+67
-4
document.cpp
src/document.cpp
+5
-0
document.hpp
src/document.hpp
+19
-1
node.hpp
src/node.hpp
+3
-1
test.scss
src/test.scss
+10
-0
token.cpp
src/token.cpp
+3
-1
token.hpp
src/token.hpp
+5
-1
unit-test-document.cpp
src/unit-test-document.cpp
+22
-0
No files found.
src/document.cpp
View file @
a9c41491
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
#include "document.hpp"
#include "document.hpp"
namespace
Sass
{
namespace
Sass
{
using
namespace
Prelexer
;
Document
::
Document
(
char
*
_path
,
char
*
_source
)
{
Document
::
Document
(
char
*
_path
,
char
*
_source
)
{
path
=
_path
;
path
=
_path
;
if
(
!
_source
)
{
if
(
!
_source
)
{
...
@@ -28,4 +30,6 @@ namespace Sass {
...
@@ -28,4 +30,6 @@ namespace Sass {
Document
::~
Document
()
{
Document
::~
Document
()
{
delete
[]
source
;
delete
[]
source
;
}
}
}
}
\ No newline at end of file
src/document.hpp
View file @
a9c41491
...
@@ -2,15 +2,32 @@
...
@@ -2,15 +2,32 @@
namespace
Sass
{
namespace
Sass
{
using
std
::
vector
;
using
std
::
vector
;
using
namespace
Prelexer
;
struct
Document
{
struct
Document
{
char
*
path
;
char
*
path
;
char
*
source
;
char
*
source
;
unsigned
int
position
;
char
*
position
;
unsigned
int
line_number
;
unsigned
int
line_number
;
vector
<
Node
>
statements
;
vector
<
Node
>
statements
;
Token
top
;
Document
(
char
*
_path
,
char
*
_source
=
0
);
Document
(
char
*
_path
,
char
*
_source
=
0
);
~
Document
();
~
Document
();
inline
Token
&
peek
()
{
return
top
;
}
template
<
prelexer
mx
>
bool
try_munching
()
{
char
*
after_whitespace
=
spaces_and_comments
(
position
);
line_number
+=
count_interval
<
'\n'
>
(
position
,
after_whitespace
);
char
*
after_token
=
mx
(
after_whitespace
);
if
(
after_token
)
{
top
=
Token
(
mx
,
after_whitespace
,
after_token
,
line_number
);
position
=
after_token
;
return
true
;
}
else
return
false
;
}
};
};
}
}
\ No newline at end of file
src/node.hpp
View file @
a9c41491
...
@@ -14,7 +14,9 @@ namespace Sass {
...
@@ -14,7 +14,9 @@ namespace Sass {
simple_selector_sequence
,
simple_selector_sequence
,
simple_selector
,
simple_selector
,
property
,
property
,
value
value
,
lookahead_sequence
,
lookahead_token
};
};
Node_Type
type
;
Node_Type
type
;
...
...
src/test.scss
0 → 100644
View file @
a9c41491
div
{
color
:
red
;
background
:
blue
;
span
{
font-weight
:
bold
;
display
:
inline-block
;
}
margin
:
10px
5px
;
}
\ No newline at end of file
src/token.cpp
View file @
a9c41491
...
@@ -6,9 +6,11 @@ namespace Sass {
...
@@ -6,9 +6,11 @@ namespace Sass {
end
=
0
;
end
=
0
;
line_number
=
1
;
line_number
=
1
;
}
}
Token
::
Token
(
const
char
*
_begin
,
Token
::
Token
(
Prelexer
::
prelexer
_type
,
const
char
*
_begin
,
const
char
*
_end
,
const
char
*
_end
,
unsigned
int
_line_number
)
{
unsigned
int
_line_number
)
{
type
=
_type
;
begin
=
_begin
;
begin
=
_begin
;
end
=
_end
;
end
=
_end
;
line_number
=
_line_number
;
line_number
=
_line_number
;
...
...
src/token.hpp
View file @
a9c41491
#include "prelexer.hpp"
namespace
Sass
{
namespace
Sass
{
struct
Token
{
struct
Token
{
Prelexer
::
prelexer
type
;
const
char
*
begin
;
const
char
*
begin
;
const
char
*
end
;
const
char
*
end
;
unsigned
int
line_number
;
unsigned
int
line_number
;
Token
();
Token
();
Token
(
const
char
*
_begin
,
Token
(
Prelexer
::
prelexer
_type
,
const
char
*
_begin
,
const
char
*
_end
,
const
char
*
_end
,
unsigned
int
_line_number
);
unsigned
int
_line_number
);
inline
bool
is_null
()
{
return
begin
==
0
||
end
==
0
;
}
inline
bool
is_null
()
{
return
begin
==
0
||
end
==
0
;
}
...
...
src/unit-test-document.cpp
View file @
a9c41491
...
@@ -3,11 +3,32 @@
...
@@ -3,11 +3,32 @@
using
namespace
Sass
;
using
namespace
Sass
;
void
print_slice
(
const
char
*
s
,
const
char
*
t
)
{
if
(
t
)
{
printf
(
"succeeded with %ld characters:
\t
"
,
t
-
s
);
while
(
s
<
t
)
putchar
(
*
s
++
);
putchar
(
'\n'
);
}
else
{
printf
(
"failed
\n
"
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
>
1
)
{
Document
doc
(
argv
[
1
],
0
);
Document
doc
(
argv
[
1
],
0
);
char
*
src
=
doc
.
source
;
char
*
src
=
doc
.
source
;
printf
(
"FILE BEGINS ON NEXT LINE
\n
"
);
printf
(
"FILE BEGINS ON NEXT LINE
\n
"
);
while
(
*
src
)
std
::
putchar
(
*
(
src
++
));
while
(
*
src
)
std
::
putchar
(
*
(
src
++
));
printf
(
"<EOF>
\n
"
);
printf
(
"<EOF>
\n
"
);
doc
.
try_munching
<
Prelexer
::
identifier
>
();
print_slice
(
doc
.
top
.
begin
,
doc
.
top
.
end
);
doc
.
try_munching
<
Prelexer
::
exactly
<
'{'
>
>
();
print_slice
(
doc
.
top
.
begin
,
doc
.
top
.
end
);
doc
.
try_munching
<
Prelexer
::
identifier
>
();
print_slice
(
doc
.
top
.
begin
,
doc
.
top
.
end
);
}
return
0
;
return
0
;
}
}
\ No newline at end of file
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