@@ -85,6 +85,8 @@ namespace Sass {
85
85
}
86
86
}
87
87
88
+ bool semicolon = false ;
89
+ string (error_message);
88
90
lex< optional_spaces >();
89
91
Selector_Lookahead lookahead_result;
90
92
while (position < end) {
@@ -97,22 +99,27 @@ namespace Sass {
97
99
(*root) << new (ctx.mem ) Import_Stub (pstate, imp->files ()[i]);
98
100
}
99
101
}
100
- if (!lex< one_plus< exactly<' ;' > > >()) error (" top-level @import directive must be terminated by ';'" , pstate);
102
+ semicolon = true ;
103
+ error_message = " top-level @import directive must be terminated by ';'" ;
101
104
}
102
105
else if (peek< kwd_mixin >() || peek< kwd_function >()) {
103
106
(*root) << parse_definition ();
104
107
}
105
108
else if (peek< variable >()) {
106
109
(*root) << parse_assignment ();
107
- if (!lex< one_plus< exactly<' ;' > > >()) error (" top-level variable binding must be terminated by ';'" , pstate);
110
+ semicolon = true ;
111
+ error_message = " top-level variable binding must be terminated by ';'" ;
108
112
}
109
113
/* else if (peek< sequence< optional< exactly<'*'> >, alternatives< identifier_schema, identifier >, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
110
114
(*root) << parse_propset();
111
115
}*/
112
116
else if (peek< kwd_include >() /* || peek< exactly<'+'> >() */ ) {
113
117
Mixin_Call* mixin_call = parse_mixin_call ();
114
118
(*root) << mixin_call;
115
- if (!mixin_call->block () && !lex< one_plus< exactly<' ;' > > >()) error (" top-level @include directive must be terminated by ';'" , pstate);
119
+ if (!mixin_call->block ()) {
120
+ semicolon = true ;
121
+ error_message = " top-level @include directive must be terminated by ';'" ;
122
+ }
116
123
}
117
124
else if (peek< kwd_if_directive >()) {
118
125
(*root) << parse_if_directive ();
@@ -137,15 +144,18 @@ namespace Sass {
137
144
}
138
145
else if (peek< kwd_warn >()) {
139
146
(*root) << parse_warning ();
140
- if (!lex< one_plus< exactly<' ;' > > >()) error (" top-level @warn directive must be terminated by ';'" , pstate);
147
+ semicolon = true ;
148
+ error_message = " top-level @warn directive must be terminated by ';'" ;
141
149
}
142
150
else if (peek< kwd_err >()) {
143
151
(*root) << parse_error ();
144
- if (!lex< one_plus< exactly<' ;' > > >()) error (" top-level @error directive must be terminated by ';'" , pstate);
152
+ semicolon = true ;
153
+ error_message = " top-level @error directive must be terminated by ';'" ;
145
154
}
146
155
else if (peek< kwd_dbg >()) {
147
156
(*root) << parse_debug ();
148
- if (!lex< one_plus< exactly<' ;' > > >()) error (" top-level @debug directive must be terminated by ';'" , pstate);
157
+ semicolon = true ;
158
+ error_message = " top-level @debug directive must be terminated by ';'" ;
149
159
}
150
160
// ignore the @charset directive for now
151
161
else if (lex< exactly< charset_kwd > >()) {
@@ -155,7 +165,10 @@ namespace Sass {
155
165
else if (peek< at_keyword >()) {
156
166
At_Rule* at_rule = parse_at_rule ();
157
167
(*root) << at_rule;
158
- if (!at_rule->block () && !lex< one_plus< exactly<' ;' > > >()) error (" top-level directive must be terminated by ';'" , pstate);
168
+ if (!at_rule->block ()){
169
+ semicolon = true ;
170
+ error_message = " top-level directive must be terminated by ';'" ;
171
+ }
159
172
}
160
173
else if ((lookahead_result = lookahead_for_selector (position)).found ) {
161
174
(*root) << parse_ruleset (lookahead_result);
@@ -168,6 +181,11 @@ namespace Sass {
168
181
if (position >= end) break ;
169
182
error (" invalid top-level expression" , after_token);
170
183
}
184
+ if (semicolon) {
185
+ if (!lex< one_plus< exactly<' ;' > > >() && peek_css< optional_css_whitespace >() != end)
186
+ { error (error_message, pstate); }
187
+ semicolon = false ;
188
+ }
171
189
lex< optional_spaces >();
172
190
}
173
191
block_stack.pop_back ();
@@ -1174,7 +1192,7 @@ namespace Sass {
1174
1192
exactly<ellipsis>,
1175
1193
default_flag,
1176
1194
global_flag
1177
- > >(position))
1195
+ > >(position)) && peek_css< optional_css_whitespace >() != end
1178
1196
) {
1179
1197
(*space_list) << parse_disjunction ();
1180
1198
}
0 commit comments