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
15b9258a
Commit
15b9258a
authored
Apr 20, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Shelving the string interpolation stuff. Don't use it.
parent
9ece236e
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
43 deletions
+60
-43
document.hpp
src/document.hpp
+1
-0
document_parser.cpp
src/document_parser.cpp
+41
-42
eval_apply.cpp
src/eval_apply.cpp
+2
-1
node.cpp
src/node.cpp
+6
-0
node.hpp
src/node.hpp
+1
-0
prelexer.hpp
src/prelexer.hpp
+9
-0
No files found.
src/document.hpp
View file @
15b9258a
...
...
@@ -142,6 +142,7 @@ namespace Sass {
Node
parse_identifier
();
Node
parse_variable
();
Node
parse_function_call
();
Node
parse_string
();
Node
parse_value_schema
();
const
char
*
look_for_rule
(
const
char
*
start
=
0
);
...
...
src/document_parser.cpp
View file @
15b9258a
...
...
@@ -716,8 +716,8 @@ namespace Sass {
{
return
Node
(
Node
::
textual_hex
,
line_number
,
lexed
);
}
if
(
peek
<
string_constant
>
())
{
return
Node
(
Node
::
string_constant
,
line_number
,
lexed
);
}
//
{ return parse_string(); }
//
{ return Node(Node::string_constant, line_number, lexed); }
{
return
parse_string
();
}
if
(
lex
<
variable
>
())
{
...
...
@@ -729,49 +729,48 @@ namespace Sass {
syntax_error
(
"error reading values after "
+
lexed
.
to_string
());
}
// Node Document::parse_string()
// {
// lex< string_constant >();
// Token str(lexed);
// const char* i = str.begin;
// while (i < str.end) {
// i = find_first< hash_lbrace >(str.begin);
// if (*(--i) == '\\') {
// i += 2;
// continue;
// }
// const char* j = find_first< rbrace >(i);
// if (j) {
// Document interp_doc(path, line_number, Token::make(i,j+1), context);
// schema << interp_doc.parse_list();
// i = j + 1;
// }
// else {
// syntax_error("unterminated interpolant inside string constant " + str.to_string());
// }
//
//
// }
extern
const
char
hash_lbrace
[]
=
"#{"
;
extern
const
char
rbrace
[]
=
"}"
;
Node
Document
::
parse_
value_schema
()
Node
Document
::
parse_
string
()
{
// Node schema;
// if (lex< interpolant >()) {
// Token insides(Token::make(lexed.begin + 2, lexed.end - 1));
// Document interp_doc(path, line_number, insides, context);
// Node interp_node(interp_doc.parse_list());
// if (position >= end) {
// return interp_node;
// }
// else {
// schema = Node(Node::value_schema, context.registry, line_number, 2);
// schema << interp_node;
// }
// }
// else {
// schema = Node(Node::value_schema, context.registry, line_number, 2);
// }
lex
<
string_constant
>
();
Token
str
(
lexed
);
const
char
*
i
=
str
.
begin
;
// see if there any interpolants
const
char
*
p
=
find_first_in_interval
<
sequence
<
negate
<
exactly
<
'\\'
>
>
,
exactly
<
hash_lbrace
>
>
>
(
str
.
begin
,
str
.
end
);
if
(
!
p
)
{
return
Node
(
Node
::
string_constant
,
line_number
,
str
);
}
Node
schema
(
Node
::
string_schema
,
context
.
registry
,
line_number
,
1
);
while
(
i
<
str
.
end
)
{
if
(
p
=
find_first_in_interval
<
sequence
<
negate
<
exactly
<
'\\'
>
>
,
exactly
<
hash_lbrace
>
>
>
(
i
,
str
.
end
))
{
if
(
i
<
p
)
schema
<<
Node
(
Node
::
identifier
,
line_number
,
Token
::
make
(
i
,
p
));
// accumulate the preceding segment if it's nonempty
const
char
*
j
=
find_first_in_interval
<
exactly
<
rbrace
>
>
(
p
,
str
.
end
);
// find the closing brace
if
(
j
)
{
// parse the interpolant and accumulate it
Document
interp_doc
(
path
,
line_number
,
Token
::
make
(
p
+
2
,
j
-
1
),
context
);
Node
interp_node
(
interp_doc
.
parse_list
());
interp_node
.
eval_me
=
true
;
schema
<<
interp_node
;
i
=
j
+
1
;
}
else
{
// throw an error if the interpolant is unterminated
syntax_error
(
"unterminated interpolant inside string constant "
+
str
.
to_string
());
}
}
else
{
// no interpolants left; add the last segment if nonempty
if
(
i
<
str
.
end
)
schema
<<
Node
(
Node
::
identifier
,
line_number
,
Token
::
make
(
i
,
str
.
end
));
break
;
}
}
return
schema
;
}
Node
Document
::
parse_value_schema
()
{
Node
schema
(
Node
::
value_schema
,
context
.
registry
,
line_number
,
1
);
while
(
position
<
end
)
{
...
...
src/eval_apply.cpp
View file @
15b9258a
...
...
@@ -86,7 +86,7 @@ namespace Sass {
if
(
rhs
[
i
].
eval_me
)
rhs
[
i
]
=
eval
(
rhs
[
i
],
env
,
f_env
,
registry
);
}
}
else
if
(
rhs
.
type
==
Node
::
value_schema
)
{
else
if
(
rhs
.
type
==
Node
::
value_schema
||
rhs
.
type
==
Node
::
string_schema
)
{
eval
(
rhs
,
env
,
f_env
,
registry
);
}
else
{
...
...
@@ -223,6 +223,7 @@ namespace Sass {
return
apply_function
(
f_env
[
sig
],
expr
[
1
],
env
,
f_env
,
registry
);
}
break
;
case
Node
:
:
string_schema
:
case
Node
:
:
value_schema
:
{
cerr
<<
"evaluating schema of size "
<<
expr
.
size
()
<<
endl
;
for
(
int
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
...
...
src/node.cpp
View file @
15b9258a
...
...
@@ -278,6 +278,12 @@ namespace Sass {
return
result
;
}
break
;
case
string_schema
:
{
string
result
;
for
(
int
i
=
0
;
i
<
size
();
++
i
)
result
+=
at
(
i
).
to_string
(
""
);
return
result
;
}
break
;
default
:
{
// return content.token.to_string();
if
(
!
has_children
&&
type
!=
flags
)
return
content
.
token
.
to_string
();
...
...
src/node.hpp
View file @
15b9258a
...
...
@@ -77,6 +77,7 @@ namespace Sass {
important
,
value_schema
,
string_schema
,
function_call
,
mixin
,
...
...
src/prelexer.hpp
View file @
15b9258a
...
...
@@ -384,6 +384,15 @@ namespace Sass {
while
(
*
src
&&
!
mx
(
src
))
++
src
;
return
*
src
?
src
:
0
;
}
template
<
prelexer
mx
>
const
char
*
find_first_in_interval
(
const
char
*
beg
,
const
char
*
end
)
{
while
((
beg
<
end
)
&&
*
beg
)
{
const
char
*
p
;
if
(
p
=
mx
(
beg
))
return
p
;
++
beg
;
}
return
0
;
}
template
<
char
c
>
unsigned
int
count_interval
(
const
char
*
beg
,
const
char
*
end
)
{
unsigned
int
counter
=
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