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
aba60c5c
Commit
aba60c5c
authored
Apr 20, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handling unary + and -. Makes more tests pass.
parent
58972fe7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
0 deletions
+63
-0
document_parser.cpp
src/document_parser.cpp
+12
-0
eval_apply.cpp
src/eval_apply.cpp
+20
-0
node.cpp
src/node.cpp
+14
-0
node.hpp
src/node.hpp
+17
-0
No files found.
src/document_parser.cpp
View file @
aba60c5c
...
...
@@ -655,6 +655,18 @@ namespace Sass {
if
(
!
lex
<
exactly
<
')'
>
>
())
syntax_error
(
"unclosed parenthesis"
);
return
value
;
}
else
if
(
lex
<
exactly
<
'+'
>
>
())
{
Node
plus
(
Node
::
unary_plus
,
context
.
registry
,
line_number
,
1
);
plus
<<
parse_factor
();
plus
.
eval_me
=
true
;
return
plus
;
}
else
if
(
lex
<
exactly
<
'-'
>
>
())
{
Node
minus
(
Node
::
unary_minus
,
context
.
registry
,
line_number
,
1
);
minus
<<
parse_factor
();
minus
.
eval_me
=
true
;
return
minus
;
}
else
{
return
parse_value
();
}
...
...
src/eval_apply.cpp
View file @
aba60c5c
...
...
@@ -223,6 +223,26 @@ namespace Sass {
return
apply_function
(
f_env
[
sig
],
expr
[
1
],
env
,
f_env
,
registry
);
}
break
;
case
Node
:
:
unary_plus
:
{
Node
arg
(
eval
(
expr
[
0
],
env
,
f_env
,
registry
));
if
(
arg
.
is_numeric
())
return
arg
;
else
{
expr
[
0
]
=
arg
;
return
expr
;
}
}
break
;
case
Node
:
:
unary_minus
:
{
Node
arg
(
eval
(
expr
[
0
],
env
,
f_env
,
registry
));
if
(
arg
.
is_numeric
())
{
arg
.
set_numeric_value
(
-
arg
.
numeric_value
());
}
else
{
expr
[
0
]
=
arg
;
return
expr
;
}
}
break
;
case
Node
:
:
string_schema
:
case
Node
:
:
value_schema
:
{
cerr
<<
"evaluating schema of size "
<<
expr
.
size
()
<<
endl
;
...
...
src/node.cpp
View file @
aba60c5c
...
...
@@ -174,6 +174,20 @@ namespace Sass {
return
"/"
;
}
break
;
case
unary_plus
:
{
stringstream
ss
;
ss
<<
"+"
;
ss
<<
at
(
0
).
to_string
(
""
);
return
ss
.
str
();
}
case
unary_minus
:
{
stringstream
ss
;
ss
<<
"-"
;
ss
<<
at
(
0
).
to_string
(
""
);
return
ss
.
str
();
}
case
numeric_percentage
:
{
stringstream
ss
;
ss
<<
content
.
dimension
.
numeric_value
;
...
...
src/node.hpp
View file @
aba60c5c
...
...
@@ -59,6 +59,8 @@ namespace Sass {
div
,
factor
,
unary_plus
,
unary_minus
,
values
,
value
,
identifier
,
...
...
@@ -170,6 +172,21 @@ namespace Sass {
}
}
void
set_numeric_value
(
double
v
)
{
switch
(
type
)
{
case
number
:
case
numeric_percentage
:
content
.
numeric_value
=
v
;
case
numeric_dimension
:
content
.
dimension
.
numeric_value
=
v
;
default
:
break
;
// throw an exception?
}
}
Node
&
operator
+=
(
const
Node
&
n
)
{
for
(
int
i
=
0
;
i
<
n
.
size
();
++
i
)
{
...
...
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