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
cf1a2eca
Commit
cf1a2eca
authored
May 27, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slightly more sophisticated lookahead in preparation for selector interpolation.
parent
c29769c2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
7 deletions
+24
-7
document.hpp
document.hpp
+6
-1
document_parser.cpp
document_parser.cpp
+18
-6
No files found.
document.hpp
View file @
cf1a2eca
...
...
@@ -7,6 +7,11 @@
#include "prelexer.hpp"
#include "context.hpp"
struct
Selector_Lookahead
{
const
char
*
found
;
bool
has_interpolants
;
};
namespace
Sass
{
using
std
::
string
;
using
std
::
vector
;
...
...
@@ -150,7 +155,7 @@ namespace Sass {
Node
parse_string
();
Node
parse_value_schema
();
const
char
*
lookahead_for_selector
(
const
char
*
start
=
0
);
Selector_Lookahead
lookahead_for_selector
(
const
char
*
start
=
0
);
void
throw_syntax_error
(
string
message
,
size_t
ln
=
0
);
void
throw_read_error
(
string
message
,
size_t
ln
=
0
);
...
...
document_parser.cpp
View file @
cf1a2eca
...
...
@@ -8,6 +8,7 @@ namespace Sass {
void
Document
::
parse_scss
()
{
lex
<
optional_spaces
>
();
Selector_Lookahead
lookahead_result
;
while
(
position
<
end
)
{
if
(
lex
<
block_comment
>
())
{
root
<<
context
.
new_Node
(
Node
::
comment
,
path
,
line
,
lexed
);
...
...
@@ -28,7 +29,7 @@ namespace Sass {
else
if
(
peek
<
sequence
<
identifier
,
optional_spaces
,
exactly
<
':'
>
,
optional_spaces
,
exactly
<
'{'
>
>
>
(
position
))
{
root
<<
parse_propset
();
}
else
if
(
lookahead_for_selector
(
position
)
)
{
else
if
(
(
lookahead_result
=
lookahead_for_selector
(
position
)).
found
)
{
root
<<
parse_ruleset
();
}
else
if
(
peek
<
include
>
()
||
peek
<
exactly
<
'+'
>
>
())
{
...
...
@@ -392,6 +393,7 @@ namespace Sass {
{
lex
<
exactly
<
'{'
>
>
();
bool
semicolon
=
false
;
Selector_Lookahead
lookahead_result
;
Node
block
(
context
.
new_Node
(
Node
::
block
,
path
,
line
,
0
));
while
(
!
lex
<
exactly
<
'}'
>
>
())
{
if
(
semicolon
)
{
...
...
@@ -432,7 +434,7 @@ namespace Sass {
else
if
(
peek
<
sequence
<
identifier
,
optional_spaces
,
exactly
<
':'
>
,
optional_spaces
,
exactly
<
'{'
>
>
>
(
position
))
{
block
<<
parse_propset
();
}
else
if
(
lookahead_for_selector
(
position
)
)
{
else
if
(
(
lookahead_result
=
lookahead_for_selector
(
position
)).
found
)
{
block
<<
parse_ruleset
(
definition
);
}
else
if
(
peek
<
exactly
<
'+'
>
>
())
{
...
...
@@ -830,10 +832,12 @@ namespace Sass {
return
call
;
}
const
char
*
Document
::
lookahead_for_selector
(
const
char
*
start
)
// const char* Document::lookahead_for_selector(const char* start)
Selector_Lookahead
Document
::
lookahead_for_selector
(
const
char
*
start
)
{
const
char
*
p
=
start
?
start
:
position
;
const
char
*
q
;
bool
saw_interpolant
=
false
;
while
((
q
=
peek
<
identifier
>
(
p
))
||
(
q
=
peek
<
id_name
>
(
p
))
||
...
...
@@ -862,10 +866,17 @@ namespace Sass {
dash_match
,
prefix_match
,
suffix_match
,
substring_match
>
>
(
p
)))
{
p
=
q
;
}
substring_match
>
>
(
p
))
||
(
q
=
peek
<
interpolant
>
(
p
)))
{
p
=
q
;
if
(
*
(
p
-
1
)
==
'}'
)
saw_interpolant
=
true
;
}
Selector_Lookahead
result
;
result
.
found
=
peek
<
exactly
<
'{'
>
>
(
p
)
?
p
:
0
;
result
.
has_interpolants
=
saw_interpolant
;
if
(
peek
<
exactly
<
'{'
>
>
(
p
))
return
p
;
else
return
0
;
return
result
;
}
}
\ 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