bool loadIncremental(size_t count_limit);
- "Unexpected end ond of file");
+ void doInclude() {
+ // First, get the filename to include
+ const string
+ filename(lexer_.getNextToken(MasterToken::QSTRING).getString());
+
+ // There could be an origin (or maybe not). So try looking
+ const MasterToken name_tok(lexer_.getNextToken(MasterToken::QSTRING,
+ true));
+
+ if (name_tok.getType() == MasterToken::QSTRING ||
+ name_tok.getType() == MasterToken::STRING) {
+ // TODO: Handle the origin. Once we complete #2427.
+ } else {
+ // We return the newline there. This is because after we pop
+ // the source, we want to call eatUntilEOL and this would
+ // eat to the next one.
+ lexer_.ungetToken();
+ }
+
+ pushSource(filename);
+ }
+
+ void handleDirective(const char* directive, size_t length) {
+ if (iequals(directive, "INCLUDE")) {
+ doInclude();
+ } else if (iequals(directive, "ORIGIN")) {
+ // TODO: Implement
+ isc_throw(isc::NotImplemented,
+ "Origin directive not implemented yet");
+ } else if (iequals(directive, "TTL")) {
+ // TODO: Implement
+ isc_throw(isc::NotImplemented,
+ "TTL directive not implemented yet");
+ } else {
+ isc_throw(InternalException, "Unknown directive '" <<
+ string(directive, directive + length) << "'");
+ }
+ }
+
+ void eatUntilEOL(bool reportExtra) {
+ // We want to continue. Try to read until the end of line
+ for (;;) {
+ const MasterToken& token(lexer_.getNextToken());
+ switch (token.getType()) {
+ case MasterToken::END_OF_FILE:
+ callbacks_.warning(lexer_.getSourceName(),
+ lexer_.getSourceLine(),
++ "File does not end with newline");
+ // We don't pop here. The End of file will stay there,
+ // and we'll handle it in the next iteration of
+ // loadIncremental properly.
+ return;
+ case MasterToken::END_OF_LINE:
+ // Found the end of the line. Good.
+ return;
+ default:
+ // Some other type of token.
+ if (reportExtra) {
+ reportExtra = false;
+ reportError(lexer_.getSourceName(),
+ lexer_.getSourceLine(),
+ "Extra tokens at the end of line");
+ }
+ break;
+ }
+ }
+ }
+
private:
MasterLexer lexer_;
const Name zone_origin_;