Commit 5eac82d3 by Aaron Leung

Allowing the parser to parse an arbitrary interval rather than all the way to the null terminator.

parent 5a78adc0
......@@ -23,6 +23,7 @@ namespace Sass {
source = new char[len + 1];
std::fread(source, sizeof(char), len, f);
source[len] = '\0';
end = source + len;
std::fclose(f);
own_source = true;
}
......@@ -48,12 +49,21 @@ namespace Sass {
source = new char[len + 1];
std::fread(source, sizeof(char), len, f);
source[len] = '\0';
end = source + len;
std::fclose(f);
position = source;
context.source_refs.push_back(source);
++context.ref_count;
}
Document::Document(Token t, Context& context)
: context(context)
{
}
Document::~Document() {
--context.ref_count;
if (context.ref_count == 0) delete &context;
......
......@@ -18,6 +18,7 @@ namespace Sass {
string path;
char* source;
const char* position;
const char* end;
size_t line_number;
bool own_source;
......@@ -28,6 +29,7 @@ namespace Sass {
Document(string path, char* source = 0);
Document(string path, Context& context);
Document(Token t, Context& context);
~Document();
template <prelexer mx>
......
......@@ -8,7 +8,7 @@ namespace Sass {
{
lex<optional_spaces>();
root << Node(Node::flags);
while(*position) {
while(position < end) {
if (lex< block_comment >()) {
root << Node(Node::comment, line_number, lexed);
}
......
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