Directives no longer require @ or ! prefix char

This commit is contained in:
John Wiegley 2009-11-10 01:05:12 -05:00
parent c927c74c2d
commit 09c9ec4b41

View file

@ -125,7 +125,7 @@ namespace {
void tag_directive(char * line); void tag_directive(char * line);
void pop_directive(char * line); void pop_directive(char * line);
void define_directive(char * line); void define_directive(char * line);
void general_directive(char * line); bool general_directive(char * line);
post_t * parse_post(char * line, post_t * parse_post(char * line,
std::streamsize len, std::streamsize len,
@ -354,6 +354,13 @@ void instance_t::read_next_directive()
period_xact_directive(line); period_xact_directive(line);
break; break;
case '@':
case '!':
line++;
// fall through...
default: // some other directive
if (! general_directive(line)) {
switch (line[0]) {
#if defined(TIMELOG_SUPPORT) #if defined(TIMELOG_SUPPORT)
case 'i': case 'i':
clock_in_directive(line, false); clock_in_directive(line, false);
@ -392,13 +399,8 @@ void instance_t::read_next_directive()
case 'Y': // set the current year case 'Y': // set the current year
year_directive(line); year_directive(line);
break; break;
}
case '@': }
case '!':
line++;
// fall through...
default: // some other directive
general_directive(line);
break; break;
} }
} }
@ -689,58 +691,56 @@ void instance_t::define_directive(char * line)
def.compile(scope); // causes definitions to be established def.compile(scope); // causes definitions to be established
} }
void instance_t::general_directive(char * line) bool instance_t::general_directive(char * line)
{ {
char * p = line; char * p = line;
char * arg = next_element(line);
if (*p == '@' || *p == '!') if (*p == '@' || *p == '!')
p++; p++;
switch (*p) { switch (*p) {
case 'a': case 'a':
if (std::strcmp(p, "account") == 0) { if (std::strcmp(p, "account") == 0) {
account_directive(arg); account_directive(next_element(line));
return; return true;
} }
else if (std::strcmp(p, "alias") == 0) { else if (std::strcmp(p, "alias") == 0) {
alias_directive(arg); alias_directive(next_element(line));
return; return true;
} }
break; break;
case 'd': case 'd':
if (std::strcmp(p, "def") == 0) { if (std::strcmp(p, "def") == 0) {
define_directive(arg); define_directive(next_element(line));
return; return true;
} }
break; break;
case 'e': case 'e':
if (std::strcmp(p, "end") == 0) { if (std::strcmp(p, "end") == 0) {
end_directive(arg); end_directive(next_element(line));
return; return true;
} }
break; break;
case 'i': case 'i':
if (std::strcmp(p, "include") == 0) { if (std::strcmp(p, "include") == 0) {
include_directive(arg); include_directive(next_element(line));
return; return true;
} }
break; break;
case 'p': case 'p':
if (std::strcmp(p, "pop") == 0) { if (std::strcmp(p, "pop") == 0) {
pop_directive(arg); pop_directive(next_element(line));
return; return true;
} }
break; break;
case 't': case 't':
if (std::strcmp(p, "tag") == 0) { if (std::strcmp(p, "tag") == 0) {
tag_directive(arg); tag_directive(next_element(line));
return; return true;
} }
break; break;
} }
@ -749,7 +749,10 @@ void instance_t::general_directive(char * line)
call_scope_t args(*this); call_scope_t args(*this);
args.push_back(string_value(p)); args.push_back(string_value(p));
op->as_function()(args); op->as_function()(args);
return true;
} }
return false;
} }
post_t * instance_t::parse_post(char * line, post_t * instance_t::parse_post(char * line,