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
008fdc67
Commit
008fdc67
authored
Aug 28, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improving argument parsing to match the new restrictions in canonical Sass.
parent
b0fc4958
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
5 deletions
+35
-5
document.hpp
document.hpp
+1
-1
document_parser.cpp
document_parser.cpp
+34
-4
No files found.
document.hpp
View file @
008fdc67
...
@@ -133,7 +133,7 @@ namespace Sass {
...
@@ -133,7 +133,7 @@ namespace Sass {
Node
parse_parameter
();
Node
parse_parameter
();
Node
parse_mixin_call
();
Node
parse_mixin_call
();
Node
parse_arguments
();
Node
parse_arguments
();
Node
parse_argument
();
Node
parse_argument
(
Node
::
Type
);
Node
parse_assignment
();
Node
parse_assignment
();
Node
parse_propset
();
Node
parse_propset
();
Node
parse_ruleset
(
Selector_Lookahead
lookahead
,
Node
::
Type
inside_of
=
Node
::
none
);
Node
parse_ruleset
(
Selector_Lookahead
lookahead
,
Node
::
Type
inside_of
=
Node
::
none
);
...
...
document_parser.cpp
View file @
008fdc67
...
@@ -192,15 +192,18 @@ namespace Sass {
...
@@ -192,15 +192,18 @@ namespace Sass {
{
{
Token
name
(
lexed
);
Token
name
(
lexed
);
Node
args
(
context
.
new_Node
(
Node
::
arguments
,
path
,
line
,
0
));
Node
args
(
context
.
new_Node
(
Node
::
arguments
,
path
,
line
,
0
));
Node
::
Type
arg_type
=
Node
::
none
;
if
(
lex
<
exactly
<
'('
>
>
())
{
if
(
lex
<
exactly
<
'('
>
>
())
{
if
(
!
peek
<
exactly
<
')'
>
>
(
position
))
{
if
(
!
peek
<
exactly
<
')'
>
>
(
position
))
{
Node
arg
(
parse_argument
());
Node
arg
(
parse_argument
(
Node
::
none
));
arg
.
should_eval
()
=
true
;
arg
.
should_eval
()
=
true
;
args
<<
arg
;
args
<<
arg
;
if
(
arg
.
type
()
==
Node
::
assignment
)
arg_type
=
Node
::
assignment
;
while
(
lex
<
exactly
<
','
>
>
())
{
while
(
lex
<
exactly
<
','
>
>
())
{
Node
arg
(
parse_argument
());
Node
arg
(
parse_argument
(
arg_type
));
arg
.
should_eval
()
=
true
;
arg
.
should_eval
()
=
true
;
args
<<
arg
;
args
<<
arg
;
if
(
arg
.
type
()
==
Node
::
assignment
)
arg_type
=
Node
::
assignment
;
}
}
}
}
if
(
!
lex
<
exactly
<
')'
>
>
())
throw_syntax_error
(
"improperly terminated argument list for "
+
name
.
to_string
());
if
(
!
lex
<
exactly
<
')'
>
>
())
throw_syntax_error
(
"improperly terminated argument list for "
+
name
.
to_string
());
...
@@ -208,8 +211,10 @@ namespace Sass {
...
@@ -208,8 +211,10 @@ namespace Sass {
return
args
;
return
args
;
}
}
Node
Document
::
parse_argument
()
Node
Document
::
parse_argument
(
Node
::
Type
arg_type
)
{
{
// if arg_type is assignment, only accept keyword args from here onwards
if
(
arg_type
==
Node
::
assignment
)
{
if
(
peek
<
sequence
<
variable
,
spaces_and_comments
,
exactly
<
':'
>
>
>
())
{
if
(
peek
<
sequence
<
variable
,
spaces_and_comments
,
exactly
<
':'
>
>
>
())
{
lex
<
variable
>
();
lex
<
variable
>
();
Node
var
(
context
.
new_Node
(
Node
::
variable
,
path
,
line
,
lexed
));
Node
var
(
context
.
new_Node
(
Node
::
variable
,
path
,
line
,
lexed
));
...
@@ -220,8 +225,33 @@ namespace Sass {
...
@@ -220,8 +225,33 @@ namespace Sass {
return
assn
;
return
assn
;
}
}
else
{
else
{
return
parse_space_list
();
throw_syntax_error
(
"ordinal arguments must precede keyword arguments"
);
}
}
}
// otherwise accept either, and let the caller set the arg_type flag
if
(
arg_type
==
Node
::
none
&&
peek
<
sequence
<
variable
,
spaces_and_comments
,
exactly
<
':'
>
>
>
())
{
lex
<
variable
>
();
Node
var
(
context
.
new_Node
(
Node
::
variable
,
path
,
line
,
lexed
));
lex
<
exactly
<
':'
>
>
();
Node
val
(
parse_space_list
());
Node
assn
(
context
.
new_Node
(
Node
::
assignment
,
path
,
line
,
2
));
assn
<<
var
<<
val
;
return
assn
;
}
return
parse_space_list
();
// if (peek< sequence < variable, spaces_and_comments, exactly<':'> > >()) {
// lex< variable >();
// Node var(context.new_Node(Node::variable, path, line, lexed));
// lex< exactly<':'> >();
// Node val(parse_space_list());
// Node assn(context.new_Node(Node::assignment, path, line, 2));
// assn << var << val;
// return assn;
// }
// else {
// return parse_space_list();
// }
}
}
Node
Document
::
parse_assignment
()
Node
Document
::
parse_assignment
()
...
...
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