colored output

master
serr 2025-03-30 19:48:38 +03:00
parent d41a34d5df
commit 54be26ab2b
2 changed files with 7 additions and 7 deletions

View File

@ -74,19 +74,19 @@ expr:
%%
void yyerror(const char *s) {
fprintf(stderr, "Error at line %d: %s\n", yylineno, s);
fprintf(stderr, "\033[91mError at line %d: %s\n\033[0m", yylineno, s);
exit(1);
}
int main(int argc, char *argv[]) {
if (argc < 2) {
fprintf(stderr, "Usage: %s <input_file>\n", argv[0]);
fprintf(stderr, "\033[91mUsage: <...>.exe <input_file>\n\033[0m", argv[0]);
return 1;
}
FILE *input = fopen(argv[1], "r");
if (!input) {
perror("Error opening file");
perror("\033[91mError opening file"); printf("\033[0m");
return 1;
}
@ -94,6 +94,6 @@ int main(int argc, char *argv[]) {
yyparse();
fclose(input);
printf("Parsing completed successfully!\n");
printf("\033[92mParsing completed successfully!\033[0m\n");
return 0;
}

View File

@ -22,9 +22,9 @@ def main():
# Исполнение команд с выводом
for cmd in cmds:
print(f"\n\033[1mExecuting: {cmd}\033[0m")
print(f"\n\033[1mExecuting:\033[0m {cmd}")
try:
result = subprocess.run(
subprocess.run(
cmd,
shell=True,
check=True,
@ -41,7 +41,7 @@ def main():
for path in ['lex.yy.c', f'{analyzer_name}.tab.c', f'{analyzer_name}.tab.h']:
try:
os.remove(path)
print(f"Removed: {path}")
print(f"\033[1mRemoved:\033[0m {path}")
except FileNotFoundError:
pass