Trying
This commit is contained in:
parent
b22000d7c3
commit
32e9d7d671
49
a1/program.c
49
a1/program.c
@ -74,25 +74,7 @@ void read_input(LinkedNode** head){
|
|||||||
{
|
{
|
||||||
if(buff[i] == '[' || buff[i] == '<' || buff[i] == '{' || buff[i] == '('){
|
if(buff[i] == '[' || buff[i] == '<' || buff[i] == '{' || buff[i] == '('){
|
||||||
push(head, buff[i]);}
|
push(head, buff[i]);}
|
||||||
if(buff[i] == '[' || buff[i] == '<' || buff[i] == '{' || buff[i] == '(' && *head != NULL){
|
|
||||||
if(buff[i] == '['){
|
|
||||||
printf("Read: %sMissing closing brackets: ]\n", buff);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(buff[i] == '{'){
|
|
||||||
printf("Read: %sMissing closing brackets: }\n", buff);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(buff[i] == '<'){
|
|
||||||
printf("Read: %sMissing closing brackets: >\n", buff);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(buff[i] == '('){
|
|
||||||
printf("Read: %sMissing closing brackets: )\n", buff);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if(buff[i] == '>' || buff[i] == '}' || buff[i] == ']' || buff[i] == ')'){
|
if(buff[i] == '>' || buff[i] == '}' || buff[i] == ']' || buff[i] == ')'){
|
||||||
if(*head == NULL){
|
if(*head == NULL){
|
||||||
printf("Read: %sUnexpected closing bracket %c in %d\n", buff, buff[i], i);
|
printf("Read: %sUnexpected closing bracket %c in %d\n", buff, buff[i], i);
|
||||||
@ -100,10 +82,7 @@ void read_input(LinkedNode** head){
|
|||||||
}
|
}
|
||||||
char popped = pop(head);
|
char popped = pop(head);
|
||||||
if (!compare(popped, buff[i]))
|
if (!compare(popped, buff[i]))
|
||||||
{ if(popped == '[' && isalpha(buff[i])){
|
{
|
||||||
printf("Read: %sMissing brackets: ]", buff);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (popped == '[' && buff[i] == '>')
|
if (popped == '[' && buff[i] == '>')
|
||||||
{
|
{
|
||||||
printf("Read: %s\n", buff);
|
printf("Read: %s\n", buff);
|
||||||
@ -213,6 +192,32 @@ void read_input(LinkedNode** head){
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if(*head != NULL){
|
||||||
|
LinkedNode* ptr = *head;
|
||||||
|
while(ptr){
|
||||||
|
if(ptr->data == '['){
|
||||||
|
printf("Read: %sMissing closing brackets: ]\n", buff);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
if(ptr->data == '('){
|
||||||
|
printf("Read: %sMissing closing brackets: )\n", buff);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
if(ptr->data == '{'){
|
||||||
|
printf("Read: %sMissing closing brackets: }\n", buff);
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
if(ptr->data == '<'){
|
||||||
|
printf("Read: %sMissing closing brackets: >\n", buff);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
printf("Read: %sAll brackets OK\n", buff);
|
printf("Read: %sAll brackets OK\n", buff);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user