Improve #def
This commit is contained in:
parent
74d20d9f37
commit
b98579699d
@ -26,9 +26,10 @@ bool replace(tSyntaxElement* tree, tProcessingData* pd) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_mod(tSyntaxElement* tree, tProcessingData* pdata) {
|
bool process_mod(tSyntaxElement* tree, tProcessingData* pdata) {
|
||||||
|
|
||||||
tProcessingData* pd = pdata;
|
tProcessingData* pd = pdata;
|
||||||
|
bool b = false;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
@ -38,7 +39,8 @@ void process_mod(tSyntaxElement* tree, tProcessingData* pdata) {
|
|||||||
if (tree->type == TOKEN) {
|
if (tree->type == TOKEN) {
|
||||||
switch (pd->type) {
|
switch (pd->type) {
|
||||||
case REPLACE:
|
case REPLACE:
|
||||||
replace(tree,pd);
|
if (replace(tree,pd))
|
||||||
|
b = true;
|
||||||
break;
|
break;
|
||||||
case FUNCTION:
|
case FUNCTION:
|
||||||
break;
|
break;
|
||||||
@ -52,6 +54,8 @@ void process_mod(tSyntaxElement* tree, tProcessingData* pdata) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return b;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool process_find(tSyntaxElement* tree, tProcessingData** p_pdata) {
|
bool process_find(tSyntaxElement* tree, tProcessingData** p_pdata) {
|
||||||
@ -129,11 +133,12 @@ bool process_find(tSyntaxElement* tree, tProcessingData** p_pdata) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void process(tSyntaxElement* tree, tProcessingData* pdata) {
|
bool process(tSyntaxElement* tree, tProcessingData* pdata) {
|
||||||
|
|
||||||
tProcessingData* pd = pdata;
|
tProcessingData* pd = pdata;
|
||||||
|
|
||||||
bool deffound = false;
|
bool deffound = false;
|
||||||
|
bool didreplace = false;
|
||||||
|
|
||||||
tProcessingData* firstpd = NULL;
|
tProcessingData* firstpd = NULL;
|
||||||
|
|
||||||
@ -147,22 +152,29 @@ void process(tSyntaxElement* tree, tProcessingData* pdata) {
|
|||||||
deffound = process_find(tree, &pd);
|
deffound = process_find(tree, &pd);
|
||||||
|
|
||||||
if (tree->next != NULL) {
|
if (tree->next != NULL) {
|
||||||
process(tree->next, pd);
|
if (process(tree->next, pd))
|
||||||
|
didreplace = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!deffound) {
|
if (!deffound) {
|
||||||
|
|
||||||
if (se_istraversable(tree))
|
if (se_istraversable(tree))
|
||||||
process(tree->content.syntax, pd);
|
if (process(tree->content.syntax, pd))
|
||||||
|
didreplace = true;
|
||||||
|
|
||||||
process_mod(tree, pd);
|
if (process_mod(tree, pd))
|
||||||
|
didreplace = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pd != pdata)
|
if (pd != pdata)
|
||||||
free(pd);
|
free(pd);
|
||||||
|
|
||||||
if (firstpd != pd && firstpd != NULL)
|
if (firstpd != pd && firstpd != NULL) {
|
||||||
free(firstpd);
|
free(firstpd);
|
||||||
|
if (didreplace)
|
||||||
|
process(tree, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return didreplace;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user