Adjusted cc_macro.c formatting with astyle -A1tSxejz2fpUxV
This commit is contained in:
parent
63bb59404d
commit
0ab7cb78eb
39
cc_macro.c
39
cc_macro.c
|
@ -19,9 +19,10 @@
|
|||
|
||||
void require(int bool, char* error);
|
||||
int numerate_string(char* a);
|
||||
void line_error_token(struct token_list *);
|
||||
void line_error_token(struct token_list* list);
|
||||
|
||||
struct conditional_inclusion {
|
||||
struct conditional_inclusion
|
||||
{
|
||||
struct conditional_inclusion* prev;
|
||||
int include; /* 1 == include, 0 == skip */
|
||||
int previous_condition_matched; /* 1 == all subsequent conditions treated as FALSE */
|
||||
|
@ -37,13 +38,19 @@ void eat_current_token()
|
|||
struct token_list* tmp;
|
||||
|
||||
if(NULL != macro_token->prev)
|
||||
{
|
||||
macro_token->prev->next = macro_token->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
global_token = macro_token->next;
|
||||
}
|
||||
|
||||
/* update backlinks */
|
||||
if(NULL != macro_token->next)
|
||||
{
|
||||
macro_token->next->prev = macro_token->prev;
|
||||
}
|
||||
|
||||
tmp = macro_token;
|
||||
macro_token = macro_token->next;
|
||||
|
@ -56,15 +63,18 @@ void eat_newline_tokens()
|
|||
|
||||
while(TRUE)
|
||||
{
|
||||
if (NULL == macro_token)
|
||||
return;
|
||||
if(NULL == macro_token) return;
|
||||
|
||||
if(match("\n", macro_token->s))
|
||||
{
|
||||
eat_current_token();
|
||||
}
|
||||
else
|
||||
{
|
||||
macro_token = macro_token->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int macro_expression();
|
||||
int macro_variable()
|
||||
|
@ -95,13 +105,20 @@ int macro_primary_expr()
|
|||
{
|
||||
eat_current_token();
|
||||
return macro_expression();
|
||||
} else if (in_set(macro_token->s[0], "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"))
|
||||
}
|
||||
else if(in_set(macro_token->s[0], "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"))
|
||||
{
|
||||
return macro_variable();
|
||||
}
|
||||
else if(in_set(macro_token->s[0], "0123456789"))
|
||||
{
|
||||
return macro_number();
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0; /* FIXME: error handling */
|
||||
}
|
||||
}
|
||||
|
||||
int macro_additive_expr()
|
||||
{
|
||||
|
@ -234,11 +251,11 @@ int macro_expression()
|
|||
}
|
||||
|
||||
|
||||
|
||||
void macro_directive()
|
||||
{
|
||||
struct conditional_inclusion *t;
|
||||
int result;
|
||||
|
||||
/* FIXME: whitespace is allowed between "#"" and "if" */
|
||||
if(match("#if", macro_token->s))
|
||||
{
|
||||
|
@ -250,10 +267,12 @@ void macro_directive()
|
|||
t->prev = conditional_inclusion_top;
|
||||
conditional_inclusion_top = t;
|
||||
t->include = TRUE;
|
||||
|
||||
if(FALSE == result)
|
||||
{
|
||||
t->include = FALSE;
|
||||
}
|
||||
|
||||
t->previous_condition_matched = t->include;
|
||||
}
|
||||
else if(match("#elif", macro_token->s))
|
||||
|
@ -277,6 +296,7 @@ void macro_directive()
|
|||
file_print("unexpected #endif\n", stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
eat_current_token();
|
||||
/* pop conditional inclusion */
|
||||
t = conditional_inclusion_top;
|
||||
|
@ -289,10 +309,14 @@ void macro_directive()
|
|||
while(TRUE)
|
||||
{
|
||||
if(NULL == macro_token)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if('\n' == macro_token->s[0])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
eat_current_token();
|
||||
}
|
||||
|
@ -306,10 +330,10 @@ void preprocess()
|
|||
|
||||
while(NULL != macro_token)
|
||||
{
|
||||
|
||||
if(start_of_line && '#' == macro_token->s[0])
|
||||
{
|
||||
macro_directive();
|
||||
|
||||
if(macro_token)
|
||||
{
|
||||
if('\n' != macro_token->s[0])
|
||||
|
@ -331,6 +355,7 @@ void preprocess()
|
|||
else
|
||||
{
|
||||
start_of_line = FALSE;
|
||||
|
||||
if(NULL == conditional_inclusion_top)
|
||||
{
|
||||
macro_token = macro_token->next;
|
||||
|
|
Loading…
Reference in New Issue