Commit 9867ac1a by Aaron Leung

Still working on syntax error handling.

parent 0efb479b
...@@ -28,7 +28,7 @@ namespace Sass { ...@@ -28,7 +28,7 @@ namespace Sass {
} }
else if (peek< variable >(position)) { else if (peek< variable >(position)) {
root << parse_assignment(); root << parse_assignment();
// missing semicolon will be caught further down if (!lex< exactly<';'> >()) syntax_error("top-level variable binding must be terminated by ';'");
} }
else { else {
root << parse_ruleset(); root << parse_ruleset();
...@@ -158,7 +158,7 @@ namespace Sass { ...@@ -158,7 +158,7 @@ namespace Sass {
ruleset << parse_selector_group(); ruleset << parse_selector_group();
// if (ruleset[0].type == Node::selector) cerr << "ruleset starts with selector" << endl; // if (ruleset[0].type == Node::selector) cerr << "ruleset starts with selector" << endl;
// if (ruleset[0].type == Node::selector_group) cerr << "ruleset starts with selector_group" << endl; // if (ruleset[0].type == Node::selector_group) cerr << "ruleset starts with selector_group" << endl;
if (!peek< exactly<'{'> >()) syntax_error("expected a '{' after the selector");
ruleset << parse_block(definition); ruleset << parse_block(definition);
return ruleset; return ruleset;
} }
...@@ -389,17 +389,20 @@ namespace Sass { ...@@ -389,17 +389,20 @@ namespace Sass {
block << Node(Node::flags); block << Node(Node::flags);
while (!lex< exactly<'}'> >()) { while (!lex< exactly<'}'> >()) {
if (semicolon) { if (semicolon) {
lex< exactly<';'> >(); // enforce terminal ';' here if (!lex< exactly<';'> >()) syntax_error("non-terminal statement or declaration must end with ';'");
semicolon = false; semicolon = false;
if (lex< exactly<'}'> >()) break; // if (lex< exactly<'}'> >()) break;
} }
if (lex< block_comment >()) { if (lex< block_comment >()) {
block << Node(Node::comment, line_number, lexed); block << Node(Node::comment, line_number, lexed);
block[0].has_statements = true; block[0].has_statements = true;
semicolon = true; //semicolon = true;
} }
else if (peek< import >(position)) { else if (peek< import >(position)) {
// TO DO: disallow imports inside of definitions if (definition) {
lex< import >(); // to adjust the line number
syntax_error("@import directive not allowed inside mixin definition");
}
Node imported_tree(parse_import()); Node imported_tree(parse_import());
for (int i = 0; i < imported_tree.size(); ++i) { for (int i = 0; i < imported_tree.size(); ++i) {
if (imported_tree[i].type == Node::comment || if (imported_tree[i].type == Node::comment ||
...@@ -416,6 +419,7 @@ namespace Sass { ...@@ -416,6 +419,7 @@ namespace Sass {
else if (peek< include >(position)) { else if (peek< include >(position)) {
block << parse_mixin_call(); block << parse_mixin_call();
block[0].has_expansions = true; block[0].has_expansions = true;
semicolon = true;
} }
else if (lex< variable >()) { else if (lex< variable >()) {
block << parse_assignment(); block << parse_assignment();
...@@ -438,7 +442,7 @@ namespace Sass { ...@@ -438,7 +442,7 @@ namespace Sass {
block << parse_rule(); block << parse_rule();
block[0].has_statements = true; block[0].has_statements = true;
semicolon = true; semicolon = true;
lex< exactly<';'> >(); // TO DO: clean up the semicolon handling stuff //lex< exactly<';'> >(); // TO DO: clean up the semicolon handling stuff
} }
else lex< exactly<';'> >(); else lex< exactly<';'> >();
while (lex< block_comment >()) { while (lex< block_comment >()) {
......
$x: 1 2 3;
bobo + mogo { bobo + mogo {
hey: hoo; hey: hoo;
} }
@mixin moogoo() {
hey: ho;
div {
blah: blah;
}
}
:nth-of-type(2) { :nth-of-type(2) {
foo: bar; foo: bar;
} }
div[hux ~= "hello" { div[hux ~= "hello"] {
foo: bar; hux: blux;
foo: boo;
@include moogoo;
dux: mux
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment