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
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
10 deletions
+30
-10
context.cpp
context.cpp
+3
-3
document_parser.cpp
document_parser.cpp
+18
-7
exceptional.scss
exceptional.scss
+9
-0
No files found.
context.cpp
View file @
bb2f9333
...
...
@@ -33,9 +33,9 @@ namespace Sass {
}
}
for
(
int
i
=
0
;
i
<
include_paths
.
size
();
++
i
)
{
cerr
<<
include_paths
[
i
]
<<
endl
;
}
//
for (int i = 0; i < include_paths.size(); ++i) {
//
cerr << include_paths[i] << endl;
//
}
}
Context
::
Context
(
const
char
*
paths_str
)
...
...
document_parser.cpp
View file @
bb2f9333
...
...
@@ -16,7 +16,7 @@ namespace Sass {
else
if
(
peek
<
import
>
(
position
))
{
// TO DO: don't splice in place at parse-time -- use an expansion node
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
))
{
root
<<
parse_mixin_definition
();
...
...
@@ -24,11 +24,11 @@ namespace Sass {
else
if
(
peek
<
include
>
(
position
))
{
root
<<
parse_mixin_call
();
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
))
{
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
{
root
<<
parse_ruleset
();
...
...
@@ -40,7 +40,8 @@ namespace Sass {
Node
Document
::
parse_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
());
const
char
*
curr_path_start
=
path
.
c_str
();
const
char
*
curr_path_end
=
folders
(
curr_path_start
);
...
...
@@ -53,9 +54,10 @@ namespace Sass {
Node
Document
::
parse_mixin_definition
()
{
lex
<
mixin
>
();
lex
<
identifier
>
(
);
if
(
!
lex
<
identifier
>
())
syntax_error
(
"invalid name for @mixin directive"
);
Node
name
(
Node
::
identifier
,
line_number
,
lexed
);
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
mixin
(
Node
::
mixin
,
line_number
,
3
);
mixin
<<
name
<<
params
<<
body
;
...
...
@@ -65,14 +67,18 @@ namespace Sass {
Node
Document
::
parse_mixin_parameters
()
{
Node
params
(
Node
::
parameters
,
line_number
);
lex
<
exactly
<
'('
>
>
();
Token
name
(
lexed
);
if
(
lex
<
exactly
<
'('
>
>
())
{
if
(
peek
<
variable
>
())
{
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
;
}
...
...
@@ -448,6 +454,7 @@ namespace Sass {
{
if
(
peek
<
exactly
<
';'
>
>
(
position
)
||
peek
<
exactly
<
'}'
>
>
(
position
)
||
peek
<
exactly
<
'{'
>
>
(
position
)
||
peek
<
exactly
<
')'
>
>
(
position
))
{
return
Node
(
Node
::
nil
,
line_number
);
// TO DO: maybe use Node::none?
}
...
...
@@ -475,6 +482,7 @@ namespace Sass {
// if it's a singleton, return it directly; don't wrap it
if
(
peek
<
exactly
<
';'
>
>
(
position
)
||
peek
<
exactly
<
'}'
>
>
(
position
)
||
peek
<
exactly
<
'{'
>
>
(
position
)
||
peek
<
exactly
<
')'
>
>
(
position
)
||
peek
<
exactly
<
','
>
>
(
position
))
{
return
disj1
;
}
...
...
@@ -485,6 +493,7 @@ namespace Sass {
while
(
!
(
peek
<
exactly
<
';'
>
>
(
position
)
||
peek
<
exactly
<
'}'
>
>
(
position
)
||
peek
<
exactly
<
'{'
>
>
(
position
)
||
peek
<
exactly
<
')'
>
>
(
position
)
||
peek
<
exactly
<
','
>
>
(
position
)))
{
...
...
@@ -682,6 +691,8 @@ namespace Sass {
var
.
eval_me
=
true
;
return
var
;
}
syntax_error
(
"expected to find more values after "
+
lexed
.
to_string
());
}
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