Commit b47fadb1 by Aaron Leung

Successfully parsing and saving statement-level comments. More to come.

parent 3945804b
/* hey, a comment */
/* hey, another comment */ /* and another */
/* all of these should be kept */
......@@ -30,4 +30,22 @@ namespace Sass {
delete [] source;
}
void Document::parse_stylesheet() {
printf("ABOUT TO MUNCH LEADING SPACES\n");
try_munching<optional_spaces>();
while (*position) {
printf("LOOPING OVER STATEMENTS\n");
statements.push_back(parse_statement());
try_munching<optional_spaces>();
}
}
Node Document::parse_statement() {
if (try_munching<block_comment>()) {
printf("MUNCHING A COMMENT\n");
return Node(Node::comment, top);
}
else return Node();
}
}
\ No newline at end of file
......@@ -36,6 +36,9 @@ namespace Sass {
return last_munch_succeeded = false;
}
}
else if (mx == optional_spaces) {
after_whitespace = optional_spaces(position);
}
else {
after_whitespace = spaces_and_comments(position);
}
......@@ -51,5 +54,8 @@ namespace Sass {
}
}
void parse_stylesheet();
Node parse_statement();
};
}
\ No newline at end of file
#include <cstdio>
#include <iostream>
#include "document.hpp"
using namespace Sass;
......@@ -38,6 +39,20 @@ int main(int argc, char* argv[]) {
printf("sizeof node object is %ld\n", sizeof(Node));
printf("sizeof Node vector object is %ld\n", sizeof(std::vector<Node>));
printf("sizeof pointer to Node vector is %ld\n", sizeof(std::vector<Node>*));
printf("GOING TO TRY PARSING NOW\n");
doc.position = doc.source;
std::cout << doc.position << std::endl;
if (*(doc.position)) std::cout << "position has content!" << std::endl;
doc.parse_stylesheet();
int i;
int j = doc.statements.size();
printf("%d\n", j);
for (i = 0; i < j; ++i) {
print_slice(doc.statements[i].token.begin, doc.statements[i].token.end);
}
}
return 0;
......
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