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
c6394df2
Commit
c6394df2
authored
Apr 09, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comparison operators.
parent
018c82e2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
9 deletions
+87
-9
Makefile
Makefile
+1
-1
basic.scss
basic.scss
+9
-0
document.hpp
document.hpp
+1
-0
document_parser.cpp
document_parser.cpp
+38
-7
eval_apply.cpp
eval_apply.cpp
+22
-0
node.hpp
node.hpp
+16
-1
No files found.
Makefile
View file @
c6394df2
build
:
sassc.cpp document.cpp node.cpp values.cpp prelexer.cpp
build
:
sassc.cpp document.cpp node.cpp values.cpp prelexer.cpp
g++
-o
bin/sassc sassc.cpp context.cpp functions.cpp document.cpp document_parser.cpp eval_apply.cpp node.cpp values.cpp prelexer.cpp
g++
-o
bin/sassc sassc.cpp context.cpp functions.cpp document.cpp document_parser.cpp eval_apply.cpp node.cpp
node_comparisons.cpp
values.cpp prelexer.cpp
test
:
build
test
:
build
ruby spec.rb spec/basic/
ruby spec.rb spec/basic/
...
...
basic.scss
View file @
c6394df2
...
@@ -91,6 +91,15 @@ div {
...
@@ -91,6 +91,15 @@ div {
b
:
not
(
true
);
b
:
not
(
true
);
c
:
not
(
hello
);
c
:
not
(
hello
);
d
:
not
(
""
);
d
:
not
(
""
);
a
:
hello
==
hello
;
b
:
(
1
2
3
)
==
(
1
2
3
);
c
:
"hello"
==
hello
;
d
:
1
+
2
<
3
+
4
/*
e
:
1
<
3
and
3
<
5
;
f
:
(
1
2
3
)
and
(
4
5
6
);
*/
/*
a
:
1
<
2
;
/*
a
:
1
<
2
;
b
:
1
>
2
;
b
:
1
>
2
;
c
:
1
>
2
or
3
<
4
;
c
:
1
>
2
or
3
<
4
;
...
...
document.hpp
View file @
c6394df2
...
@@ -131,6 +131,7 @@ namespace Sass {
...
@@ -131,6 +131,7 @@ namespace Sass {
Node
parse_list
();
Node
parse_list
();
Node
parse_comma_list
();
Node
parse_comma_list
();
Node
parse_space_list
();
Node
parse_space_list
();
Node
parse_relation
();
Node
parse_expression
();
Node
parse_expression
();
Node
parse_term
();
Node
parse_term
();
Node
parse_factor
();
Node
parse_factor
();
...
...
document_parser.cpp
View file @
c6394df2
...
@@ -419,31 +419,62 @@ namespace Sass {
...
@@ -419,31 +419,62 @@ namespace Sass {
Node
Document
::
parse_space_list
()
Node
Document
::
parse_space_list
()
{
{
Node
expr1
(
parse_express
ion
());
Node
rel1
(
parse_relat
ion
());
// if it's a singleton, return it directly; don't wrap it
// if it's a singleton, return it directly; don't wrap it
if
(
peek
<
exactly
<
';'
>
>
(
position
)
||
if
(
peek
<
exactly
<
';'
>
>
(
position
)
||
peek
<
exactly
<
'}'
>
>
(
position
)
||
peek
<
exactly
<
'}'
>
>
(
position
)
||
peek
<
exactly
<
')'
>
>
(
position
)
||
peek
<
exactly
<
')'
>
>
(
position
)
||
peek
<
exactly
<
','
>
>
(
position
))
peek
<
exactly
<
','
>
>
(
position
))
{
return
expr
1
;
}
{
return
rel
1
;
}
Node
space_list
(
Node
::
space_list
,
line_number
,
2
);
Node
space_list
(
Node
::
space_list
,
line_number
,
2
);
space_list
<<
expr
1
;
space_list
<<
rel
1
;
space_list
.
eval_me
|=
expr
1
.
eval_me
;
space_list
.
eval_me
|=
rel
1
.
eval_me
;
while
(
!
(
peek
<
exactly
<
';'
>
>
(
position
)
||
while
(
!
(
peek
<
exactly
<
';'
>
>
(
position
)
||
peek
<
exactly
<
'}'
>
>
(
position
)
||
peek
<
exactly
<
'}'
>
>
(
position
)
||
peek
<
exactly
<
')'
>
>
(
position
)
||
peek
<
exactly
<
')'
>
>
(
position
)
||
peek
<
exactly
<
','
>
>
(
position
)))
peek
<
exactly
<
','
>
>
(
position
)))
{
{
Node
expr
(
parse_express
ion
());
Node
rel
(
parse_relat
ion
());
space_list
<<
expr
;
space_list
<<
rel
;
space_list
.
eval_me
|=
expr
.
eval_me
;
space_list
.
eval_me
|=
rel
.
eval_me
;
}
}
return
space_list
;
return
space_list
;
}
}
Node
Document
::
parse_relation
()
{
Node
expr1
(
parse_expression
());
// if it's a singleton, return it directly; don't wrap it
if
(
!
(
peek
<
eq_op
>
(
position
)
||
peek
<
neq_op
>
(
position
)
||
peek
<
gt_op
>
(
position
)
||
peek
<
gte_op
>
(
position
)
||
peek
<
lt_op
>
(
position
)
||
peek
<
lte_op
>
(
position
)))
{
return
expr1
;
}
Node
relation
(
Node
::
relation
,
line_number
,
2
);
expr1
.
eval_me
=
true
;
relation
<<
expr1
;
if
(
lex
<
eq_op
>
())
relation
<<
Node
(
Node
::
eq
,
line_number
,
lexed
);
else
if
(
lex
<
neq_op
>
())
relation
<<
Node
(
Node
::
neq
,
line_number
,
lexed
);
else
if
(
lex
<
gt_op
>
())
relation
<<
Node
(
Node
::
gt
,
line_number
,
lexed
);
else
if
(
lex
<
gte_op
>
())
relation
<<
Node
(
Node
::
gte
,
line_number
,
lexed
);
else
if
(
lex
<
lt_op
>
())
relation
<<
Node
(
Node
::
lt
,
line_number
,
lexed
);
else
if
(
lex
<
lte_op
>
())
relation
<<
Node
(
Node
::
lte
,
line_number
,
lexed
);
Node
expr2
(
parse_expression
());
expr2
.
eval_me
=
true
;
relation
<<
expr2
;
relation
.
eval_me
=
true
;
return
relation
;
}
Node
Document
::
parse_expression
()
Node
Document
::
parse_expression
()
{
{
Node
term1
(
parse_term
());
Node
term1
(
parse_term
());
...
...
eval_apply.cpp
View file @
c6394df2
...
@@ -84,6 +84,28 @@ namespace Sass {
...
@@ -84,6 +84,28 @@ namespace Sass {
if
(
expr
.
eval_me
)
expr
[
0
]
=
eval
(
expr
[
0
],
env
,
f_env
);
if
(
expr
.
eval_me
)
expr
[
0
]
=
eval
(
expr
[
0
],
env
,
f_env
);
return
expr
;
return
expr
;
}
break
;
}
break
;
case
Node
:
:
relation
:
{
Node
lhs
(
eval
(
expr
[
0
],
env
,
f_env
));
Node
op
(
expr
[
1
]);
Node
rhs
(
eval
(
expr
[
2
],
env
,
f_env
));
Node
T
(
Node
::
boolean
);
T
.
line_number
=
lhs
.
line_number
;
T
.
content
.
boolean_value
=
true
;
Node
F
(
T
);
F
.
content
.
boolean_value
=
false
;
switch
(
op
.
type
)
{
case
Node
:
:
eq
:
return
(
lhs
==
rhs
)
?
T
:
F
;
case
Node
:
:
neq
:
return
(
lhs
!=
rhs
)
?
T
:
F
;
case
Node
:
:
gt
:
return
(
lhs
>
rhs
)
?
T
:
F
;
case
Node
:
:
gte
:
return
(
lhs
>=
rhs
)
?
T
:
F
;
case
Node
:
:
lt
:
return
(
lhs
<
rhs
)
?
T
:
F
;
case
Node
:
:
lte
:
return
(
lhs
<=
rhs
)
?
T
:
F
;
}
}
break
;
case
Node
:
:
expression
:
{
case
Node
:
:
expression
:
{
Node
acc
(
Node
::
expression
,
expr
.
line_number
,
1
);
Node
acc
(
Node
::
expression
,
expr
.
line_number
,
1
);
...
...
node.hpp
View file @
c6394df2
...
@@ -41,6 +41,14 @@ namespace Sass {
...
@@ -41,6 +41,14 @@ namespace Sass {
disjunction
,
disjunction
,
conjunction
,
conjunction
,
relation
,
eq
,
neq
,
gt
,
gte
,
lt
,
lte
,
expression
,
expression
,
add
,
add
,
...
@@ -126,7 +134,7 @@ namespace Sass {
...
@@ -126,7 +134,7 @@ namespace Sass {
return
*
this
;
return
*
this
;
}
}
double
numeric_value
()
double
numeric_value
()
const
{
{
switch
(
type
)
switch
(
type
)
{
{
...
@@ -149,6 +157,13 @@ namespace Sass {
...
@@ -149,6 +157,13 @@ namespace Sass {
return
*
this
;
return
*
this
;
}
}
bool
operator
==
(
const
Node
&
rhs
)
const
;
bool
operator
!=
(
const
Node
&
rhs
)
const
;
bool
operator
<
(
const
Node
&
rhs
)
const
;
bool
operator
<=
(
const
Node
&
rhs
)
const
;
bool
operator
>
(
const
Node
&
rhs
)
const
;
bool
operator
>=
(
const
Node
&
rhs
)
const
;
string
to_string
(
const
string
&
prefix
)
const
;
string
to_string
(
const
string
&
prefix
)
const
;
void
echo
(
stringstream
&
buf
,
size_t
depth
=
0
);
void
echo
(
stringstream
&
buf
,
size_t
depth
=
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