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
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
44 deletions
+61
-44
document.hpp
src/document.hpp
+1
-0
document_parser.cpp
src/document_parser.cpp
+42
-43
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 {
...
@@ -142,6 +142,7 @@ namespace Sass {
Node
parse_identifier
();
Node
parse_identifier
();
Node
parse_variable
();
Node
parse_variable
();
Node
parse_function_call
();
Node
parse_function_call
();
Node
parse_string
();
Node
parse_value_schema
();
Node
parse_value_schema
();
const
char
*
look_for_rule
(
const
char
*
start
=
0
);
const
char
*
look_for_rule
(
const
char
*
start
=
0
);
...
...
src/document_parser.cpp
View file @
15b9258a
...
@@ -716,8 +716,8 @@ namespace Sass {
...
@@ -716,8 +716,8 @@ namespace Sass {
{
return
Node
(
Node
::
textual_hex
,
line_number
,
lexed
);
}
{
return
Node
(
Node
::
textual_hex
,
line_number
,
lexed
);
}
if
(
peek
<
string_constant
>
())
if
(
peek
<
string_constant
>
())
{
return
Node
(
Node
::
string_constant
,
line_number
,
lexed
);
}
//
{ return Node(Node::string_constant, line_number, lexed); }
//
{ return parse_string(); }
{
return
parse_string
();
}
if
(
lex
<
variable
>
())
if
(
lex
<
variable
>
())
{
{
...
@@ -729,49 +729,48 @@ namespace Sass {
...
@@ -729,49 +729,48 @@ namespace Sass {
syntax_error
(
"error reading values after "
+
lexed
.
to_string
());
syntax_error
(
"error reading values after "
+
lexed
.
to_string
());
}
}
// Node Document::parse_string()
extern
const
char
hash_lbrace
[]
=
"#{"
;
// {
extern
const
char
rbrace
[]
=
"}"
;
// lex< string_constant >();
// Token str(lexed);
Node
Document
::
parse_string
()
// const char* i = str.begin;
{
// while (i < str.end) {
lex
<
string_constant
>
();
// i = find_first< hash_lbrace >(str.begin);
Token
str
(
lexed
);
// if (*(--i) == '\\') {
const
char
*
i
=
str
.
begin
;
// i += 2;
// see if there any interpolants
// continue;
const
char
*
p
=
find_first_in_interval
<
sequence
<
negate
<
exactly
<
'\\'
>
>
,
exactly
<
hash_lbrace
>
>
>
(
str
.
begin
,
str
.
end
);
// }
if
(
!
p
)
{
// const char* j = find_first< rbrace >(i);
return
Node
(
Node
::
string_constant
,
line_number
,
str
);
// if (j) {
}
// Document interp_doc(path, line_number, Token::make(i,j+1), context);
// schema << interp_doc.parse_list();
Node
schema
(
Node
::
string_schema
,
context
.
registry
,
line_number
,
1
);
// i = j + 1;
while
(
i
<
str
.
end
)
{
// }
if
(
p
=
find_first_in_interval
<
sequence
<
negate
<
exactly
<
'\\'
>
>
,
exactly
<
hash_lbrace
>
>
>
(
i
,
str
.
end
))
{
// else {
if
(
i
<
p
)
schema
<<
Node
(
Node
::
identifier
,
line_number
,
Token
::
make
(
i
,
p
));
// accumulate the preceding segment if it's nonempty
// syntax_error("unterminated interpolant inside string constant " + str.to_string());
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
Document
::
parse_value_schema
()
{
{
// 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);
// }
Node
schema
(
Node
::
value_schema
,
context
.
registry
,
line_number
,
1
);
Node
schema
(
Node
::
value_schema
,
context
.
registry
,
line_number
,
1
);
while
(
position
<
end
)
{
while
(
position
<
end
)
{
...
...
src/eval_apply.cpp
View file @
15b9258a
...
@@ -86,7 +86,7 @@ namespace Sass {
...
@@ -86,7 +86,7 @@ namespace Sass {
if
(
rhs
[
i
].
eval_me
)
rhs
[
i
]
=
eval
(
rhs
[
i
],
env
,
f_env
,
registry
);
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
);
eval
(
rhs
,
env
,
f_env
,
registry
);
}
}
else
{
else
{
...
@@ -223,6 +223,7 @@ namespace Sass {
...
@@ -223,6 +223,7 @@ namespace Sass {
return
apply_function
(
f_env
[
sig
],
expr
[
1
],
env
,
f_env
,
registry
);
return
apply_function
(
f_env
[
sig
],
expr
[
1
],
env
,
f_env
,
registry
);
}
break
;
}
break
;
case
Node
:
:
string_schema
:
case
Node
:
:
value_schema
:
{
case
Node
:
:
value_schema
:
{
cerr
<<
"evaluating schema of size "
<<
expr
.
size
()
<<
endl
;
cerr
<<
"evaluating schema of size "
<<
expr
.
size
()
<<
endl
;
for
(
int
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
expr
.
size
();
++
i
)
{
...
...
src/node.cpp
View file @
15b9258a
...
@@ -278,6 +278,12 @@ namespace Sass {
...
@@ -278,6 +278,12 @@ namespace Sass {
return
result
;
return
result
;
}
break
;
}
break
;
case
string_schema
:
{
string
result
;
for
(
int
i
=
0
;
i
<
size
();
++
i
)
result
+=
at
(
i
).
to_string
(
""
);
return
result
;
}
break
;
default
:
{
default
:
{
// return content.token.to_string();
// return content.token.to_string();
if
(
!
has_children
&&
type
!=
flags
)
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 {
...
@@ -77,6 +77,7 @@ namespace Sass {
important
,
important
,
value_schema
,
value_schema
,
string_schema
,
function_call
,
function_call
,
mixin
,
mixin
,
...
...
src/prelexer.hpp
View file @
15b9258a
...
@@ -384,6 +384,15 @@ namespace Sass {
...
@@ -384,6 +384,15 @@ namespace Sass {
while
(
*
src
&&
!
mx
(
src
))
++
src
;
while
(
*
src
&&
!
mx
(
src
))
++
src
;
return
*
src
?
src
:
0
;
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
>
template
<
char
c
>
unsigned
int
count_interval
(
const
char
*
beg
,
const
char
*
end
)
{
unsigned
int
count_interval
(
const
char
*
beg
,
const
char
*
end
)
{
unsigned
int
counter
=
0
;
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