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
bb2f9333
Commit
bb2f9333
authored
Apr 12, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detecting syntax errors.
parent
43ae0e6b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
13 deletions
+33
-13
context.cpp
context.cpp
+3
-3
document_parser.cpp
document_parser.cpp
+21
-10
exceptional.scss
exceptional.scss
+9
-0
No files found.
context.cpp
View file @
bb2f9333
...
@@ -33,9 +33,9 @@ namespace Sass {
...
@@ -33,9 +33,9 @@ namespace Sass {
}
}
}
}
for
(
int
i
=
0
;
i
<
include_paths
.
size
();
++
i
)
{
//
for (int i = 0; i < include_paths.size(); ++i) {
cerr
<<
include_paths
[
i
]
<<
endl
;
//
cerr << include_paths[i] << endl;
}
//
}
}
}
Context
::
Context
(
const
char
*
paths_str
)
Context
::
Context
(
const
char
*
paths_str
)
...
...
document_parser.cpp
View file @
bb2f9333
...
@@ -16,7 +16,7 @@ namespace Sass {
...
@@ -16,7 +16,7 @@ namespace Sass {
else
if
(
peek
<
import
>
(
position
))
{
else
if
(
peek
<
import
>
(
position
))
{
// TO DO: don't splice in place at parse-time -- use an expansion node
// TO DO: don't splice in place at parse-time -- use an expansion node
root
+=
parse_import
();
root
+=
parse_import
();
if
(
!
lex
<
exactly
<
';'
>
>
())
syntax_error
(
"top-level @import directive must be terminated by
a semicolon
"
);
if
(
!
lex
<
exactly
<
';'
>
>
())
syntax_error
(
"top-level @import directive must be terminated by
';'
"
);
}
}
else
if
(
peek
<
mixin
>
(
position
))
{
else
if
(
peek
<
mixin
>
(
position
))
{
root
<<
parse_mixin_definition
();
root
<<
parse_mixin_definition
();
...
@@ -24,11 +24,11 @@ namespace Sass {
...
@@ -24,11 +24,11 @@ namespace Sass {
else
if
(
peek
<
include
>
(
position
))
{
else
if
(
peek
<
include
>
(
position
))
{
root
<<
parse_mixin_call
();
root
<<
parse_mixin_call
();
root
[
0
].
has_expansions
=
true
;
root
[
0
].
has_expansions
=
true
;
if
(
!
lex
<
exactly
<
';'
>
>
())
syntax_error
(
"top-level @include directive must be terminated by
a semicolon
"
);
if
(
!
lex
<
exactly
<
';'
>
>
())
syntax_error
(
"top-level @include directive must be terminated by
';'
"
);
}
}
else
if
(
peek
<
variable
>
(
position
))
{
else
if
(
peek
<
variable
>
(
position
))
{
root
<<
parse_assignment
();
root
<<
parse_assignment
();
if
(
!
lex
<
exactly
<
';'
>
>
())
syntax_error
(
"top-level variable binding must be terminated by a semicolon"
);
// missing semicolon will be caught further down
}
}
else
{
else
{
root
<<
parse_ruleset
();
root
<<
parse_ruleset
();
...
@@ -40,7 +40,8 @@ namespace Sass {
...
@@ -40,7 +40,8 @@ namespace Sass {
Node
Document
::
parse_import
()
Node
Document
::
parse_import
()
{
{
lex
<
import
>
();
lex
<
import
>
();
lex
<
string_constant
>
();
if
(
!
lex
<
string_constant
>
())
syntax_error
(
"@import directive requires a quoted path"
);
// TO DO: BETTER PATH HANDLING
string
import_path
(
lexed
.
unquote
());
string
import_path
(
lexed
.
unquote
());
const
char
*
curr_path_start
=
path
.
c_str
();
const
char
*
curr_path_start
=
path
.
c_str
();
const
char
*
curr_path_end
=
folders
(
curr_path_start
);
const
char
*
curr_path_end
=
folders
(
curr_path_start
);
...
@@ -53,9 +54,10 @@ namespace Sass {
...
@@ -53,9 +54,10 @@ namespace Sass {
Node
Document
::
parse_mixin_definition
()
Node
Document
::
parse_mixin_definition
()
{
{
lex
<
mixin
>
();
lex
<
mixin
>
();
lex
<
identifier
>
(
);
if
(
!
lex
<
identifier
>
())
syntax_error
(
"invalid name for @mixin directive"
);
Node
name
(
Node
::
identifier
,
line_number
,
lexed
);
Node
name
(
Node
::
identifier
,
line_number
,
lexed
);
Node
params
(
parse_mixin_parameters
());
Node
params
(
parse_mixin_parameters
());
if
(
!
peek
<
exactly
<
'{'
>
>
())
syntax_error
(
"body for mixin "
+
name
.
content
.
token
.
to_string
()
+
" must begin with a '{'"
);
Node
body
(
parse_block
(
true
));
Node
body
(
parse_block
(
true
));
Node
mixin
(
Node
::
mixin
,
line_number
,
3
);
Node
mixin
(
Node
::
mixin
,
line_number
,
3
);
mixin
<<
name
<<
params
<<
body
;
mixin
<<
name
<<
params
<<
body
;
...
@@ -65,14 +67,18 @@ namespace Sass {
...
@@ -65,14 +67,18 @@ namespace Sass {
Node
Document
::
parse_mixin_parameters
()
Node
Document
::
parse_mixin_parameters
()
{
{
Node
params
(
Node
::
parameters
,
line_number
);
Node
params
(
Node
::
parameters
,
line_number
);
lex
<
exactly
<
'('
>
>
();
Token
name
(
lexed
);
if
(
peek
<
variable
>
())
{
if
(
lex
<
exactly
<
'('
>
>
())
{
params
<<
parse_parameter
();
if
(
peek
<
variable
>
())
{
while
(
lex
<
exactly
<
','
>
>
())
{
params
<<
parse_parameter
();
params
<<
parse_parameter
();
while
(
lex
<
exactly
<
','
>
>
())
{
if
(
!
peek
<
variable
>
())
syntax_error
(
"expected a variable name (e.g. $x) for the parameter list for "
+
name
.
to_string
());
params
<<
parse_parameter
();
}
if
(
!
lex
<
exactly
<
')'
>
>
())
syntax_error
(
"parameter list for "
+
name
.
to_string
()
+
" requires a ')'"
);
}
}
else
if
(
!
lex
<
exactly
<
')'
>
>
())
syntax_error
(
"expected a variable name (e.g. $x) or ')' for the parameter list for "
+
name
.
to_string
());
}
}
lex
<
exactly
<
')'
>
>
();
return
params
;
return
params
;
}
}
...
@@ -448,6 +454,7 @@ namespace Sass {
...
@@ -448,6 +454,7 @@ namespace Sass {
{
{
if
(
peek
<
exactly
<
';'
>
>
(
position
)
||
if
(
peek
<
exactly
<
';'
>
>
(
position
)
||
peek
<
exactly
<
'}'
>
>
(
position
)
||
peek
<
exactly
<
'}'
>
>
(
position
)
||
peek
<
exactly
<
'{'
>
>
(
position
)
||
peek
<
exactly
<
')'
>
>
(
position
))
{
peek
<
exactly
<
')'
>
>
(
position
))
{
return
Node
(
Node
::
nil
,
line_number
);
// TO DO: maybe use Node::none?
return
Node
(
Node
::
nil
,
line_number
);
// TO DO: maybe use Node::none?
}
}
...
@@ -475,6 +482,7 @@ namespace Sass {
...
@@ -475,6 +482,7 @@ namespace Sass {
// 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
))
peek
<
exactly
<
','
>
>
(
position
))
{
return
disj1
;
}
{
return
disj1
;
}
...
@@ -485,6 +493,7 @@ namespace Sass {
...
@@ -485,6 +493,7 @@ namespace Sass {
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
)))
peek
<
exactly
<
','
>
>
(
position
)))
{
{
...
@@ -682,6 +691,8 @@ namespace Sass {
...
@@ -682,6 +691,8 @@ namespace Sass {
var
.
eval_me
=
true
;
var
.
eval_me
=
true
;
return
var
;
return
var
;
}
}
syntax_error
(
"expected to find more values after "
+
lexed
.
to_string
());
}
}
Node
Document
::
parse_function_call
()
Node
Document
::
parse_function_call
()
...
...
exceptional.scss
0 → 100644
View file @
bb2f9333
@mixin
mux
(
$x
,
$y
)
{
bar
:
bar
;
bux
:
$x
$y
;
}
div
{
@include
mux
(
hey
,
ho
);
}
\ No newline at end of file
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